/** * Removes/deletes Generic Entity records found by matching the EntityCondition. * * @param entityName The Name of the Entity as defined in the entity XML file * @param whereCondition The EntityCondition object that specifies how to constrain this query * @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 removeByCondition( final String entityName, final EntityCondition whereCondition, final boolean doCacheClear) throws GenericEntityException { checkIfLocked(); ModelEntity modelEntity = getModelReader().getModelEntity(entityName); GenericHelper helper = getEntityHelper(entityName); if (doCacheClear) { // always clear cache before the operation Collection<GenericValue> toBeDeleted = helper.findByCondition(modelEntity, whereCondition, null, null); clearAllCacheLinesByValue(toBeDeleted); } return helper.removeByCondition(modelEntity, whereCondition); }
/** * Finds any GenericValues matching the given conditions. * * @param entityName The Name of the Entity as defined in the entity model XML file * @param entityCondition The EntityCondition object that specifies how to constrain this query * @param fieldsToSelect The fields of the named entity to get from the * database; if empty or null all fields will be retreived * @param orderBy The fields of the named entity by which to order the * query; optionally add " ASC" for ascending or " DESC" for descending * @return any matching values */ public List<GenericValue> findByCondition(final String entityName, final EntityCondition entityCondition, final Collection<String> fieldsToSelect, final List<String> orderBy) throws GenericEntityException { checkIfLocked(); final ModelEntity modelEntity = getModelReader().getModelEntity(entityName); if (entityCondition != null) { entityCondition.checkCondition(modelEntity); } final GenericHelper helper = getEntityHelper(entityName); final List<GenericValue> list = helper.findByCondition(modelEntity, entityCondition, fieldsToSelect, orderBy); absorbList(list); return list; }
/** Finds GenericValues by the conditions specified in the EntityCondition object, the the EntityCondition javadoc for more details. *@param entityName The Name of the Entity as defined in the entity model XML file *@param entityCondition The EntityCondition object that specifies how to constrain this query *@param fieldsToSelect The fields of the named entity to get from the database; if empty or null all fields will be retreived *@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 objects representing the result */ public List findByCondition(String entityName, EntityCondition entityCondition, Collection fieldsToSelect, List orderBy) throws GenericEntityException { ModelEntity modelEntity = getModelReader().getModelEntity(entityName); GenericValue dummyValue = new GenericValue(modelEntity); Map ecaEventMap = this.getEcaEntityEventMap(entityName); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_FIND, dummyValue, ecaEventMap, (ecaEventMap == null), false); if (entityCondition != null) entityCondition.checkCondition(modelEntity); this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_FIND, dummyValue, ecaEventMap, (ecaEventMap == null), false); GenericHelper helper = getEntityHelper(entityName); List list = null; list = helper.findByCondition(modelEntity, entityCondition, fieldsToSelect, orderBy); this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_FIND, dummyValue, ecaEventMap, (ecaEventMap == null), false); absorbList(list); return list; }
/** Finds GenericValues by the conditions specified in the EntityCondition object, the the EntityCondition javadoc for more details. *@param entityName The Name of the Entity as defined in the entity model XML file *@param entityCondition The EntityCondition object that specifies how to constrain this query *@param fieldsToSelect The fields of the named entity to get from the database; if empty or null all fields will be retreived *@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 objects representing the result */ public List findByCondition(String entityName, EntityCondition entityCondition, Collection fieldsToSelect, List orderBy) throws GenericEntityException { ModelEntity modelEntity = getModelReader().getModelEntity(entityName); GenericValue dummyValue = new GenericValue(modelEntity); Map ecaEventMap = this.getEcaEntityEventMap(entityName); this.evalEcaRules(EntityEcaHandler.EV_VALIDATE, EntityEcaHandler.OP_FIND, dummyValue, ecaEventMap, (ecaEventMap == null), false); if (entityCondition != null) entityCondition.checkCondition(modelEntity); this.evalEcaRules(EntityEcaHandler.EV_RUN, EntityEcaHandler.OP_FIND, dummyValue, ecaEventMap, (ecaEventMap == null), false); GenericHelper helper = getEntityHelper(entityName); List list = null; list = helper.findByCondition(modelEntity, entityCondition, fieldsToSelect, orderBy); this.evalEcaRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_FIND, dummyValue, ecaEventMap, (ecaEventMap == null), false); absorbList(list); return list; }