use of org.motechproject.mds.dto.EntityDto in project motech by motech.
the class MDSConstructorImpl method registerEnhancedClassBytes.
private void registerEnhancedClassBytes(List<EntityDto> entities, MdsJDOEnhancer enhancer, SchemaHolder schemaHolder) {
for (EntityDto entity : entities) {
// register
String className = entity.getClassName();
LOGGER.debug("Registering {}", className);
registerClass(enhancer, entity);
if (entity.isRecordHistory()) {
registerHistoryClass(enhancer, className);
}
registerTrashClass(enhancer, className);
LOGGER.debug("Building infrastructure for {}", className);
buildInfrastructure(entity, schemaHolder);
}
}
use of org.motechproject.mds.dto.EntityDto in project motech by motech.
the class MDSConstructorImpl method buildClasses.
private Map<String, ClassData> buildClasses(List<EntityDto> entities, SchemaHolder schemaHolder) {
Map<String, ClassData> classDataMap = new LinkedHashMap<>();
// We build classes for all entities
for (EntityDto entity : entities) {
List<FieldDto> fields = schemaHolder.getFields(entity);
ClassData classData = buildClass(entity, fields);
ClassData historyClassData = null;
if (entity.isRecordHistory()) {
historyClassData = entityBuilder.buildHistory(entity, fields);
}
ClassData trashClassData = entityBuilder.buildTrash(entity, fields);
String className = entity.getClassName();
classDataMap.put(className, classData);
if (historyClassData != null) {
classDataMap.put(ClassName.getHistoryClassName(className), historyClassData);
}
classDataMap.put(ClassName.getTrashClassName(className), trashClassData);
}
return classDataMap;
}
use of org.motechproject.mds.dto.EntityDto 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;
}
use of org.motechproject.mds.dto.EntityDto in project motech by motech.
the class EntityServiceImpl method listWorkInProgress.
@Override
@Transactional
public List<EntityDto> listWorkInProgress() {
String username = getUsername();
List<EntityDraft> drafts = allEntityDrafts.retrieveAll(username);
List<EntityDto> entityDtoList = new ArrayList<>();
for (EntityDraft draft : drafts) {
if (draft.isChangesMade()) {
entityDtoList.add(draft.toDto());
}
}
return entityDtoList;
}
use of org.motechproject.mds.dto.EntityDto in project motech by motech.
the class EntityServiceImpl method getSchema.
@Override
@Transactional
public SchemaHolder getSchema() {
StopWatch stopWatch = new StopWatch();
SchemaHolder entitiesHolder = new SchemaHolder();
LOGGER.debug("Retrieving entities for processing");
stopWatch.start();
List<Entity> entities = allEntities.getActualEntities();
stopWatch.stop();
LOGGER.debug("{} entities retrieved in {} ms", entities.size(), stopWatch.getTime());
StopWatchHelper.restart(stopWatch);
for (Entity entity : entities) {
LOGGER.debug("Preparing entity: {}", entity.getClassName());
StopWatchHelper.restart(stopWatch);
EntityDto entityDto = entity.toDto();
stopWatch.stop();
LOGGER.debug("Entity dto created in {} ms", stopWatch.getTime());
StopWatchHelper.restart(stopWatch);
AdvancedSettingsDto advSettingsDto = entity.advancedSettingsDto();
stopWatch.stop();
LOGGER.debug("Advanced settings dto created in {} ms", stopWatch.getTime());
StopWatchHelper.restart(stopWatch);
List<FieldDto> fieldDtos = entity.getFieldDtos();
stopWatch.stop();
LOGGER.debug("Field dtos created in {} ms", stopWatch.getTime());
StopWatchHelper.restart(stopWatch);
entitiesHolder.addEntity(entityDto, advSettingsDto, fieldDtos);
stopWatch.stop();
LOGGER.debug("Result stored in {} ms", stopWatch.getTime());
}
LOGGER.debug("Retrieving types for processing");
List<Type> types = allTypes.retrieveAll();
for (Type type : types) {
TypeDto typeDto = type.toDto();
entitiesHolder.addType(typeDto);
entitiesHolder.addTypeValidation(typeDto, type.getTypeValidationDtos());
}
LOGGER.debug("Entities holder ready");
return entitiesHolder;
}
Aggregations