use of org.motechproject.mds.domain.EntityDefinitionType in project motech by motech.
the class ImportManifestReader method readManifest.
public ImportManifest readManifest() throws IOException {
ImportManifest manifest = new ImportManifest();
jsonReader.beginArray();
while (jsonReader.hasNext()) {
jsonReader.beginObject();
String entityName = objectReader.readString("entity");
EntityDefinitionType entityType = objectReader.readEnum("type", EntityDefinitionType.class);
Entity existingEntity = getExistingEntity(entityName);
boolean canImport = isImportable(existingEntity, entityType);
String moduleName = null != existingEntity && existingEntity.isDDE() ? existingEntity.getModule() : "MDS";
ImportManifest.Record manifestRecord = manifest.addRecord(entityName, moduleName);
objectReader.expectAndSkip("schema");
manifestRecord.setCanIncludeSchema(canImport);
if (jsonReader.hasNext()) {
objectReader.expectAndSkip("instances");
manifestRecord.setCanIncludeData(canImport);
}
if (jsonReader.hasNext()) {
throw new JsonParseException("Invalid json format! Unexpected property: " + jsonReader.nextName());
}
jsonReader.endObject();
}
jsonReader.endArray();
return manifest;
}
use of org.motechproject.mds.domain.EntityDefinitionType 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);
}
Aggregations