Search in sources :

Example 1 with FilterValue

use of org.motechproject.mds.filter.FilterValue in project motech by motech.

the class EntityServiceImpl method findEntitiesByPackage.

@Override
@Transactional
public List<EntityDto> findEntitiesByPackage(String packageName) {
    List<EntityDto> entities = new ArrayList<>();
    FilterValue filterValue = new FilterValue() {

        @Override
        public Object valueForQuery() {
            return super.getValue();
        }

        @Override
        public String paramTypeForQuery() {
            return String.class.getName();
        }

        @Override
        public List<String> operatorForQueryFilter() {
            return Arrays.asList(".startsWith(", ")");
        }
    };
    filterValue.setValue(packageName);
    Filter filter = new Filter("className", new FilterValue[] { filterValue });
    for (Entity entity : allEntities.filter(new Filters(filter), null, null)) {
        if (entity.isActualEntity()) {
            entities.add(entity.toDto());
        }
    }
    return entities;
}
Also used : EntityDto(org.motechproject.mds.dto.EntityDto) MdsEntity(org.motechproject.mds.domain.MdsEntity) Entity(org.motechproject.mds.domain.Entity) MdsVersionedEntity(org.motechproject.mds.domain.MdsVersionedEntity) Filters(org.motechproject.mds.filter.Filters) Filter(org.motechproject.mds.filter.Filter) ArrayList(java.util.ArrayList) FilterValue(org.motechproject.mds.filter.FilterValue) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ArrayList (java.util.ArrayList)1 Entity (org.motechproject.mds.domain.Entity)1 MdsEntity (org.motechproject.mds.domain.MdsEntity)1 MdsVersionedEntity (org.motechproject.mds.domain.MdsVersionedEntity)1 EntityDto (org.motechproject.mds.dto.EntityDto)1 Filter (org.motechproject.mds.filter.Filter)1 FilterValue (org.motechproject.mds.filter.FilterValue)1 Filters (org.motechproject.mds.filter.Filters)1 Transactional (org.springframework.transaction.annotation.Transactional)1