public class MemoryHelper extends Object implements GenericHelper
| Constructor and Description |
|---|
MemoryHelper(String helperName) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkDataSource(Map<String,? extends ModelEntity> modelEntities,
Collection<String> messages,
boolean addMissing)
Check the datasource to make sure the entity definitions are correct, optionally adding missing entities or
fields on the server
|
static void |
clearCache() |
int |
count(ModelEntity modelEntity,
String fieldName,
EntityCondition entityCondition,
EntityFindOptions findOptions)
Returns the count of the results that matches the specified condition
|
GenericValue |
create(GenericPK primaryKey) |
GenericValue |
create(GenericValue value)
Creates a Entity in the form of a GenericValue and write it to the database
|
List<GenericValue> |
findAllByPrimaryKeys(List<? extends GenericPK> primaryKeys)
Find a number of Generic Value objects by their Primary Keys, all at once
|
List<GenericValue> |
findByAnd(ModelEntity modelEntity,
List<? extends EntityCondition> expressions,
List<String> orderBy) |
List<GenericValue> |
findByAnd(ModelEntity modelEntity,
Map<String,?> fields,
List<String> orderBy)
Finds Generic Entity records by all of the specified fields (ie: combined using AND)
|
List<GenericValue> |
findByCondition(ModelEntity modelEntity,
EntityCondition entityCondition,
Collection<String> fieldsToSelect,
List<String> orderBy)
Finds GenericValues by the conditions specified in the EntityCondition object, the the EntityCondition javadoc
for more details.
|
List<GenericValue> |
findByLike(ModelEntity modelEntity,
Map<String,?> fields,
List<String> orderBy) |
List<GenericValue> |
findByMultiRelation(GenericValue value,
ModelRelation modelRelationOne,
ModelEntity modelEntityOne,
ModelRelation modelRelationTwo,
ModelEntity modelEntityTwo,
List<String> orderBy) |
List<GenericValue> |
findByOr(ModelEntity modelEntity,
List<? extends EntityCondition> expressions,
List<String> orderBy) |
List<GenericValue> |
findByOr(ModelEntity modelEntity,
Map<String,?> fields,
List<String> orderBy)
Finds Generic Entity records by all of the specified fields (ie: combined using OR)
|
GenericValue |
findByPrimaryKey(GenericPK primaryKey)
Find a Generic Entity by its Primary Key
|
GenericValue |
findByPrimaryKeyPartial(GenericPK primaryKey,
Set<String> keys)
Find a Generic Entity by its Primary Key and only returns the values requested by the passed keys (names)
|
EntityListIterator |
findListIteratorByCondition(ModelEntity modelEntity,
EntityCondition whereEntityCondition,
EntityCondition havingEntityCondition,
Collection<String> fieldsToSelect,
List<String> orderBy,
EntityFindOptions findOptions)
The memory implementation does the *minimum* that it can to allow tests to work.
|
String |
getHelperName()
Gets the name of the server configuration that corresponds to this helper
|
int |
removeAll(List<? extends GenericEntity> dummyPKs)
Remove the Entities from the List from the persistent store.
|
int |
removeByAnd(ModelEntity modelEntity,
Map<String,?> fields)
Removes/deletes Generic Entity records found by all of the specified fields (ie: combined using AND)
|
int |
removeByCondition(ModelEntity modelEntity,
EntityCondition whereCondition)
Removes/deletes Generic Entity records found by all of the specified fields (ie: combined using AND)
|
int |
removeByPrimaryKey(GenericPK primaryKey)
Remove a Generic Entity corresponding to the primaryKey
|
int |
store(GenericValue value)
Store the Entity from the GenericValue to the persistent store
|
int |
storeAll(List<? extends GenericValue> values)
Store the Entities from the List GenericValue instances to the persistent store.
|
List<GenericValue> |
transform(ModelEntity modelEntity,
EntityCondition entityCondition,
List<String> orderBy,
String lockField,
Transformation transformation)
Applies the given transformation to any entities matching the given condition.
|
public MemoryHelper(String helperName)
public static void clearCache()
public String getHelperName()
GenericHelpergetHelperName in interface GenericHelperpublic GenericValue create(GenericValue value) throws GenericEntityException
GenericHelpercreate in interface GenericHelperGenericEntityExceptionpublic GenericValue create(GenericPK primaryKey) throws GenericEntityException
GenericEntityExceptionpublic GenericValue findByPrimaryKey(GenericPK primaryKey) throws GenericEntityException
GenericHelperfindByPrimaryKey in interface GenericHelperprimaryKey - The primary key to find by.GenericEntityExceptionpublic GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set<String> keys) throws GenericEntityException
GenericHelperfindByPrimaryKeyPartial in interface GenericHelperprimaryKey - The primary key to find by.keys - The keys, or names, of the values to retrieve; only these values will be retrievedGenericEntityExceptionpublic List<GenericValue> findAllByPrimaryKeys(List<? extends GenericPK> primaryKeys) throws GenericEntityException
GenericHelperfindAllByPrimaryKeys in interface GenericHelperprimaryKeys - A List of primary keys to find by.GenericEntityExceptionpublic int removeByPrimaryKey(GenericPK primaryKey) throws GenericEntityException
GenericHelperremoveByPrimaryKey in interface GenericHelperprimaryKey - The primary key of the entity to remove.GenericEntityExceptionpublic List<GenericValue> findByAnd(ModelEntity modelEntity, Map<String,?> fields, List<String> orderBy) throws GenericEntityException
GenericHelperfindByAnd in interface GenericHelpermodelEntity - The ModelEntity of the Entity as defined in the entity XML filefields - The fields of the named entity to query by with their corresponging valuesorderBy - The fields of the named entity to order the query by; optionally add a " ASC" for ascending or "
DESC" for descendingGenericEntityExceptionpublic List<GenericValue> findByAnd(ModelEntity modelEntity, List<? extends EntityCondition> expressions, List<String> orderBy) throws GenericEntityException
GenericEntityExceptionpublic List<GenericValue> findByLike(ModelEntity modelEntity, Map<String,?> fields, List<String> orderBy) throws GenericEntityException
GenericEntityExceptionpublic List<GenericValue> findByOr(ModelEntity modelEntity, Map<String,?> fields, List<String> orderBy) throws GenericEntityException
GenericHelperfindByOr in interface GenericHelpermodelEntity - The ModelEntity of the Entity as defined in the entity XML filefields - The fields of the named entity to query by with their corresponging valuesorderBy - The fields of the named entity to order the query by; optionally add a " ASC" for ascending or "
DESC" for descendingGenericEntityExceptionpublic List<GenericValue> findByOr(ModelEntity modelEntity, List<? extends EntityCondition> expressions, List<String> orderBy) throws GenericEntityException
GenericEntityExceptionpublic List<GenericValue> findByCondition(ModelEntity modelEntity, EntityCondition entityCondition, Collection<String> fieldsToSelect, List<String> orderBy) throws GenericEntityException
GenericHelperfindByCondition in interface GenericHelpermodelEntity - The ModelEntity of the Entity as defined in the entity XML fileentityCondition - The EntityCondition object that specifies how to constrain this queryfieldsToSelect - The fields of the named entity to get from the database; if empty or null all fields will
be retreivedorderBy - The fields of the named entity to order the query by; optionally add a " ASC" for ascending or "
DESC" for descendingGenericEntityExceptionpublic List<GenericValue> findByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne, ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List<String> orderBy) throws GenericEntityException
findByMultiRelation in interface GenericHelperGenericEntityExceptionpublic EntityListIterator findListIteratorByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions) throws GenericEntityException
findListIteratorByCondition in interface GenericHelpermodelEntity - The ModelEntity of the Entity as defined in the entity XML filewhereEntityCondition - The EntityCondition object that specifies how to constrain this query before any
groupings are done (if this is a view entity with group-by aliases)havingEntityCondition - The EntityCondition object that specifies how to constrain this query after any
groupings are done (if this is a view entity with group-by aliases)fieldsToSelect - The fields of the named entity to get from the database; if empty or null all fields will
be retreivedorderBy - The fields of the named entity to order the query by; optionally add a " ASC" for ascending or "
DESC" for descendingfindOptions - An instance of EntityFindOptions that specifies advanced query options. See the
EntityFindOptions JavaDoc for more details.GenericEntityExceptionpublic int removeByAnd(ModelEntity modelEntity, Map<String,?> fields) throws GenericEntityException
GenericHelperremoveByAnd in interface GenericHelpermodelEntity - The ModelEntity of the Entity as defined in the entity XML filefields - The fields of the named entity to query by with their corresponging valuesGenericEntityExceptionpublic int removeByCondition(ModelEntity modelEntity, EntityCondition whereCondition) throws GenericEntityException
GenericHelperremoveByCondition in interface GenericHelpermodelEntity - The ModelEntity of the Entity as defined in the entity XML filewhereCondition - The EntityCondition object that specifies how to constrain this queryGenericEntityExceptionpublic int store(GenericValue value) throws GenericEntityException
GenericHelperstore in interface GenericHelpervalue - GenericValue instance containing the entityGenericEntityExceptionpublic int storeAll(List<? extends GenericValue> values) throws GenericEntityException
GenericHelperstoreAll in interface GenericHelpervalues - List of GenericValue instances containing the entities to storeGenericEntityExceptionpublic int removeAll(List<? extends GenericEntity> dummyPKs) throws GenericEntityException
GenericHelperremoveAll in interface GenericHelperdummyPKs - List of GenericEntity instances containing the entities or by and fields to removeGenericEntityExceptionpublic void checkDataSource(Map<String,? extends ModelEntity> modelEntities, Collection<String> messages, boolean addMissing) throws GenericEntityException
GenericHelpercheckDataSource in interface GenericHelpermodelEntities - Map of entityName names and ModelEntity valuesmessages - Collection to put any result messages inaddMissing - Flag indicating whether or not to add missing entities and fields on the serverGenericEntityExceptionpublic int count(ModelEntity modelEntity, String fieldName, EntityCondition entityCondition, EntityFindOptions findOptions) throws GenericEntityException
GenericHelpercount in interface GenericHelpermodelEntity - The ModelEntity of the Entity as defined in the entity XML filefieldName - The field of the named entity to count, if null this is equivalent to count(*)entityCondition - The EntityCondition object that specifies how to constrain this query The expressions to
use for the lookup, each consisting of at least a field name, an EntityOperator, and a value to compare tofindOptions - An instance of EntityFindOptions that specifies advanced query options. The only option that
is used is distinct, in which case a select (distinct fieldname) is issued. If you issue a distinct without a fieldName it will be ignored as select count (distinct *) makes no sense
GenericEntityExceptionpublic List<GenericValue> transform(ModelEntity modelEntity, EntityCondition entityCondition, List<String> orderBy, String lockField, Transformation transformation) throws GenericEntityException
GenericHelpertransform in interface GenericHelpermodelEntity - the type of entity to transform (required)entityCondition - the condition that selects the entities to transform (null means transform all)orderBy - the order in which the entities should be selected for updating (null means no ordering)lockField - the entity field to use for optimistic locking; the value of this field will be read
between the SELECT and the UPDATE to determine whether another process has updated one of the target records in
the meantime; if so, the transformation will be reapplied and another UPDATE attemptedtransformation - the transformation to apply (required)GenericEntityExceptionCopyright © 2024 Atlassian. All rights reserved.