Class JsonEntityPropertyManagerImpl
java.lang.Object
com.atlassian.jira.entity.property.JsonEntityPropertyManagerImpl
- All Implemented Interfaces:
JsonEntityPropertyManager
Low-level database API for accessing JSON entity properties.
- Since:
- v6.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIf you any of these change these values, please update the JavaDocs forJsonEntityPropertyManager.put(String, Long, String, String)andJsonEntityPropertyManager.getMaximumValueLength()accordingly.static final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionJsonEntityPropertyManagerImpl(EntityEngine entityEngine, com.atlassian.event.api.EventPublisher eventPublisher, DbConnectionManager dbConnectionManager) -
Method Summary
Modifier and TypeMethodDescriptionlongcountByEntity(String entityName, Long entityId) Counts the number of properties that match the given entity.longcountByEntityNameAndPropertyKey(String entityName, String key) Counts the number of properties that match the given entity name and property key.voidDeletes the stored value for an entity property, if it exists.voiddeleteByEntity(String entityName, Long entityId) Deletes all properties that are associated with the provided entity.voiddeleteByEntityNameAndEntityIds(String entityName, List<Long> entityIds) Deletes all properties that are associated with the provided entities.voiddeleteByEntityNameAndPropertyKey(String entityName, String key) Deletes all properties that are associated with the provided entity name and property key.booleanReturns whether or not a given property exists.Produces a list of entity property keys that match the provided entity name and entity id.Produces a list of entity property keys that match the provided entity name and key prefix.Retrieve all entity properties by the entity name, entity id.Look up an entity property by the entity name, entity id, and property key.Retrieve all entity properties by the entity name, entity id and the supplied keysintThe maximum allowed length (in characters) permitted for theString jsonvalue when callingJsonEntityPropertyManager.put(String, Long, String, String)(orJsonEntityPropertyManager.putDryRun(String, String, String)).voidput(ApplicationUser user, String entityName, Long entityId, String key, String json, BiFunction<ApplicationUser, EntityProperty, ? extends EntityPropertySetEvent> eventFunction, boolean dispatchEvent) Set the value for an entity property, creating, updating, or deleting it as necessary.voidSet the value for an entity property, creating, updating, or deleting it as necessary.voidPerforms all of the validation that would be performed during aJsonEntityPropertyManager.put(String, Long, String, String)request, but does not actually store the value.query()Returns a query object for finding, counting, or deleting properties with various restrictions.
-
Field Details
-
MAXIMUM_ENTITY_NAME_LENGTH
public static final int MAXIMUM_ENTITY_NAME_LENGTHIf you any of these change these values, please update the JavaDocs forJsonEntityPropertyManager.put(String, Long, String, String)andJsonEntityPropertyManager.getMaximumValueLength()accordingly.- See Also:
-
MAXIMUM_KEY_LENGTH
public static final int MAXIMUM_KEY_LENGTH- See Also:
-
MAXIMUM_VALUE_LENGTH
public static final int MAXIMUM_VALUE_LENGTH- See Also:
-
-
Constructor Details
-
JsonEntityPropertyManagerImpl
public JsonEntityPropertyManagerImpl(EntityEngine entityEngine, com.atlassian.event.api.EventPublisher eventPublisher, DbConnectionManager dbConnectionManager)
-
-
Method Details
-
putDryRun
Description copied from interface:JsonEntityPropertyManagerPerforms all of the validation that would be performed during aJsonEntityPropertyManager.put(String, Long, String, String)request, but does not actually store the value.- Specified by:
putDryRunin interfaceJsonEntityPropertyManager- Parameters:
entityName- as forJsonEntityPropertyManager.put(String, Long, String, String)key- as forJsonEntityPropertyManager.put(String, Long, String, String)json- as forJsonEntityPropertyManager.put(String, Long, String, String)- See Also:
-
put
public void put(@Nonnull String entityName, @Nonnull Long entityId, @Nonnull String key, String json) Description copied from interface:JsonEntityPropertyManagerSet the value for an entity property, creating, updating, or deleting it as necessary.- Specified by:
putin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name for the property (maximum length255). As explained in theclass documentation, this value should be unique to the service creating the properties and will generally not be the same as the entity to which the properties are attached.entityId- the entity ID for the property. In general, this will be the same as the ID of the owning entity; for example, theRemoteVersionLinkServiceuses theversion IDfor this value.key- the key for the property (maximum length255). This value should generally be suitable for a reverse lookup when the same data might be associated with multiple entities. For example, theRemoteVersionLinkServiceuses theglobal IDof the remote object, which is the same identifier used by applinks to identify a Confluence page, Bamboo project, etc.json- the new value for the property, ornullto delete it (maximum length is available by callingJsonEntityPropertyManager.getMaximumValueLength())- See Also:
-
put
public void put(ApplicationUser user, @Nonnull String entityName, @Nonnull Long entityId, @Nonnull String key, @Nullable String json, BiFunction<ApplicationUser, EntityProperty, ? extends EntityPropertySetEvent> eventFunction, boolean dispatchEvent) Description copied from interface:JsonEntityPropertyManagerSet the value for an entity property, creating, updating, or deleting it as necessary.- Specified by:
putin interfaceJsonEntityPropertyManager- Parameters:
user- The user performing the action. The event will be actioned as this userentityName- the entity name for the property (maximum length255). As explained in theclass documentation, this value should be unique to the service creating the properties and will generally not be the same as the entity to which the properties are attached.entityId- the entity ID for the property. In general, this will be the same as the ID of the owning entity; for example, theRemoteVersionLinkServiceuses theversion IDfor this value.key- the key for the property (maximum length255). This value should generally be suitable for a reverse lookup when the same data might be associated with multiple entities. For example, theRemoteVersionLinkServiceuses theglobal IDof the remote object, which is the same identifier used by applinks to identify a Confluence page, Bamboo project, etc.json- the new value for the property, ornullto delete it (maximum length is available by callingJsonEntityPropertyManager.getMaximumValueLength())eventFunction- the function that generates the event to be thrown. SeeEntityPropertyHelperfor some functions that may be used to generate eventsdispatchEvent- true if the method should dispatch an event after it is run.- See Also:
-
get
Description copied from interface:JsonEntityPropertyManagerLook up an entity property by the entity name, entity id, and property key.- Specified by:
getin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name of the propertyentityId- the entity ID of the propertykey- the key of the property- Returns:
- the matching property, or
nullif the property does not exist.
-
get
Description copied from interface:JsonEntityPropertyManagerRetrieve all entity properties by the entity name, entity id.- Specified by:
getin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name of the propertyentityId- the entity ID of the property- Returns:
- a map with the property key as the map key of all properties for the entity.
-
get
@Nullable public Map<String,EntityProperty> get(String entityName, Long entityId, List<String> keys) Description copied from interface:JsonEntityPropertyManagerRetrieve all entity properties by the entity name, entity id and the supplied keys- Specified by:
getin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name of the propertyentityId- the entity ID of the propertykeys- list of property keys to match- Returns:
- a map with the property key as the map key of all properties for the entity.
-
delete
Description copied from interface:JsonEntityPropertyManagerDeletes the stored value for an entity property, if it exists.- Specified by:
deletein interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name of the property to be deletedentityId- the entity ID of the property to be deletedkey- the key of the property to be deleted
-
getMaximumValueLength
public int getMaximumValueLength()Description copied from interface:JsonEntityPropertyManagerThe maximum allowed length (in characters) permitted for theString jsonvalue when callingJsonEntityPropertyManager.put(String, Long, String, String)(orJsonEntityPropertyManager.putDryRun(String, String, String)). This value is currently32,768, but this may change in the future.- Specified by:
getMaximumValueLengthin interfaceJsonEntityPropertyManager
-
query
Description copied from interface:JsonEntityPropertyManagerReturns a query object for finding, counting, or deleting properties with various restrictions. SeeEntityPropertyQueryfor usage and minimum requirements.- Specified by:
queryin interfaceJsonEntityPropertyManager- Returns:
- the query object
-
findKeys
Description copied from interface:JsonEntityPropertyManagerProduces a list of entity property keys that match the provided entity name and key prefix. This convenience method is exactly equivalent to:JsonEntityPropertyManager.query().entityName(entityName).keyPrefix(keyPrefix).findDistinctKeys()- Specified by:
findKeysin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name for the entities that are associated with the properties.keyPrefix- the prefix to apply for limiting which keys are returned; must not benullor a blank string- Returns:
- the list of distinct matching keys, sorted in ascending alphabetical order
-
findKeys
Description copied from interface:JsonEntityPropertyManagerProduces a list of entity property keys that match the provided entity name and entity id. This convenience method is exactly equivalent to:JsonEntityPropertyManager.query().entityName(entityName).entityId(entityId).EntityPropertyQuery.ExecutableQuery.findKeys()- Specified by:
findKeysin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name for the entities that are associated with the properties.entityId- the id of the entity.- Returns:
- the list of distinct matching keys, sorted in ascending alphabetical order
-
exists
Description copied from interface:JsonEntityPropertyManagerReturns whether or not a given property exists. This convenience method is equivalent toJsonEntityPropertyManager.get(String, Long, String)!= null, but does not actually retrieve the JSON data from the database, so it may have better performance characteristics when the JSON content is not needed.- Specified by:
existsin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name for the propertyentityId- the entity ID for the propertykey- the key for the property
-
countByEntity
Description copied from interface:JsonEntityPropertyManagerCounts the number of properties that match the given entity. This convenience method is exactly equivalent to:JsonEntityPropertyManager.query().entityName(entityName).entityId(entityId).count()- Specified by:
countByEntityin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name of the owning entityentityId- the entity ID of the owning entity- Returns:
- the count of properties assigned to that entity
-
countByEntityNameAndPropertyKey
Description copied from interface:JsonEntityPropertyManagerCounts the number of properties that match the given entity name and property key. This convenience method is exactly equivalent to:JsonEntityPropertyManager.query().entityName(entityName).key(key).count()- Specified by:
countByEntityNameAndPropertyKeyin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name of the owning entitieskey- the property key to look for- Returns:
- the count of properties with that key which are assigned to entities with the given name
-
deleteByEntity
Description copied from interface:JsonEntityPropertyManagerDeletes all properties that are associated with the provided entity. This convenience method is exactly equivalent to:JsonEntityPropertyManager.query().entityName(entityName).entityId(entityId).delete()- Specified by:
deleteByEntityin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name for the propertiesentityId- the entity ID for the properties
-
deleteByEntityNameAndPropertyKey
Description copied from interface:JsonEntityPropertyManagerDeletes all properties that are associated with the provided entity name and property key. This convenience method is exactly equivalent to:JsonEntityPropertyManager.query().entityName(entityName).key(key).delete()- Specified by:
deleteByEntityNameAndPropertyKeyin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name for the propertieskey- the property key for the properties
-
deleteByEntityNameAndEntityIds
public void deleteByEntityNameAndEntityIds(@Nonnull String entityName, @Nonnull List<Long> entityIds) Description copied from interface:JsonEntityPropertyManagerDeletes all properties that are associated with the provided entities.- Specified by:
deleteByEntityNameAndEntityIdsin interfaceJsonEntityPropertyManager- Parameters:
entityName- the entity name for the propertiesentityIds- the IDs of the entities
-