/** * Clones this GenericPK, this is a shallow clone & uses the default shallow HashMap clone * * @return Object that is a clone of this GenericPK */ public Object clone() { GenericPK newEntity = new GenericPK(this); newEntity.setDelegator(internalDelegator); return newEntity; } }
public List getFromAndCache(ModelEntity entity, Map fields) { if (entity == null || fields == null) return null; GenericPK tempPK = new GenericPK(entity, fields); if (tempPK == null) return null; return (List) andCache.get(tempPK); }
public List getFromAndCache(ModelEntity entity, Map fields) { if (entity == null || fields == null) return null; GenericPK tempPK = new GenericPK(entity, fields); if (tempPK == null) return null; return (List) andCache.get(tempPK); }
/** Clones this GenericPK, this is a shallow clone & uses the default shallow HashMap clone *@return Object that is a clone of this GenericPK */ public Object clone() { GenericPK newEntity = new GenericPK(this); newEntity.setDelegator(internalDelegator); return newEntity; } }
/** Clones this GenericPK, this is a shallow clone & uses the default shallow HashMap clone *@return Object that is a clone of this GenericPK */ public Object clone() { GenericPK newEntity = new GenericPK(this); newEntity.setDelegator(internalDelegator); return newEntity; } }
@Override public GenericPK getPrimaryKey() { return new GenericPK(getModelEntity(), UtilMisc.toMap("id", fields.get("id"))); }
/** Creates a Primary Key in the form of a GenericPK without persisting it */ public GenericPK makePK(String entityName, Map fields) { ModelEntity entity = this.getModelEntity(entityName); if (entity == null) { throw new IllegalArgumentException("[GenericDelegator.makePK] could not find entity for entityName: " + entityName); } GenericPK pk = new GenericPK(entity, fields); pk.setDelegator(this); return pk; }
/** Creates a Primary Key in the form of a GenericPK without persisting it */ public GenericPK makePK(String entityName, Map fields) { ModelEntity entity = this.getModelEntity(entityName); if (entity == null) { throw new IllegalArgumentException("[GenericDelegator.makePK] could not find entity for entityName: " + entityName); } GenericPK pk = new GenericPK(entity, fields); pk.setDelegator(this); return pk; }
public List<GenericValue> getFromAndCache(final ModelEntity entity, final Map<String, ?> fields) { checkIfLocked(); if (entity == null || fields == null) { return null; } final GenericPK tempPK = new GenericPK(entity, fields); return andCache.get(tempPK); }
public GenericPK getPrimaryKey() { Collection<String> pkNames = new LinkedList<String>(); Iterator<ModelField> iter = this.getModelEntity().getPksIterator(); while (iter != null && iter.hasNext()) { ModelField curField = iter.next(); pkNames.add(curField.getName()); } return new GenericPK(getModelEntity(), this.getFields(pkNames)); }
public GenericPK getPrimaryKey() { Collection pkNames = new LinkedList(); Iterator iter = this.getModelEntity().getPksIterator(); while (iter != null && iter.hasNext()) { ModelField curField = (ModelField) iter.next(); pkNames.add(curField.getName()); } return new GenericPK(getModelEntity(), this.getFields(pkNames)); }
public GenericPK getPrimaryKey() { Collection pkNames = new LinkedList(); Iterator iter = this.getModelEntity().getPksIterator(); while (iter != null && iter.hasNext()) { ModelField curField = (ModelField) iter.next(); pkNames.add(curField.getName()); } return new GenericPK(getModelEntity(), this.getFields(pkNames)); }
public int removeAll(List dummyPKs) throws GenericEntityException { int count = 0; for (Iterator iterator = dummyPKs.iterator(); iterator.hasNext();) { GenericEntity ge = (GenericEntity) iterator.next(); if (ge instanceof GenericPK) { count = count + removeFromCache((GenericPK) ge); } else { Map pkFields = new HashMap(); List pkFieldNames = ge.getModelEntity().getPkFieldNames(); for (int i = 0; i < pkFieldNames.size(); i++) { String fieldName = (String) pkFieldNames.get(i); pkFields.put(fieldName, ge.get(fieldName)); } GenericPK pk = new GenericPK(ge.getModelEntity(), pkFields); count = count + removeFromCache(pk); } } return count; }
public int removeAll(List dummyPKs) throws GenericEntityException { int count = 0; for (Iterator iterator = dummyPKs.iterator(); iterator.hasNext();) { GenericEntity ge = (GenericEntity) iterator.next(); if (ge instanceof GenericPK) { count = count + removeFromCache((GenericPK) ge); } else { Map pkFields = new HashMap(); List pkFieldNames = ge.getModelEntity().getPkFieldNames(); for (int i = 0; i < pkFieldNames.size(); i++) { String fieldName = (String) pkFieldNames.get(i); pkFields.put(fieldName, ge.get(fieldName)); } GenericPK pk = new GenericPK(ge.getModelEntity(), pkFields); count = count + removeFromCache(pk); } } return count; }
/** * Creates a Primary Key in the form of a GenericPK without persisting it. * * @param entityName the type of entity for which to create a PK (must exist in the model) * @param fields the primary key fields and their values (can be null) * @return the created PK */ public GenericPK makePK(final String entityName, final Map<String, ?> fields) { checkIfLocked(); ModelEntity entity = getModelEntity(entityName); if (entity == null) { throw new IllegalArgumentException( "[GenericDelegator.makePK] could not find entity for entityName: " + entityName); } final GenericPK pk = new GenericPK(entity, fields); pk.setDelegator(this); return pk; }
/** Remove a CACHED Generic Entity (List) from the cache, either a PK, ByAnd, or All *@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 */ public void clearCacheLine(String entityName, Map fields) { // if no fields passed, do the all cache quickly and return if (fields == null && allCache != null) { allCache.remove(entityName); return; } ModelEntity entity = this.getModelEntity(entityName); if (entity == null) { throw new IllegalArgumentException("[GenericDelegator.clearCacheLine] could not find entity for entityName: " + entityName); } //if never cached, then don't bother clearing if (entity.getNeverCache()) return; GenericPK dummyPK = new GenericPK(entity, fields); this.clearCacheLineFlexible(dummyPK); }
/** Remove a CACHED Generic Entity (List) from the cache, either a PK, ByAnd, or All *@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 */ public void clearCacheLine(String entityName, Map fields) { // if no fields passed, do the all cache quickly and return if (fields == null && allCache != null) { allCache.remove(entityName); return; } ModelEntity entity = this.getModelEntity(entityName); if (entity == null) { throw new IllegalArgumentException("[GenericDelegator.clearCacheLine] could not find entity for entityName: " + entityName); } //if never cached, then don't bother clearing if (entity.getNeverCache()) return; GenericPK dummyPK = new GenericPK(entity, fields); this.clearCacheLineFlexible(dummyPK); }
public int removeAll(List<? extends GenericEntity> dummyPKs) throws GenericEntityException { int count = 0; for (GenericEntity ge : dummyPKs) { if (ge instanceof GenericPK) { count = count + removeFromCache((GenericPK) ge); } else { Map<String, Object> pkFields = new HashMap<String, Object>(); List<String> pkFieldNames = ge.getModelEntity().getPkFieldNames(); for (String pkFieldName : pkFieldNames) { pkFields.put(pkFieldName, ge.get(pkFieldName)); } GenericPK pk = new GenericPK(ge.getModelEntity(), pkFields); count = count + removeFromCache(pk); } } return count; }
/** * Remove a CACHED Generic Entity (List) from the cache, either a PK, ByAnd, or All * * @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 */ public void clearCacheLine(String entityName, Map<String, ?> fields) { checkIfLocked(); // if no fields passed, do the all cache quickly and return if (fields == null && allCache != null) { allCache.remove(entityName); return; } ModelEntity entity = getModelEntity(entityName); if (entity == null) { throw new IllegalArgumentException( "[GenericDelegator.clearCacheLine] could not find entity for entityName: " + entityName); } //if never cached, then don't bother clearing if (entity.getNeverCache()) return; GenericPK dummyPK = new GenericPK(entity, fields); clearCacheLineFlexible(dummyPK); }
/** Get a dummy primary key for the named Related Entity for the GenericValue * @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 value GenericValue instance containing the entity * @return GenericPK containing a possibly incomplete PrimaryKey object representing the related entity or entities */ public GenericPK getRelatedDummyPK(String relationName, Map byAndFields, 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); } ModelEntity relatedEntity = getModelReader().getModelEntity(relation.getRelEntityName()); // 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())); } GenericPK dummyPK = new GenericPK(relatedEntity, fields); dummyPK.setDelegator(this); return dummyPK; }