Search in sources :

Example 1 with RelationshipSorter

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;
}
Also used : Entity(org.motechproject.mds.domain.Entity) ArrayList(java.util.ArrayList) RelationshipSorter(org.motechproject.mds.helper.RelationshipSorter) ImportExportBlueprint(org.motechproject.mds.domain.ImportExportBlueprint)

Aggregations

ArrayList (java.util.ArrayList)1 Entity (org.motechproject.mds.domain.Entity)1 ImportExportBlueprint (org.motechproject.mds.domain.ImportExportBlueprint)1 RelationshipSorter (org.motechproject.mds.helper.RelationshipSorter)1