use of org.motechproject.mds.domain.Entity in project motech by motech.
the class EntityWriterTest method shouldWriteModifiedDDE.
@Test
public void shouldWriteModifiedDDE() throws IOException {
Entity dde = buildModifiedDDE();
String ddeJsonResource = "json/EntityWriterTest_ModifiedDDE.json";
assertEntityWrittenCorrectly(dde, ddeJsonResource);
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class ActionHandlerServiceImpl method queryAndUpdate.
@Override
public void queryAndUpdate(Map<String, Object> parameters) throws ActionHandlerException {
LOGGER.debug("Action QUERY AND UPDATE: params {}", parameters);
String entityClassName = getEntityClassName(parameters);
MotechDataService dataService = getEntityDataService(entityClassName);
Entity entity = getEntity(entityClassName);
List<?> instances = dataService.retrieveAll();
for (Object instance : instances) {
setInstancePropertiesForQuery(instance, entity.getFields(), parameters);
dataService.update(instance);
}
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class ImportExportServiceImpl method sortBlueprintRecords.
private ImportExportBlueprint sortBlueprintRecords(ImportExportBlueprint blueprint) {
List<Entity> entities = new ArrayList<>(blueprint.size());
for (ImportExportBlueprint.Record record : blueprint) {
entities.add(allEntities.retrieveByClassName(record.getEntityName()));
}
RelationshipSorter relationshipSorter = new RelationshipSorter();
relationshipSorter.sort(entities);
ImportExportBlueprint sortedBlueprint = new ImportExportBlueprint();
for (Entity entity : entities) {
String entityName = entity.getClassName();
sortedBlueprint.includeEntitySchema(entityName, blueprint.isIncludeEntitySchema(entityName));
sortedBlueprint.includeEntityData(entityName, blueprint.isIncludeEntityData(entityName));
}
return sortedBlueprint;
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class ImportReader method beginEntry.
public EntryReader beginEntry() throws IOException {
jsonReader.beginObject();
String entityName = objectReader.readString("entity");
EntityDefinitionType entityType = objectReader.readEnum("type", EntityDefinitionType.class);
Entity entity = importContext.getEntity(entityName);
return new EntryReader(jsonReader, entityName, entityType, entity, importContext);
}
use of org.motechproject.mds.domain.Entity in project motech by motech.
the class ImportContext method setupNewEntity.
public Entity setupNewEntity(String entityName) {
Entity entity = new Entity(entityName);
EntityHelper.addDefaultFields(entity, allTypes);
return entity;
}
Aggregations