Search in sources :

Example 66 with EntityDto

use of org.motechproject.mds.dto.EntityDto in project motech by motech.

the class JdoListenerRegistryServiceImpl method updateEntityNames.

@Override
public void updateEntityNames() {
    for (MotechLifecycleListener listener : listeners) {
        String packageName = listener.getPackageName();
        if (!packageName.isEmpty()) {
            List<String> entityNames = new ArrayList<>();
            for (EntityDto entityDto : entityService.findEntitiesByPackage(packageName)) {
                entityNames.add(entityDto.getClassName());
            }
            listener.setEntityNames(entityNames);
        }
    }
}
Also used : EntityDto(org.motechproject.mds.dto.EntityDto) ArrayList(java.util.ArrayList) MotechLifecycleListener(org.motechproject.mds.listener.MotechLifecycleListener)

Example 67 with EntityDto

use of org.motechproject.mds.dto.EntityDto in project motech by motech.

the class InstanceServiceImpl method getInstanceHistory.

@Override
public List<BasicHistoryRecord> getInstanceHistory(Long entityId, Long instanceId, QueryParams queryParams) {
    EntityDto entity = getEntity(entityId);
    validateCredentialsForReading(entity);
    MotechDataService service = getServiceForEntity(entity);
    Object instance = service.retrieve(ID_FIELD_NAME, instanceId);
    List history = historyService.getHistoryForInstance(instance, queryParams);
    updateGridSize(entityId, queryParams);
    List<BasicHistoryRecord> result = new ArrayList<>();
    for (Object o : history) {
        result.add(convertToBasicHistoryRecord(o, entity, instanceId, service));
    }
    return result;
}
Also used : EntityDto(org.motechproject.mds.dto.EntityDto) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) BasicHistoryRecord(org.motechproject.mds.web.domain.BasicHistoryRecord) MotechDataService(org.motechproject.mds.service.MotechDataService)

Example 68 with EntityDto

use of org.motechproject.mds.dto.EntityDto in project motech by motech.

the class InstanceServiceImpl method getEntityRecords.

@Override
public List<BasicEntityRecord> getEntityRecords(Long entityId, QueryParams queryParams) {
    EntityDto entity = getEntity(entityId);
    validateCredentialsForReading(entity);
    List<FieldDto> fields = entityService.getEntityFieldsForUI(entityId);
    MotechDataService service = getServiceForEntity(entity);
    List instances = service.retrieveAll(queryParams);
    updateGridSize(entityId, queryParams);
    return instancesToBasicRecords(instances, entity, fields, service, EntityType.STANDARD);
}
Also used : EntityDto(org.motechproject.mds.dto.EntityDto) ArrayList(java.util.ArrayList) List(java.util.List) MotechDataService(org.motechproject.mds.service.MotechDataService) FieldDto(org.motechproject.mds.dto.FieldDto)

Example 69 with EntityDto

use of org.motechproject.mds.dto.EntityDto in project motech by motech.

the class InstanceServiceImpl method countHistoryRecords.

@Override
public long countHistoryRecords(Long entityId, Long instanceId) {
    EntityDto entity = getEntity(entityId);
    validateCredentialsForReading(entity);
    MotechDataService service = getServiceForEntity(entity);
    Object instance = service.retrieve(ID_FIELD_NAME, instanceId);
    return historyService.countHistoryRecords(instance);
}
Also used : EntityDto(org.motechproject.mds.dto.EntityDto) MotechDataService(org.motechproject.mds.service.MotechDataService)

Example 70 with EntityDto

use of org.motechproject.mds.dto.EntityDto in project motech by motech.

the class InstanceServiceImpl method getTrashRecords.

@Override
public List<BasicEntityRecord> getTrashRecords(Long entityId, QueryParams queryParams) {
    EntityDto entity = getEntity(entityId);
    validateCredentialsForReading(entity);
    MotechDataService service = getServiceForEntity(entity);
    List<FieldDto> fields = entityService.getEntityFieldsForUI(entityId);
    Collection collection = trashService.getInstancesFromTrash(entity.getClassName(), queryParams);
    updateGridSize(entityId, queryParams);
    return instancesToBasicRecords(collection, entity, fields, service, EntityType.TRASH);
}
Also used : EntityDto(org.motechproject.mds.dto.EntityDto) Collection(java.util.Collection) MotechDataService(org.motechproject.mds.service.MotechDataService) FieldDto(org.motechproject.mds.dto.FieldDto)

Aggregations

EntityDto (org.motechproject.mds.dto.EntityDto)136 Test (org.junit.Test)61 FieldDto (org.motechproject.mds.dto.FieldDto)53 ArrayList (java.util.ArrayList)34 LookupFieldDto (org.motechproject.mds.dto.LookupFieldDto)32 MotechDataService (org.motechproject.mds.service.MotechDataService)26 LookupDto (org.motechproject.mds.dto.LookupDto)24 List (java.util.List)19 BasicEntityRecord (org.motechproject.mds.web.domain.BasicEntityRecord)12 Method (java.lang.reflect.Method)11 FieldTestHelper.lookupFieldDto (org.motechproject.mds.testutil.FieldTestHelper.lookupFieldDto)11 Arrays.asList (java.util.Arrays.asList)9 FieldBasicDto (org.motechproject.mds.dto.FieldBasicDto)9 EntityRecord (org.motechproject.mds.web.domain.EntityRecord)9 AdvancedSettingsDto (org.motechproject.mds.dto.AdvancedSettingsDto)7 TypeDto (org.motechproject.mds.dto.TypeDto)7 HashMap (java.util.HashMap)6 SchemaHolder (org.motechproject.mds.dto.SchemaHolder)6 BasicFieldRecord (org.motechproject.mds.web.domain.BasicFieldRecord)6 FieldRecord (org.motechproject.mds.web.domain.FieldRecord)6