public int count(final ModelEntity modelEntity, final String fieldName, final EntityCondition entityCondition, final EntityFindOptions findOptions) throws GenericEntityException { Map<GenericEntity, GenericValue> entityCache = cache.get(modelEntity.getEntityName()); if (entityCache == null) { return 0; } List<GenericValue> genericValues = this.findByCondition(modelEntity, entityCondition, Lists.newArrayList(fieldName), null); return genericValues.size(); }
public int removeByCondition(final ModelEntity modelEntity, final EntityCondition whereCondition) throws GenericEntityException { Map<GenericEntity, GenericValue> entityCache = cache.get(modelEntity.getEntityName()); if (entityCache == null) { return 0; } List<GenericValue> foundValues = findByCondition(modelEntity, whereCondition, null, null); return removeAll(foundValues); }
/** * The memory implementation does the *minimum* that it can to allow tests to work. In particular it will * return *all* values for a particular entity from this method. */ public EntityListIterator findListIteratorByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions) throws GenericEntityException { final Iterator<GenericValue> entities = (new ArrayList<GenericValue>(findByCondition(modelEntity, whereEntityCondition, fieldsToSelect, orderBy))).iterator(); // hack in the minimum that we can for this. return new EntityListIterator(new ReadOnlySQLProcessor(null), modelEntity, null, modelFieldTypeReader) { public GenericValue next() { if (entities.hasNext()) return entities.next(); else return null; } public void close() { //do nothing } }; }
/** * The memory implementation does the *minimum* that it can to allow tests to work. In particular it will * return *all* values for a particular entity from this method. */ public EntityListIterator findListIteratorByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, Collection fieldsToSelect, List orderBy, EntityFindOptions findOptions) throws GenericEntityException { final Iterator entities = (new ArrayList(findByCondition(modelEntity, whereEntityCondition, fieldsToSelect, orderBy))).iterator(); // hack in the minimum that we can for this. EntityListIterator entityListIterator = new EntityListIterator(new ReadOnlySQLProcessor(null), modelEntity, null, modelFieldTypeReader) { public Object next() { if (entities.hasNext()) return entities.next(); else return null; } public void close() { //do nothing } }; return entityListIterator; }
/** * The memory implementation does the *minimum* that it can to allow tests to work. In particular it will * return *all* values for a particular entity from this method. */ public EntityListIterator findListIteratorByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, Collection fieldsToSelect, List orderBy, EntityFindOptions findOptions) throws GenericEntityException { final Iterator entities = (new ArrayList(findByCondition(modelEntity, whereEntityCondition, fieldsToSelect, orderBy))).iterator(); // hack in the minimum that we can for this. EntityListIterator entityListIterator = new EntityListIterator(new ReadOnlySQLProcessor(null), modelEntity, null, modelFieldTypeReader) { public Object next() { if (entities.hasNext()) return entities.next(); else return null; } public void close() { //do nothing } }; return entityListIterator; }