use of org.motechproject.mds.helper.RelationshipSorter 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;
}
Aggregations