/** Remove a CACHED Generic Entity from the cache by its primary key, does NOT * check to see if the passed GenericPK is a complete primary key. * Also tries to clear the corresponding all cache entry. *@param primaryKey The primary key to clear by. */ public void clearCacheLine(GenericPK primaryKey) { this.clearCacheLine(primaryKey, true); }
/** Remove a CACHED Generic Entity from the cache by its primary key, does NOT * check to see if the passed GenericPK is a complete primary key. * Also tries to clear the corresponding all cache entry. *@param primaryKey The primary key to clear by. */ public void clearCacheLine(GenericPK primaryKey) { this.clearCacheLine(primaryKey, true); }
public void clearAllCacheLinesByValue(Collection values) { if (values == null) return; Iterator iter = values.iterator(); while (iter.hasNext()) { GenericValue value = (GenericValue) iter.next(); this.clearCacheLine(value); } }
public void clearAllCacheLinesByValue(Collection values) { if (values == null) return; Iterator iter = values.iterator(); while (iter.hasNext()) { GenericValue value = (GenericValue) iter.next(); this.clearCacheLine(value); } }
public void clearAllCacheLinesByValue(final Collection<? extends GenericValue> values) { checkIfLocked(); if (values == null) return; for (final GenericValue value : values) { clearCacheLine(value); } }
/** * Remove a CACHED Generic Entity from the cache by its primary key, does NOT * check to see if the passed GenericPK is a complete primary key. * Also tries to clear the corresponding all cache entry. * * @param primaryKey The primary key to clear by. */ public void clearCacheLine(final GenericPK primaryKey) { checkIfLocked(); clearCacheLine(primaryKey, true); }
/** * Remove a CACHED GenericValue from as many caches as it can. * Automatically tries to remove entries from the all cache, the by primary * key cache, and the "by and" cache. This is the ONLY method that tries to * clear automatically from the by and cache. * * @param value The primary key to clear by. */ public void clearCacheLine(final GenericValue value) { checkIfLocked(); clearCacheLine(value, true); }
/** 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; }
/** * 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; }
/** * Remove a Generic Entity corresponding to the primaryKey. * * @param primaryKey The primary key of the entity to remove. * @param doCacheClear boolean that specifies whether to clear cache entries for this primaryKey to be removed * @return int representing number of rows affected by this operation */ public int removeByPrimaryKey(final GenericPK primaryKey, final boolean doCacheClear) throws GenericEntityException { checkIfLocked(); if (doCacheClear) { // always clear cache before the operation clearCacheLine(primaryKey); } final GenericHelper helper = getEntityHelper(primaryKey.getEntityName()); return helper.removeByPrimaryKey(primaryKey); }
/** * Remove a Generic Value from the database. * * @param value The GenericValue object of the entity to remove. * @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 removeValue(final GenericValue value, final boolean doCacheClear) throws GenericEntityException { checkIfLocked(); final GenericHelper helper = getEntityHelper(value.getEntityName()); if (doCacheClear) { clearCacheLine(value); } return helper.removeByPrimaryKey(value.getPrimaryKey()); }
/** * Store the Entity from the GenericValue to the persistent store. * * @param value GenericValue instance containing the entity * @param doCacheClear whether to automatically clear cache entries related to this operation * @return int representing number of rows affected by this operation */ public int store(final GenericValue value, final boolean doCacheClear) throws GenericEntityException { checkIfLocked(); final GenericHelper helper = getEntityHelper(value.getEntityName()); if (doCacheClear) { // always clear cache before the operation clearCacheLine(value); } final int retVal = helper.store(value); // refresh the valueObject to get the new version if (value.lockEnabled()) { refresh(value, doCacheClear); } return retVal; }
/** * 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; }
/** Remove a Generic Entity corresponding to the primaryKey *@param primaryKey The primary key of the entity to remove. *@param doCacheClear boolean that specifies whether to clear cache entries for this primaryKey to be removed *@return int representing number of rows effected by this operation */ public int removeByPrimaryKey(GenericPK primaryKey, boolean doCacheClear) throws GenericEntityException { Map ecaEventMap = this.getEcaEntityEventMap(primaryKey.getEntityName()); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_REMOVE, primaryKey, ecaEventMap, (ecaEventMap == null), false); GenericHelper helper = getEntityHelper(primaryKey.getEntityName()); if (doCacheClear) { // always clear cache before the operation this.evalEcaRules(EntityEcaHandler.EV_CACHE_CLEAR, EntityEcaHandler.OP_REMOVE, primaryKey, ecaEventMap, (ecaEventMap == null), false); this.clearCacheLine(primaryKey); } this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_REMOVE, primaryKey, ecaEventMap, (ecaEventMap == null), false); int num = helper.removeByPrimaryKey(primaryKey); this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_REMOVE, primaryKey, ecaEventMap, (ecaEventMap == null), false); return num; }
/** Remove a Generic Entity corresponding to the primaryKey *@param primaryKey The primary key of the entity to remove. *@param doCacheClear boolean that specifies whether to clear cache entries for this primaryKey to be removed *@return int representing number of rows effected by this operation */ public int removeByPrimaryKey(GenericPK primaryKey, boolean doCacheClear) throws GenericEntityException { Map ecaEventMap = this.getEcaEntityEventMap(primaryKey.getEntityName()); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_REMOVE, primaryKey, ecaEventMap, (ecaEventMap == null), false); GenericHelper helper = getEntityHelper(primaryKey.getEntityName()); if (doCacheClear) { // always clear cache before the operation this.evalEcaRules(EntityEcaHandler.EV_CACHE_CLEAR, EntityEcaHandler.OP_REMOVE, primaryKey, ecaEventMap, (ecaEventMap == null), false); this.clearCacheLine(primaryKey); } this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_REMOVE, primaryKey, ecaEventMap, (ecaEventMap == null), false); int num = helper.removeByPrimaryKey(primaryKey); this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_REMOVE, primaryKey, ecaEventMap, (ecaEventMap == null), false); return num; }
/** Remove a Generic Value from the database *@param value The GenericValue object of the entity to remove. *@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 removeValue(GenericValue value, boolean doCacheClear) throws GenericEntityException { Map ecaEventMap = this.getEcaEntityEventMap(value.getEntityName()); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_REMOVE, value, ecaEventMap, (ecaEventMap == null), false); GenericHelper helper = getEntityHelper(value.getEntityName()); if (doCacheClear) { this.evalEcaRules(EntityEcaHandler.EV_CACHE_CLEAR, EntityEcaHandler.OP_REMOVE, value, ecaEventMap, (ecaEventMap == null), false); this.clearCacheLine(value); } this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_REMOVE, value, ecaEventMap, (ecaEventMap == null), false); int num = helper.removeByPrimaryKey(value.getPrimaryKey()); this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_REMOVE, value, ecaEventMap, (ecaEventMap == null), false); return num; }
/** Remove a Generic Value from the database *@param value The GenericValue object of the entity to remove. *@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 removeValue(GenericValue value, boolean doCacheClear) throws GenericEntityException { Map ecaEventMap = this.getEcaEntityEventMap(value.getEntityName()); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_REMOVE, value, ecaEventMap, (ecaEventMap == null), false); GenericHelper helper = getEntityHelper(value.getEntityName()); if (doCacheClear) { this.evalEcaRules(EntityEcaHandler.EV_CACHE_CLEAR, EntityEcaHandler.OP_REMOVE, value, ecaEventMap, (ecaEventMap == null), false); this.clearCacheLine(value); } this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_REMOVE, value, ecaEventMap, (ecaEventMap == null), false); int num = helper.removeByPrimaryKey(value.getPrimaryKey()); this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_REMOVE, value, 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; }
/** Store the Entity from the GenericValue to the persistent store *@param value GenericValue instance containing the entity *@param doCacheClear boolean that specifies whether or not to automatically clear cache entries related to this operation *@return int representing number of rows effected by this operation */ public int store(GenericValue value, boolean doCacheClear) throws GenericEntityException { Map ecaEventMap = this.getEcaEntityEventMap(value.getEntityName()); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_STORE, value, ecaEventMap, (ecaEventMap == null), false); GenericHelper helper = getEntityHelper(value.getEntityName()); if (doCacheClear) { // always clear cache before the operation this.evalEcaRules(EntityEcaHandler.EV_CACHE_CLEAR, EntityEcaHandler.OP_STORE, value, ecaEventMap, (ecaEventMap == null), false); this.clearCacheLine(value); } this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_STORE, value, ecaEventMap, (ecaEventMap == null), false); int retVal = helper.store(value); // refresh the valueObject to get the new version if (value.lockEnabled()) { refresh(value, doCacheClear); } this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_STORE, value, ecaEventMap, (ecaEventMap == null), false); return retVal; }