/** Finds Generic Entity records by all of the specified fields (ie: combined using AND) * @param entityName The Name of the Entity as defined in the entity XML file * @param fields The fields of the named entity to query by with their corresponging values * @return List of GenericValue instances that match the query */ public List findByAnd(String entityName, Map fields) throws GenericEntityException { return this.findByAnd(entityName, fields, null); }
/** Finds Generic Entity records by all of the specified fields (ie: combined using AND) * @param entityName The Name of the Entity as defined in the entity XML file * @param fields The fields of the named entity to query by with their corresponging values * @return List of GenericValue instances that match the query */ public List findByAnd(String entityName, Map fields) throws GenericEntityException { return this.findByAnd(entityName, fields, null); }
/** Finds all Generic entities *@param entityName The Name of the Entity as defined in the entity XML file *@return List containing all Generic entities */ public List findAll(String entityName) throws GenericEntityException { return this.findByAnd(entityName, new HashMap(), null); }
/** Finds all Generic entities *@param entityName The Name of the Entity as defined in the entity XML file *@return List containing all Generic entities */ public List findAll(String entityName) throws GenericEntityException { return this.findByAnd(entityName, new HashMap(), null); }
/** Finds all Generic entities *@param entityName The Name of the Entity as defined in the entity XML file *@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending *@return List containing all Generic entities */ public List findAll(String entityName, List orderBy) throws GenericEntityException { return this.findByAnd(entityName, new HashMap(), orderBy); }
/** Finds all Generic entities *@param entityName The Name of the Entity as defined in the entity XML file *@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending *@return List containing all Generic entities */ public List findAll(String entityName, List orderBy) throws GenericEntityException { return this.findByAnd(entityName, new HashMap(), orderBy); }
/** * Finds all Generic entities of the given type, optionally sorted. * * @param entityName The Name of the Entity as defined in the entity XML file * @param orderBy the entity fields by which to order the query; optionally * add " ASC" for ascending or " DESC" for descending to each field name * @return List containing all Generic entities */ public List<GenericValue> findAll(final String entityName, final List<String> orderBy) throws GenericEntityException { checkIfLocked(); return findByAnd(entityName, new HashMap<String, Object>(), orderBy); }
/** * Finds all Generic entities of the given type. * * @param entityName The Name of the Entity as defined in the entity XML file * @return all entities of the given type */ public List<GenericValue> findAll(final String entityName) throws GenericEntityException { checkIfLocked(); return findByAnd(entityName, new HashMap<String, Object>(), null); }
/** * Finds Generic Entity records by all of the specified fields (ie: combined using AND). * * @param entityName The Name of the Entity as defined in the entity XML file * @param fields The fields of the named entity to query by with their corresponging values * @return List of GenericValue instances that match the query */ public List<GenericValue> findByAnd(final String entityName, final Map<String, ?> fields) throws GenericEntityException { checkIfLocked(); return findByAnd(entityName, fields, null); }
public Collection<Message> doUpgrade() throws Exception { final GenericDelegator genericDelegator = ComponentLocator.getComponent(GenericDelegator.class); final List<GenericValue> services = genericDelegator.findByAnd("ServiceConfig", EasyMap.build("clazz", OLD_CLASS_NAME)); if (services.isEmpty()) { log.info("No JiraPluginSchedulerService found. No classname fixing required"); } for (final GenericValue service : services) { service.set("clazz", NEW_CLASS_NAME); log.info("Fixing classname for service " + service.getString("name")); } genericDelegator.storeAll(services); return null; }
public GenericValue getIssueByWorkflow(Long wfid) throws GenericEntityException { List values = CoreFactory.getGenericDelegator().findByAnd("Issue", FieldMap.build("workflowId", wfid)); return EntityUtil.getOnly(values); }
/** * Create the default internal directory configuration. * @param position */ private void createInternalDirectoryConfiguration(final int position) throws GenericEntityException { // Check if the default directory already exists if (!genericDelegator.findByAnd(DIRECTORY_ENTITY_NAME, FieldMap.build("directoryName", DEFAULT_DIRECTORY)).isEmpty()) { // already created return; } addDirectory(INTERNAL_DIRECTORY_ID, DEFAULT_DIRECTORY, true, "JIRA default internal directory", InternalDirectory.class.getName(), DirectoryType.INTERNAL, position); // Add the allowed operations addDirectoryOperations(INTERNAL_DIRECTORY_ID, Sets.newHashSet(OperationType.values())); // Add the attributes addDirectoryAttribute(INTERNAL_DIRECTORY_ID, InternalDirectory.ATTRIBUTE_USER_ENCRYPTION_METHOD, PasswordEncoderFactory.ATLASSIAN_SECURITY_ENCODER); }
/** * Finds Generic Entity records by all of the specified fields (i.e. * combined using AND). * * @param entityName The Name of the Entity as defined in the entity XML file * @param fields the names and values of the fields by which to query (can be null) * @param orderBy The fields of the named entity to order the query by; * optionally add a " ASC" for ascending or " DESC" for descending * @return List of GenericValue instances that match the query */ public List<GenericValue> findByAnd( final String entityName, final Map<String, ?> fields, final List<String> orderBy) throws GenericEntityException { checkIfLocked(); final ModelEntity modelEntity = getModelReader().getModelEntity(entityName); return findByAnd(modelEntity, fields, orderBy); }
/** Finds Generic Entity records by all of the specified fields (ie: combined using AND) * @param entityName The Name of the Entity as defined in the entity XML file * @param fields The fields of the named entity to query by with their corresponging values * @param orderBy The fields of the named entity to order the query by; * optionally add a " ASC" for ascending or " DESC" for descending * @return List of GenericValue instances that match the query */ public List findByAnd(String entityName, Map fields, List orderBy) throws GenericEntityException { ModelEntity modelEntity = getModelReader().getModelEntity(entityName); GenericValue dummyValue = new GenericValue(modelEntity, fields); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_FIND, dummyValue, null, false, false); return findByAnd(modelEntity, fields, orderBy); }
/** Finds Generic Entity records by all of the specified fields (ie: combined using AND) * @param entityName The Name of the Entity as defined in the entity XML file * @param fields The fields of the named entity to query by with their corresponging values * @param orderBy The fields of the named entity to order the query by; * optionally add a " ASC" for ascending or " DESC" for descending * @return List of GenericValue instances that match the query */ public List findByAnd(String entityName, Map fields, List orderBy) throws GenericEntityException { ModelEntity modelEntity = getModelReader().getModelEntity(entityName); GenericValue dummyValue = new GenericValue(modelEntity, fields); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_FIND, dummyValue, null, false, false); return findByAnd(modelEntity, fields, orderBy); }
/** * We need to make sure that we account for failed upgrades - the QA-EACJ migration showed that the table may linger but the sequence ids go * * @param entityName * @param nextId * @throws GenericEntityException */ private void setNextId(String entityName, Long nextId) throws GenericEntityException { final GenericDelegator delegator = getDelegator(); // First ensure we have an entry in SequenecValueItem table delegator.getNextSeqId(entityName); // Now set it to nextId GenericValue sequenceItem = EntityUtil.getOnly(delegator.findByAnd("SequenceValueItem", ImmutableMap.of("seqName", entityName))); if (sequenceItem != null) { sequenceItem.set("seqId", nextId); sequenceItem.store(); delegator.refreshSequencer(); } }
/** Get the named Related Entity for the GenericValue from the persistent store * @param relationName String containing the relation name which is the * combination of relation.title and relation.rel-entity-name as * specified in the entity XML definition file * @param byAndFields the fields that must equal in order to keep; may be null * @param orderBy The fields of the named entity to order the query by; may be null; * optionally add a " ASC" for ascending or " DESC" for descending * @param value GenericValue instance containing the entity * @return List of GenericValue instances as specified in the relation definition */ public List getRelated(String relationName, Map byAndFields, List orderBy, GenericValue value) throws GenericEntityException { ModelEntity modelEntity = value.getModelEntity(); ModelRelation relation = modelEntity.getRelation(relationName); if (relation == null) { throw new GenericModelException("Could not find relation for relationName: " + relationName + " for value " + value); } // put the byAndFields (if not null) into the hash map first, // they will be overridden by value's fields if over-specified this is important for security and cleanliness Map fields = byAndFields == null ? new HashMap() : new HashMap(byAndFields); for (int i = 0; i < relation.getKeyMapsSize(); i++) { ModelKeyMap keyMap = relation.getKeyMap(i); fields.put(keyMap.getRelFieldName(), value.get(keyMap.getFieldName())); } return this.findByAnd(relation.getRelEntityName(), fields, orderBy); }
/** * We need to make sure that we account for failed upgrades - the QA-EACJ migration showed that the table may linger but the sequence ids go * * @param entityName * @param nextId * @throws GenericEntityException */ private void setNextId(String entityName, Long nextId) throws GenericEntityException { final GenericDelegator delegator = getDelegator(); // First ensure we have an entry in SequenecValueItem table delegator.getNextSeqId(entityName); // Now set it to nextId GenericValue sequenceItem = EntityUtil.getOnly(delegator.findByAnd("SequenceValueItem", ImmutableMap.of("seqName", entityName))); if (sequenceItem != null) { sequenceItem.set("seqId", nextId); sequenceItem.store(); delegator.refreshSequencer(); } } @Nullable
/** Finds Generic Entity records by all of the specified fields (ie: combined using AND), looking first in the cache; uses orderBy for lookup, but only keys results on the entityName and fields *@param entityName The Name of the Entity as defined in the entity XML file *@param fields The fields of the named entity to query by with their corresponging values *@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending *@return List of GenericValue instances that match the query */ public List findByAndCache(String entityName, Map fields, List orderBy) throws GenericEntityException { ModelEntity modelEntity = getModelReader().getModelEntity(entityName); GenericValue dummyValue = new GenericValue(modelEntity); Map ecaEventMap = this.getEcaEntityEventMap(modelEntity.getEntityName()); this.evalEcaRules(EntityEcaHandler.EV_CACHE_CHECK, EntityEcaHandler.OP_FIND, dummyValue, null, false, false); List lst = this.getFromAndCache(modelEntity, fields); if (lst == null) { lst = findByAnd(modelEntity, fields, orderBy); if (lst != null) { this.evalEcaRules(EntityEcaHandler.EV_CACHE_PUT, EntityEcaHandler.OP_FIND, dummyValue, null, false, false); this.putInAndCache(modelEntity, fields, lst); } } return lst; }
/** Finds Generic Entity records by all of the specified fields (ie: combined using AND), looking first in the cache; uses orderBy for lookup, but only keys results on the entityName and fields *@param entityName The Name of the Entity as defined in the entity XML file *@param fields The fields of the named entity to query by with their corresponging values *@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending *@return List of GenericValue instances that match the query */ public List findByAndCache(String entityName, Map fields, List orderBy) throws GenericEntityException { ModelEntity modelEntity = getModelReader().getModelEntity(entityName); GenericValue dummyValue = new GenericValue(modelEntity); Map ecaEventMap = this.getEcaEntityEventMap(modelEntity.getEntityName()); this.evalEcaRules(EntityEcaHandler.EV_CACHE_CHECK, EntityEcaHandler.OP_FIND, dummyValue, null, false, false); List lst = this.getFromAndCache(modelEntity, fields); if (lst == null) { lst = findByAnd(modelEntity, fields, orderBy); if (lst != null) { this.evalEcaRules(EntityEcaHandler.EV_CACHE_PUT, EntityEcaHandler.OP_FIND, dummyValue, null, false, false); this.putInAndCache(modelEntity, fields, lst); } } return lst; }