public GenericPK makePK(Element element) { GenericValue value = makeValue(element); return value.getPrimaryKey(); }
public GenericPK makePK(Element element) { GenericValue value = makeValue(element); return value.getPrimaryKey(); }
public List makeValues(Document document) { if (document == null) return null; List values = new LinkedList(); Element docElement = document.getDocumentElement(); if (docElement == null) return null; if (!"entity-engine-xml".equals(docElement.getTagName())) { Debug.logError("[GenericDelegator.makeValues] Root node was not <entity-engine-xml>", module); throw new java.lang.IllegalArgumentException("Root node was not <entity-engine-xml>"); } docElement.normalize(); Node curChild = docElement.getFirstChild(); if (curChild != null) { do { if (curChild.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) curChild; GenericValue value = this.makeValue(element); if (value != null) values.add(value); } } while ((curChild = curChild.getNextSibling()) != null); } else { Debug.logWarning("[GenericDelegator.makeValues] No child nodes found in document.", module); } return values; }
public List makeValues(Document document) { if (document == null) return null; List values = new LinkedList(); Element docElement = document.getDocumentElement(); if (docElement == null) return null; if (!"entity-engine-xml".equals(docElement.getTagName())) { Debug.logError("[GenericDelegator.makeValues] Root node was not <entity-engine-xml>", module); throw new java.lang.IllegalArgumentException("Root node was not <entity-engine-xml>"); } docElement.normalize(); Node curChild = docElement.getFirstChild(); if (curChild != null) { do { if (curChild.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) curChild; GenericValue value = this.makeValue(element); if (value != null) values.add(value); } } while ((curChild = curChild.getNextSibling()) != null); } else { Debug.logWarning("[GenericDelegator.makeValues] No child nodes found in document.", module); } return values; }
@SuppressWarnings("unused") public GenericPK makePK(final Element element) { checkIfLocked(); GenericValue value = makeValue(element); return value.getPrimaryKey(); }
currentValue = delegator.makeValue(entityName, null); } catch (Exception e) {}
currentValue = delegator.makeValue(entityName, null); } catch (Exception e) {}
if (curChild.getNodeType() == Node.ELEMENT_NODE) { final Element element = (Element) curChild; final GenericValue value = makeValue(element); if (value != null) { values.add(value);
/** * Create a new entity. * * If there is no "id" in the parameter list, one is created using the entity sequence * * @deprecated Use {@link com.atlassian.jira.entity.EntityUtils#createValue(String, java.util.Map)} instead. Since v5.1. */ public static GenericValue createValue(final String entity, final Map<String, ?> paramMap) throws GenericEntityException { final Map<String, Object> params = (paramMap == null) ? new HashMap<String, Object>() : new HashMap<String, Object>(paramMap); if (params.get("id") == null) { final Long id = CoreFactory.getGenericDelegator().getNextSeqId(entity); params.put("id", id); } final GenericValue v = CoreFactory.getGenericDelegator().makeValue(entity, params); v.create(); return v; }
currentValue = delegator.makeValue(entityName, null); } catch (Exception e) {
public GenericValue makeValue(Element element) { if (element == null) return null; String entityName = element.getTagName(); // if a dash or colon is in the tag name, grab what is after it if (entityName.indexOf('-') > 0) entityName = entityName.substring(entityName.indexOf('-') + 1); if (entityName.indexOf(':') > 0) entityName = entityName.substring(entityName.indexOf(':') + 1); GenericValue value = this.makeValue(entityName, null); ModelEntity modelEntity = value.getModelEntity(); Iterator modelFields = modelEntity.getFieldsIterator(); while (modelFields.hasNext()) { ModelField modelField = (ModelField) modelFields.next(); String name = modelField.getName(); String attr = element.getAttribute(name); if (attr != null && attr.length() > 0) { value.setString(name, attr); } else { // if no attribute try a subelement Element subElement = UtilXml.firstChildElement(element, name); if (subElement != null) { value.setString(name, UtilXml.elementValue(subElement)); } } } return value; }
public SearchRequest get(final GenericValue sharedEntityGV) { final GenericDelegator genericDelegator = sharedEntityGV.getDelegator(); return convertGVToRequest(genericDelegator.makeValue(Table.NAME, filter(sharedEntityGV.getAllFields()))); }
public GenericValue makeValue(Element element) { if (element == null) return null; String entityName = element.getTagName(); // if a dash or colon is in the tag name, grab what is after it if (entityName.indexOf('-') > 0) entityName = entityName.substring(entityName.indexOf('-') + 1); if (entityName.indexOf(':') > 0) entityName = entityName.substring(entityName.indexOf(':') + 1); GenericValue value = this.makeValue(entityName, null); ModelEntity modelEntity = value.getModelEntity(); Iterator modelFields = modelEntity.getFieldsIterator(); while (modelFields.hasNext()) { ModelField modelField = (ModelField) modelFields.next(); String name = modelField.getName(); String attr = element.getAttribute(name); if (attr != null && attr.length() > 0) { value.setString(name, attr); } else { // if no attribute try a subelement Element subElement = UtilXml.firstChildElement(element, name); if (subElement != null) { value.setString(name, UtilXml.elementValue(subElement)); } } } return value; }
public static GenericValue getTestConstant(final String entity, Map params) { try { if (params == null) { params = new HashMap(); } if (params.get("id") == null) { final String id = EntityUtils.getNextStringId(entity); params.put("id", id); } GenericValue v = CoreFactory.getGenericDelegator().makeValue(entity, params); v = v.create(); return v; } catch (final GenericEntityException e) { throw new EntityException(e); } }
public GenericValue makeValue(final Element element) { checkIfLocked(); if (element == null) { return null; } final String entityName = getEntityName(element); final GenericValue value = makeValue(entityName, null); final ModelEntity modelEntity = value.getModelEntity(); final Iterator<ModelField> modelFields = modelEntity.getFieldsIterator(); while (modelFields.hasNext()) { final ModelField modelField = modelFields.next(); final String name = modelField.getName(); final String attr = element.getAttribute(name); if (attr != null && attr.length() > 0) { value.setString(name, attr); } else { // if no attribute try a subelement final Element subElement = UtilXml.firstChildElement(element, name); if (subElement != null) { value.setString(name, UtilXml.elementValue(subElement)); } } } return value; }
/** Finds all Generic entities, 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 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 findAllCache(String entityName, List orderBy) throws GenericEntityException { GenericValue dummyValue = makeValue(entityName, null); Map ecaEventMap = this.getEcaEntityEventMap(entityName); this.evalEcaRules(EntityEcaHandler.EV_CACHE_CHECK, EntityEcaHandler.OP_FIND, dummyValue, ecaEventMap, (ecaEventMap == null), false); List lst = this.getFromAllCache(entityName); if (lst == null) { lst = findAll(entityName, orderBy); if (lst != null) { this.evalEcaRules(EntityEcaHandler.EV_CACHE_PUT, EntityEcaHandler.OP_FIND, dummyValue, ecaEventMap, (ecaEventMap == null), false); this.putInAllCache(entityName, lst); } } return lst; }
/** Finds all Generic entities, 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 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 findAllCache(String entityName, List orderBy) throws GenericEntityException { GenericValue dummyValue = makeValue(entityName, null); Map ecaEventMap = this.getEcaEntityEventMap(entityName); this.evalEcaRules(EntityEcaHandler.EV_CACHE_CHECK, EntityEcaHandler.OP_FIND, dummyValue, ecaEventMap, (ecaEventMap == null), false); List lst = this.getFromAllCache(entityName); if (lst == null) { lst = findAll(entityName, orderBy); if (lst != null) { this.evalEcaRules(EntityEcaHandler.EV_CACHE_PUT, EntityEcaHandler.OP_FIND, dummyValue, ecaEventMap, (ecaEventMap == null), false); this.putInAllCache(entityName, lst); } } return lst; }
/** * Removes/deletes Generic Entity records found 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 doCacheClear boolean that specifies whether to clear cache entries for this value to be removed * @return int representing number of rows affected by this operation */ public int removeByAnd(final String entityName, final Map<String, ?> fields, final boolean doCacheClear) throws GenericEntityException { checkIfLocked(); final GenericValue dummyValue = makeValue(entityName, fields); final ModelEntity modelEntity = getModelReader().getModelEntity(entityName); final GenericHelper helper = getEntityHelper(entityName); if (doCacheClear) { // always clear cache before the operation clearCacheLine(entityName, fields); } return helper.removeByAnd(modelEntity, dummyValue.getAllFields()); }
/** Removes/deletes Generic Entity records found 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 doCacheClear boolean that specifies whether to clear cache entries for this value to be removed *@return int representing number of rows effected by this operation */ public int removeByAnd(String entityName, Map fields, boolean doCacheClear) throws GenericEntityException { GenericValue dummyValue = makeValue(entityName, fields); Map ecaEventMap = this.getEcaEntityEventMap(entityName); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_REMOVE, dummyValue, ecaEventMap, (ecaEventMap == null), false); ModelEntity modelEntity = getModelReader().getModelEntity(entityName); GenericHelper helper = getEntityHelper(entityName); if (doCacheClear) { // always clear cache before the operation this.evalEcaRules(EntityEcaHandler.EV_CACHE_CLEAR, EntityEcaHandler.OP_REMOVE, dummyValue, ecaEventMap, (ecaEventMap == null), false); this.clearCacheLine(entityName, fields); } this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_REMOVE, dummyValue, ecaEventMap, (ecaEventMap == null), false); int num = helper.removeByAnd(modelEntity, dummyValue.getAllFields()); this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_REMOVE, dummyValue, ecaEventMap, (ecaEventMap == null), false); return num; }
/** Removes/deletes Generic Entity records found 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 doCacheClear boolean that specifies whether to clear cache entries for this value to be removed *@return int representing number of rows effected by this operation */ public int removeByAnd(String entityName, Map fields, boolean doCacheClear) throws GenericEntityException { GenericValue dummyValue = makeValue(entityName, fields); Map ecaEventMap = this.getEcaEntityEventMap(entityName); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_REMOVE, dummyValue, ecaEventMap, (ecaEventMap == null), false); ModelEntity modelEntity = getModelReader().getModelEntity(entityName); GenericHelper helper = getEntityHelper(entityName); if (doCacheClear) { // always clear cache before the operation this.evalEcaRules(EntityEcaHandler.EV_CACHE_CLEAR, EntityEcaHandler.OP_REMOVE, dummyValue, ecaEventMap, (ecaEventMap == null), false); this.clearCacheLine(entityName, fields); } this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_REMOVE, dummyValue, ecaEventMap, (ecaEventMap == null), false); int num = helper.removeByAnd(modelEntity, dummyValue.getAllFields()); this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_REMOVE, dummyValue, ecaEventMap, (ecaEventMap == null), false); return num; }