Class ObjectAttributeBeanFactoryImpl
java.lang.Object
com.riadalabs.jira.plugins.insight.services.model.factory.ObjectAttributeBeanFactoryImpl
- All Implemented Interfaces:
ObjectAttributeBeanFactory
@PublicApi
public class ObjectAttributeBeanFactoryImpl
extends Object
implements ObjectAttributeBeanFactory
Factory component used to create
ObjectAttributeBean
.- Since:
- 5.0
- Author:
- Ola Melin
-
Constructor Summary
ConstructorsConstructorDescriptionObjectAttributeBeanFactoryImpl
(io.riada.insight.utils.PropertyManager propertyManager, io.riada.insight.services.InsightUserService insightUserService, com.riadalabs.jira.plugins.insight.services.core.ConfigureService configureService, com.riadalabs.jira.plugins.insight.services.core.ObjectFilterManager objectFilterManager, com.riadalabs.jira.plugins.insight.services.predicate.ObjectBeanPredicateFactory objectBeanPredicateFactory, com.riadalabs.jira.plugins.insight.services.core.ObjectTypeService objectTypeService, io.riada.insight.external.services.UserGroupService userGroupService, io.riada.insight.external.services.ProjectService projectService, io.riada.insight.external.services.VersionService versionService, com.atlassian.servicedesk.internal.api.featureflag.FeatureFlagCache featureFlagCache) -
Method Summary
Modifier and TypeMethodDescriptioncreateConfluenceAttributeValue
(ObjectTypeAttributeBean ota, Long... pageIds) createDefaultTypeValues
(ObjectTypeAttributeBean ota, Object... values) Creates default type values from the specified values.createGroupAttributeValue
(ObjectTypeAttributeBean ota, Predicate<InsightGroup> groupPredicate) Create an object attribute bean with all groups matching the predicatecreateGroupAttributeValueByNames
(ObjectTypeAttributeBean ota, String... groupNames) Create an object attribute bean with one or more group namescreateObjectAttributeBean
(ObjectTypeAttributeBean ota, String... values) Creates an object attribute bean by using the jira default date format as well as the jira date time format if the object type attribute supplied is of date or date time format respectively.createObjectAttributeBean
(ObjectTypeAttributeBean ota, DateFormat dateFormat, DateFormat dateTimeFormat, String... values) Creates an object attribute bean of the type specified by the object type supplied.createObjectAttributeBeanForObject
(ObjectBean objectBean, ObjectTypeAttributeBean ota, String... values) Creates an object attribute bean of the givenObjectTypeAttributeBean
type and with the supplied values.createObjectAttributeBeanForObject
(ObjectBean objectBean, ObjectTypeAttributeBean ota, DateFormat dateFormat, DateFormat dateTimeFormat, String... values) Creates an object attribute bean with the specified date format and date time format for the supplied object bean.createProjectAttributeValue
(ObjectTypeAttributeBean ota, Predicate<InsightProject> predicate) createReferenceAttributeValue
(ObjectTypeAttributeBean ota, Predicate<ObjectBean> predicate) createStatusAttributeValue
(ObjectTypeAttributeBean ota, Predicate<StatusTypeBean> predicate) createUserAttributeValueByKey
(ObjectTypeAttributeBean ota, String... userKeys) Create a user attribute by supplying one or more user keys convenient method when you have one or more user keys.createUserAttributeValueByName
(ObjectTypeAttributeBean ota, String... userNames) Create a user attribute by one or more user namescreateUserTypeAttribute
(ObjectTypeAttributeBean ota, String userKey) Creates an ObjectAttributeBean with values with user matching the given user keycreateUserTypeAttribute
(ObjectTypeAttributeBean ota, List<String> valueList, boolean includeInactiveUsers, Integer maxUserSearchValue) Creates an ObjectAttributeBean with values with all users matching the given userPredicate.createUserTypeAttributeByKeyOrUsername
(ObjectTypeAttributeBean ota, List<String> userKeys) Creates an ObjectAttributeBean with values with user matching the given user keyscreateVersionAttributeValue
(ObjectTypeAttributeBean ota, Predicate<InsightVersion> predicate)
-
Constructor Details
-
ObjectAttributeBeanFactoryImpl
public ObjectAttributeBeanFactoryImpl(io.riada.insight.utils.PropertyManager propertyManager, io.riada.insight.services.InsightUserService insightUserService, com.riadalabs.jira.plugins.insight.services.core.ConfigureService configureService, com.riadalabs.jira.plugins.insight.services.core.ObjectFilterManager objectFilterManager, com.riadalabs.jira.plugins.insight.services.predicate.ObjectBeanPredicateFactory objectBeanPredicateFactory, com.riadalabs.jira.plugins.insight.services.core.ObjectTypeService objectTypeService, io.riada.insight.external.services.UserGroupService userGroupService, io.riada.insight.external.services.ProjectService projectService, io.riada.insight.external.services.VersionService versionService, com.atlassian.servicedesk.internal.api.featureflag.FeatureFlagCache featureFlagCache)
-
-
Method Details
-
createObjectAttributeBeanForObject
@NotNull public MutableObjectAttributeBean createObjectAttributeBeanForObject(@NotNull ObjectBean objectBean, @NotNull ObjectTypeAttributeBean ota, String... values) throws InsightException Creates an object attribute bean of the givenObjectTypeAttributeBean
type and with the supplied values. The created object attribute is not appended to the supplied object bean. The caller will have to append the object attribute to the object and persist the same. The method will create all information needed for the object attribute together with object attribute values. A call to this method is the same as tocreateObjectAttributeBeanForObject(ObjectBean, ObjectTypeAttributeBean, DateFormat, DateFormat, String...)
with JIRAs default date format and date time format- Specified by:
createObjectAttributeBeanForObject
in interfaceObjectAttributeBeanFactory
- Parameters:
objectBean
- the object bean that are supposed to have the object attribute. I.e. the value for object id will be used from the object beanota
- the attribute type to createvalues
- a vararg of values.- Returns:
- the created object attribute bean (not persisted) and not added to the object beans attribute list
- Throws:
InsightException
- if the ota is of object type reference and when trying to find the reference objects fails in some way.IllegalArgumentException
- if no matching type is found for the ObjectTypeAttributeBean or if the values supplied are null
-
createObjectAttributeBeanForObject
public MutableObjectAttributeBean createObjectAttributeBeanForObject(ObjectBean objectBean, ObjectTypeAttributeBean ota, DateFormat dateFormat, DateFormat dateTimeFormat, String... values) throws InsightException Creates an object attribute bean with the specified date format and date time format for the supplied object bean. The values supplied will be used to fetch the relevant information that should be stored as a value. In the case of theObjectTypeAttributeBean
is of the type User the values supplied will be used to match users based on display name, email or user key. This method uses {#createObjectAttributeBean(ObjectTypeAttributeBean, * DateFormat, DateFormat, String...)} internally but appends the relevant object bean information to the created object attribute- Specified by:
createObjectAttributeBeanForObject
in interfaceObjectAttributeBeanFactory
- Parameters:
objectBean
- the object bean that are supposed to have the object attribute. I.e. the value for object id will be used from the object beanota
- the attribute type to createdateFormat
- a java date format used to parse date values if theObjectTypeAttributeBean
is of a date typedateTimeFormat
- a java date time format used to parse date values if theObjectTypeAttributeBean
is of a date time typevalues
- a vararg of values.- Returns:
- the created object attribute bean (not persisted)
- Throws:
InsightException
- if the ota is of object type reference and when trying to find the reference objects fails in some way.IllegalArgumentException
- if no matching type is found for the ObjectTypeAttributeBean or if the values supplied are null
-
createObjectAttributeBean
@NotNull public MutableObjectAttributeBean createObjectAttributeBean(@NotNull ObjectTypeAttributeBean ota, String... values) throws InsightException Creates an object attribute bean by using the jira default date format as well as the jira date time format if the object type attribute supplied is of date or date time format respectively. This method usescreateObjectAttributeBean(ObjectTypeAttributeBean, DateFormat, DateFormat, String...)
internally but with JIRA default dateFormat and dateTimeFormat for the date format parameters- Specified by:
createObjectAttributeBean
in interfaceObjectAttributeBeanFactory
- Parameters:
ota
- the attribute type to createvalues
- a vararg of values- Returns:
- a created (not persisted) object attribute bean with object attribute bean value(s) populated
- Throws:
InsightException
- if the ota is of object type reference and when trying to find the reference objects fails in some way.IllegalArgumentException
- if no matching type is found for the ObjectTypeAttributeBean or if the values supplied are null
-
createObjectAttributeBean
public MutableObjectAttributeBean createObjectAttributeBean(ObjectTypeAttributeBean ota, DateFormat dateFormat, DateFormat dateTimeFormat, String... values) throws InsightException Creates an object attribute bean of the type specified by the object type supplied. If the attribute type is of a date type the dateFormat will be used on order to parsed the supplied values. The values will be used differently based on the type of attribute. The following will happen based on the object type attribute supplied- Default
- The value(s) will be parsed as the relevant type. If not possible an
IllegalArgumentException
will be thrown - Object reference
- The value(s) supplied will be compared to objects matching the object key, the id or the label for objects of the object type specified by the object type attribute
- Status
- The supplied value(s) is matched with the status name
- User
- The supplied value(s) is first matched with users based on user name if no user is found based on user name the user is matched with user key, display name, e-mail address or username
- Group
- The value(s) is matched with group names
- Project
- The value(s) supplied can contain JIRA project keys or project names
- Confluence
- The supplied value(s) must be confluence page id's
- Version
- Value(s) is matched with version names
- Specified by:
createObjectAttributeBean
in interfaceObjectAttributeBeanFactory
- Parameters:
ota
- the object type attribute bean that the object attribute created should be ofdateFormat
- a date format used to parse date values if the object type attribute is of a date typedateTimeFormat
- a date time format used to parse date time values if the object type attribute is of a date time typevalues
- a vararg of string values. See the above description for what is expected for each value- Returns:
- a created (not persisted) object attribute bean with object attribute bean value(s) populated
- Throws:
InsightException
- if the object type attribute is of a object reference type and Insight fails to load the object referenced by the supplied valuesIllegalArgumentException
- if no matching type is found for the ObjectTypeAttributeBean or if the values supplied are null
-
createUserAttributeValueByKey
public MutableObjectAttributeBean createUserAttributeValueByKey(ObjectTypeAttributeBean ota, String... userKeys) Create a user attribute by supplying one or more user keys convenient method when you have one or more user keys. Will use thecreateObjectAttributeBean(ObjectTypeAttributeBean, List)
internally- Specified by:
createUserAttributeValueByKey
in interfaceObjectAttributeBeanFactory
- Parameters:
ota
- the object type attribute determining the type that should be created, can not be nulluserKeys
- the value(s) that should be used to search jira for users by key- Returns:
- a created (not persisted) object attribute bean with object attribute bean value(s) populated
-
createUserAttributeValueByName
public MutableObjectAttributeBean createUserAttributeValueByName(ObjectTypeAttributeBean ota, String... userNames) Create a user attribute by one or more user names- Specified by:
createUserAttributeValueByName
in interfaceObjectAttributeBeanFactory
- Parameters:
ota
- the object type attribute determining the type that should be created, can not be nulluserNames
- the user names that should be used to query user service for users- Returns:
- the created MutableObjectAttributeBean with the corresponding
MutableObjectAttributeValueBean
(s)
-
createUserTypeAttribute
public MutableObjectAttributeBean createUserTypeAttribute(ObjectTypeAttributeBean ota, List<String> valueList, boolean includeInactiveUsers, Integer maxUserSearchValue) Creates an ObjectAttributeBean with values with all users matching the given userPredicate.- Specified by:
createUserTypeAttribute
in interfaceObjectAttributeBeanFactory
- Parameters:
ota
- the object type attribute bean. The maximum cardinality will be used from this parameter and only find that many users. If multiple users match the predicate only the maximum cardinality will be included. This may not be deterministicvalueList
- the list of users that should be includedincludeInactiveUsers
- if inactive users should be included or not.- Returns:
- the created MutableObjectAttributeBean with the corresponding
MutableObjectAttributeValueBean
(s)
-
createUserTypeAttribute
public MutableObjectAttributeBean createUserTypeAttribute(ObjectTypeAttributeBean ota, String userKey) Creates an ObjectAttributeBean with values with user matching the given user key- Specified by:
createUserTypeAttribute
in interfaceObjectAttributeBeanFactory
- Parameters:
ota
- the object type attribute bean. The maximum cardinality will be used from this parameter and only find that many users. If multiple users match the predicate only the maximum cardinality will be included. This may not be deterministicuserKey
- the user key- Returns:
- the created MutableObjectAttributeBean with the corresponding
MutableObjectAttributeValueBean
(s)
-
createUserTypeAttributeByKeyOrUsername
public MutableObjectAttributeBean createUserTypeAttributeByKeyOrUsername(ObjectTypeAttributeBean ota, List<String> userKeys) Creates an ObjectAttributeBean with values with user matching the given user keys- Specified by:
createUserTypeAttributeByKeyOrUsername
in interfaceObjectAttributeBeanFactory
- Parameters:
ota
- the object type attribute bean. The maximum cardinality will be used from this parameter and only find that many users. If multiple users match the predicate only the maximum cardinality will be included. This may not be deterministicuserKeys
- the list of user keys- Returns:
- the created MutableObjectAttributeBean with the corresponding
MutableObjectAttributeValueBean
(s)
-
createGroupAttributeValueByNames
public MutableObjectAttributeBean createGroupAttributeValueByNames(ObjectTypeAttributeBean ota, String... groupNames) Create an object attribute bean with one or more group names- Specified by:
createGroupAttributeValueByNames
in interfaceObjectAttributeBeanFactory
- Parameters:
ota
- the object type attribute determining the type that should be created, can not be nullgroupNames
- used to query the JIRA for groups matching the given name(s)- Returns:
- the created MutableObjectAttributeBean with the corresponding
MutableObjectAttributeValueBean
(s)
-
createGroupAttributeValue
public MutableObjectAttributeBean createGroupAttributeValue(ObjectTypeAttributeBean ota, Predicate<InsightGroup> groupPredicate) Create an object attribute bean with all groups matching the predicate- Specified by:
createGroupAttributeValue
in interfaceObjectAttributeBeanFactory
- Parameters:
ota
- the object type attribute determining the type that should be created, can not be nullgroupPredicate
- a predicate that is used to determine which groups that should be matched when creating the group attributes- Returns:
- the created MutableObjectAttributeBean with the corresponding
MutableObjectAttributeValueBean
(s)
-
createProjectAttributeValue
public MutableObjectAttributeBean createProjectAttributeValue(ObjectTypeAttributeBean ota, Predicate<InsightProject> predicate) - Specified by:
createProjectAttributeValue
in interfaceObjectAttributeBeanFactory
-
createConfluenceAttributeValue
public MutableObjectAttributeBean createConfluenceAttributeValue(ObjectTypeAttributeBean ota, Long... pageIds) - Specified by:
createConfluenceAttributeValue
in interfaceObjectAttributeBeanFactory
-
createVersionAttributeValue
public MutableObjectAttributeBean createVersionAttributeValue(ObjectTypeAttributeBean ota, Predicate<InsightVersion> predicate) - Specified by:
createVersionAttributeValue
in interfaceObjectAttributeBeanFactory
-
createStatusAttributeValue
public MutableObjectAttributeBean createStatusAttributeValue(ObjectTypeAttributeBean ota, Predicate<StatusTypeBean> predicate) throws InsightException - Specified by:
createStatusAttributeValue
in interfaceObjectAttributeBeanFactory
- Throws:
InsightException
-
createReferenceAttributeValue
public MutableObjectAttributeBean createReferenceAttributeValue(ObjectTypeAttributeBean ota, Predicate<ObjectBean> predicate) throws InsightException - Specified by:
createReferenceAttributeValue
in interfaceObjectAttributeBeanFactory
- Throws:
InsightException
-
createDefaultTypeValues
public MutableObjectAttributeBean createDefaultTypeValues(ObjectTypeAttributeBean ota, Object... values) Creates default type values from the specified values. Will use default dateFormatter and dateTimeFormatter if the specified object type attribute is of date or date time type. If more values then supported by the ObjectTypeAttributeBean are supplied as values the order of the values are important. E.g. for a text attribute only one value is allowed and if the values are text1, text2 only text1 will be used.- Specified by:
createDefaultTypeValues
in interfaceObjectAttributeBeanFactory
- Parameters:
ota
- the object type attribute determining the type that should be created, can not be nullvalues
- the values that should be added as the attributes- Returns:
- a created (not persisted) object attribute bean with object attribute bean value(s) populated
-