com.atlassian.jira.entity.property
Class JsonEntityPropertyManagerImpl

java.lang.Object
  extended by com.atlassian.jira.entity.property.JsonEntityPropertyManagerImpl
All Implemented Interfaces:
JsonEntityPropertyManager

public class JsonEntityPropertyManagerImpl
extends Object
implements JsonEntityPropertyManager

Low-level database API for accessing JSON entity properties.

Since:
v6.1

Field Summary
static int MAXIMUM_ENTITY_NAME_LENGTH
          If you any of these change these values, please update the JavaDocs for JsonEntityPropertyManager.put(String, Long, String, String) and JsonEntityPropertyManager.getMaximumValueLength() accordingly.
static int MAXIMUM_KEY_LENGTH
           
static int MAXIMUM_VALUE_LENGTH
           
 
Constructor Summary
JsonEntityPropertyManagerImpl(EntityEngine entityEngine)
           
 
Method Summary
 long countByEntity(String entityName, Long entityId)
          Counts the number of properties that match the given entity.
 long countByEntityNameAndPropertyKey(String entityName, String key)
          Counts the number of properties that match the given entity name and property key.
 void delete(String entityName, Long entityId, String key)
          Deletes the stored value for an entity property, if it exists.
 void deleteByEntity(String entityName, Long entityId)
          Deletes all properties that are associated with the provided entity.
 void deleteByEntityNameAndPropertyKey(String entityName, String key)
          Deletes all properties that are associated with the provided entity name and property key.
 boolean exists(String entityName, Long entityId, String key)
          Returns whether or not a given property exists.
 List<String> findKeys(String entityName, Long entityId)
          Produces a list of entity property keys that match the provided entity name and entity id.
 List<String> findKeys(String entityName, String keyPrefix)
          Produces a list of entity property keys that match the provided entity name and key prefix.
 EntityProperty get(String entityName, Long entityId, String key)
          Look up an entity property by the entity name, entity id, and property key.
 int getMaximumValueLength()
          The maximum allowed length (in characters) permitted for the String json value when calling JsonEntityPropertyManager.put(String, Long, String, String) (or JsonEntityPropertyManager.putDryRun(String, Long, String, String)).
 void put(String entityName, Long entityId, String key, String json)
          Set the value for an entity property, creating, updating, or deleting it as necessary.
 void putDryRun(String entityName, Long entityId, String key, String json)
          Performs all of the validation that would be performed during a JsonEntityPropertyManager.put(String, Long, String, String) request, but does not actually store the value.
 EntityPropertyQuery<?> query()
          Returns a query object for finding, counting, or deleting properties with various restrictions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXIMUM_ENTITY_NAME_LENGTH

public static final int MAXIMUM_ENTITY_NAME_LENGTH
If you any of these change these values, please update the JavaDocs for JsonEntityPropertyManager.put(String, Long, String, String) and JsonEntityPropertyManager.getMaximumValueLength() accordingly.

See Also:
Constant Field Values

MAXIMUM_KEY_LENGTH

public static final int MAXIMUM_KEY_LENGTH
See Also:
Constant Field Values

MAXIMUM_VALUE_LENGTH

public static final int MAXIMUM_VALUE_LENGTH
See Also:
Constant Field Values
Constructor Detail

JsonEntityPropertyManagerImpl

public JsonEntityPropertyManagerImpl(EntityEngine entityEngine)
Method Detail

putDryRun

public void putDryRun(@Nonnull
                      String entityName,
                      @Nonnull
                      Long entityId,
                      @Nonnull
                      String key,
                      String json)
Description copied from interface: JsonEntityPropertyManager
Performs all of the validation that would be performed during a JsonEntityPropertyManager.put(String, Long, String, String) request, but does not actually store the value.

Specified by:
putDryRun in interface JsonEntityPropertyManager
Parameters:
entityName - as for JsonEntityPropertyManager.put(String, Long, String, String)
entityId - as for JsonEntityPropertyManager.put(String, Long, String, String)
key - as for JsonEntityPropertyManager.put(String, Long, String, String)
json - as for JsonEntityPropertyManager.put(String, Long, String, String)
See Also:
JsonEntityPropertyManager.put(String, Long, String, String)

put

public void put(@Nonnull
                String entityName,
                @Nonnull
                Long entityId,
                @Nonnull
                String key,
                String json)
Description copied from interface: JsonEntityPropertyManager
Set the value for an entity property, creating, updating, or deleting it as necessary.

Specified by:
put in interface JsonEntityPropertyManager
Parameters:
entityName - the entity name for the property (maximum length 255). As explained in the class 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, the RemoteVersionLinkService uses the version ID for this value.
key - the key for the property (maximum length 255). This value should generally be suitable for a reverse lookup when the same data might be associated with multiple entities. For example, the RemoteVersionLinkService uses the global ID of 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, or null to delete it (maximum length is available by calling JsonEntityPropertyManager.getMaximumValueLength())
See Also:
JsonEntityPropertyManager.putDryRun(String, Long, String, String)

get

public EntityProperty get(String entityName,
                          Long entityId,
                          String key)
Description copied from interface: JsonEntityPropertyManager
Look up an entity property by the entity name, entity id, and property key.

Specified by:
get in interface JsonEntityPropertyManager
Parameters:
entityName - the entity name of the property
entityId - the entity ID of the property
key - the key of the property
Returns:
the matching property, or null if the property does not exist.

delete

public void delete(@Nonnull
                   String entityName,
                   @Nonnull
                   Long entityId,
                   @Nonnull
                   String key)
Description copied from interface: JsonEntityPropertyManager
Deletes the stored value for an entity property, if it exists.

Specified by:
delete in interface JsonEntityPropertyManager
Parameters:
entityName - the entity name of the property to be deleted
entityId - the entity ID of the property to be deleted
key - the key of the property to be deleted

getMaximumValueLength

public int getMaximumValueLength()
Description copied from interface: JsonEntityPropertyManager
The maximum allowed length (in characters) permitted for the String json value when calling JsonEntityPropertyManager.put(String, Long, String, String) (or JsonEntityPropertyManager.putDryRun(String, Long, String, String)). This value is currently 32,768, but this may change in the future.

Specified by:
getMaximumValueLength in interface JsonEntityPropertyManager

query

public EntityPropertyQuery<?> query()
Description copied from interface: JsonEntityPropertyManager
Returns a query object for finding, counting, or deleting properties with various restrictions. See EntityPropertyQuery for usage and minimum requirements.

Specified by:
query in interface JsonEntityPropertyManager
Returns:
the query object

findKeys

@Nonnull
public List<String> findKeys(@Nonnull
                                     String entityName,
                                     @Nonnull
                                     String keyPrefix)
Description copied from interface: JsonEntityPropertyManager
Produces 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:
findKeys in interface JsonEntityPropertyManager
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 be null or a blank string
Returns:
the list of distinct matching keys, sorted in ascending alphabetical order

findKeys

@Nonnull
public List<String> findKeys(@Nonnull
                                     String entityName,
                                     @Nonnull
                                     Long entityId)
Description copied from interface: JsonEntityPropertyManager
Produces 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:
findKeys in interface JsonEntityPropertyManager
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

public boolean exists(@Nonnull
                      String entityName,
                      @Nonnull
                      Long entityId,
                      @Nonnull
                      String key)
Description copied from interface: JsonEntityPropertyManager
Returns whether or not a given property exists. This convenience method is equivalent to JsonEntityPropertyManager.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:
exists in interface JsonEntityPropertyManager
Parameters:
entityName - the entity name for the property
entityId - the entity ID for the property
key - the key for the property

countByEntity

public long countByEntity(@Nonnull
                          String entityName,
                          @Nonnull
                          Long entityId)
Description copied from interface: JsonEntityPropertyManager
Counts 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:
countByEntity in interface JsonEntityPropertyManager
Parameters:
entityName - the entity name of the owning entity
entityId - the entity ID of the owning entity
Returns:
the count of properties assigned to that entity

countByEntityNameAndPropertyKey

public long countByEntityNameAndPropertyKey(@Nonnull
                                            String entityName,
                                            @Nonnull
                                            String key)
Description copied from interface: JsonEntityPropertyManager
Counts 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:
countByEntityNameAndPropertyKey in interface JsonEntityPropertyManager
Parameters:
entityName - the entity name of the owning entities
key - the property key to look for
Returns:
the count of properties with that key which are assigned to entities with the given name

deleteByEntity

public void deleteByEntity(@Nonnull
                           String entityName,
                           @Nonnull
                           Long entityId)
Description copied from interface: JsonEntityPropertyManager
Deletes 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:
deleteByEntity in interface JsonEntityPropertyManager
Parameters:
entityName - the entity name for the properties
entityId - the entity ID for the properties

deleteByEntityNameAndPropertyKey

public void deleteByEntityNameAndPropertyKey(@Nonnull
                                             String entityName,
                                             @Nonnull
                                             String key)
Description copied from interface: JsonEntityPropertyManager
Deletes 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:
deleteByEntityNameAndPropertyKey in interface JsonEntityPropertyManager
Parameters:
entityName - the entity name for the properties
key - the property key for the properties


Copyright © 2002-2014 Atlassian. All Rights Reserved.