private void absorbList(final List<GenericValue> lst) { if (lst == null) { return; } for (GenericValue aLst : lst) { aLst.setDelegator(this); } }
protected void absorbList(List lst) { if (lst == null) return; Iterator iter = lst.iterator(); while (iter.hasNext()) { GenericValue value = (GenericValue) iter.next(); value.setDelegator(this); } }
protected void absorbList(List lst) { if (lst == null) return; Iterator iter = lst.iterator(); while (iter.hasNext()) { GenericValue value = (GenericValue) iter.next(); value.setDelegator(this); } }
/** Clones this GenericValue, this is a shallow clone & uses the default shallow HashMap clone *@return Object that is a clone of this GenericValue */ public Object clone() { GenericValue newEntity = new GenericValue(this); newEntity.setDelegator(internalDelegator); return newEntity; } }
/** * Clones this GenericValue, this is a shallow clone & uses the default shallow HashMap clone * * @return Object that is a clone of this GenericValue */ public Object clone() { GenericValue newEntity = new GenericValue(this); newEntity.setDelegator(internalDelegator); return newEntity; } }
/** Clones this GenericValue, this is a shallow clone & uses the default shallow HashMap clone *@return Object that is a clone of this GenericValue */ public Object clone() { GenericValue newEntity = new GenericValue(this); newEntity.setDelegator(internalDelegator); return newEntity; } }
/** Creates a Entity in the form of a GenericValue without persisting it */ public GenericValue makeValue(String entityName, Map fields) { ModelEntity entity = this.getModelEntity(entityName); if (entity == null) { throw new IllegalArgumentException("[GenericDelegator.makeValue] could not find entity for entityName: " + entityName); } GenericValue value = new GenericValue(entity, fields); value.setDelegator(this); return value; }
/** Creates a Entity in the form of a GenericValue without persisting it */ public GenericValue makeValue(String entityName, Map fields) { ModelEntity entity = this.getModelEntity(entityName); if (entity == null) { throw new IllegalArgumentException("[GenericDelegator.makeValue] could not find entity for entityName: " + entityName); } GenericValue value = new GenericValue(entity, fields); value.setDelegator(this); return value; }
public ImmutableGenericValue(GenericDelegator delegator, String entityName, Map fields) { super(delegator.getModelEntity(entityName)); super.setDelegator(delegator); super.setFields(fields); constructed = true; }
/** NOTE: Calling this method does return the current value, but so does calling next() or previous(), so calling one of those AND this method will cause the value to be created twice */ public GenericValue currentGenericValue() throws GenericEntityException { if (closed) throw new GenericResultSetClosedException("This EntityListIterator has been closed, this operation cannot be performed"); GenericValue value = new GenericValue(modelEntity); for (int j = 0; j < selectFields.size(); j++) { ModelField curField = (ModelField) selectFields.get(j); SqlJdbcUtil.getValue(resultSet, j + 1, curField, value, modelFieldTypeReader); } value.modified = false; value.copyOriginalDbValues(); value.setDelegator(this.delegator); this.haveMadeValue = true; return value; }
/** NOTE: Calling this method does return the current value, but so does calling next() or previous(), so calling one of those AND this method will cause the value to be created twice */ public GenericValue currentGenericValue() throws GenericEntityException { if (closed) throw new GenericResultSetClosedException("This EntityListIterator has been closed, this operation cannot be performed"); GenericValue value = new GenericValue(modelEntity); for (int j = 0; j < selectFields.size(); j++) { ModelField curField = (ModelField) selectFields.get(j); SqlJdbcUtil.getValue(resultSet, j + 1, curField, value, modelFieldTypeReader); } value.modified = false; value.copyOriginalDbValues(); value.setDelegator(this.delegator); this.haveMadeValue = true; return value; }
/** Refresh the Entity for the GenericValue from the persistent store *@param value GenericValue instance containing the entity to refresh *@param doCacheClear boolean that specifies whether or not to automatically clear cache entries related to this operation */ public void refresh(GenericValue value, boolean doCacheClear) throws GenericEntityException { if (doCacheClear) { // always clear cache before the operation clearCacheLine(value); } GenericPK pk = value.getPrimaryKey(); GenericValue newValue = findByPrimaryKey(pk); if (newValue == null) { throw new IllegalArgumentException("[GenericDelegator.refresh] could not refresh value: " + value); } value.fields = newValue.fields; value.setDelegator(this); value.modified = false; }
/** Refresh the Entity for the GenericValue from the persistent store *@param value GenericValue instance containing the entity to refresh *@param doCacheClear boolean that specifies whether or not to automatically clear cache entries related to this operation */ public void refresh(GenericValue value, boolean doCacheClear) throws GenericEntityException { if (doCacheClear) { // always clear cache before the operation clearCacheLine(value); } GenericPK pk = value.getPrimaryKey(); GenericValue newValue = findByPrimaryKey(pk); if (newValue == null) { throw new IllegalArgumentException("[GenericDelegator.refresh] could not refresh value: " + value); } value.fields = newValue.fields; value.setDelegator(this); value.modified = false; }
/** * NOTE: Calling this method does return the current value, but so does calling next() or previous(), so calling one of those AND this method will cause the value to be created twice */ public GenericValue currentGenericValue() throws GenericEntityException { if (closed) throw new GenericResultSetClosedException("This EntityListIterator has been closed, this operation cannot be performed"); GenericValue value = new GenericValue(modelEntity); for (int j = 0; j < selectFields.size(); j++) { ModelField curField = selectFields.get(j); SqlJdbcUtil.getValue(resultSet, j + 1, curField, value, modelFieldTypeReader); } value.modified = false; value.copyOriginalDbValues(); value.setDelegator(this.delegator); this.haveMadeValue = true; return value; }
/** * Refresh the Entity for the GenericValue from the persistent store. * * @param value GenericValue instance containing the entity to refresh * @param doCacheClear whether to automatically clear cache entries related to this operation */ public void refresh(final GenericValue value, final boolean doCacheClear) throws GenericEntityException { checkIfLocked(); if (doCacheClear) { // always clear cache before the operation clearCacheLine(value); } GenericPK pk = value.getPrimaryKey(); GenericValue newValue = findByPrimaryKey(pk); if (newValue == null) { throw new IllegalArgumentException("[GenericDelegator.refresh] could not refresh value: " + value); } value.fields = newValue.fields; value.setDelegator(this); value.modified = false; }
/** * Creates a Entity in the form of a GenericValue and write it to the datasource. * * @param value The GenericValue from which to create a value in the datasource (required) * @param doCacheClear whether to automatically clear cache entries related to this operation * @return GenericValue instance containing the new instance */ public GenericValue create(GenericValue value, final boolean doCacheClear) throws GenericEntityException { checkIfLocked(); final GenericHelper helper = getEntityHelper(value.getEntityName()); value.setDelegator(this); value = helper.create(value); if (value != null) { value.setDelegator(this); if (value.lockEnabled()) { refresh(value, doCacheClear); } else if (doCacheClear) { clearCacheLine(value); } } return value; }
@Override public List<GenericValue> transform(final String entityName, final EntityCondition entityCondition, final List<String> orderBy, final String lockField, final Transformation transformation) throws GenericEntityException { checkIfLocked(); final ModelEntity modelEntity = getModelReader().getModelEntity(entityName); final GenericHelper entityHelper = getEntityHelper(entityName); final List<GenericValue> transformedEntities = entityHelper.transform(modelEntity, entityCondition, orderBy, lockField, transformation); for (final GenericValue genericValue : transformedEntities) { genericValue.setDelegator(this); } return transformedEntities; }
/** Find a Generic Entity by its Primary Key *@param primaryKey The primary key to find by. *@return The GenericValue corresponding to the primaryKey */ public GenericValue findByPrimaryKey(GenericPK primaryKey) throws GenericEntityException { Map ecaEventMap = this.getEcaEntityEventMap(primaryKey.getEntityName()); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_FIND, primaryKey, ecaEventMap, (ecaEventMap == null), false); GenericHelper helper = getEntityHelper(primaryKey.getEntityName()); GenericValue value = null; if (!primaryKey.isPrimaryKey()) { throw new IllegalArgumentException("[GenericDelegator.findByPrimaryKey] Passed primary key is not a valid primary key: " + primaryKey); } this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_FIND, primaryKey, ecaEventMap, (ecaEventMap == null), false); try { value = helper.findByPrimaryKey(primaryKey); } catch (GenericEntityNotFoundException e) { value = null; } if (value != null) value.setDelegator(this); this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_FIND, primaryKey, ecaEventMap, (ecaEventMap == null), false); return value; }
/** Find a Generic Entity by its Primary Key *@param primaryKey The primary key to find by. *@return The GenericValue corresponding to the primaryKey */ public GenericValue findByPrimaryKey(GenericPK primaryKey) throws GenericEntityException { Map ecaEventMap = this.getEcaEntityEventMap(primaryKey.getEntityName()); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_FIND, primaryKey, ecaEventMap, (ecaEventMap == null), false); GenericHelper helper = getEntityHelper(primaryKey.getEntityName()); GenericValue value = null; if (!primaryKey.isPrimaryKey()) { throw new IllegalArgumentException("[GenericDelegator.findByPrimaryKey] Passed primary key is not a valid primary key: " + primaryKey); } this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_FIND, primaryKey, ecaEventMap, (ecaEventMap == null), false); try { value = helper.findByPrimaryKey(primaryKey); } catch (GenericEntityNotFoundException e) { value = null; } if (value != null) value.setDelegator(this); this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_FIND, primaryKey, ecaEventMap, (ecaEventMap == null), false); return value; }
/** Find a Generic Entity by its Primary Key and only returns the values requested by the passed keys (names) *@param primaryKey The primary key to find by. *@param keys The keys, or names, of the values to retrieve; only these values will be retrieved *@return The GenericValue corresponding to the primaryKey */ public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set keys) throws GenericEntityException { Map ecaEventMap = this.getEcaEntityEventMap(primaryKey.getEntityName()); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_FIND, primaryKey, ecaEventMap, (ecaEventMap == null), false); GenericHelper helper = getEntityHelper(primaryKey.getEntityName()); GenericValue value = null; if (!primaryKey.isPrimaryKey()) { throw new IllegalArgumentException("[GenericDelegator.findByPrimaryKey] Passed primary key is not a valid primary key: " + primaryKey); } this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_FIND, primaryKey, ecaEventMap, (ecaEventMap == null), false); try { value = helper.findByPrimaryKeyPartial(primaryKey, keys); } catch (GenericEntityNotFoundException e) { value = null; } if (value != null) value.setDelegator(this); this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_FIND, primaryKey, ecaEventMap, (ecaEventMap == null), false); return value; }