diff --git a/li.strolch.service/src/main/java/li/strolch/command/XmlExportModelCommand.java b/li.strolch.service/src/main/java/li/strolch/command/XmlExportModelCommand.java index 438e537b7..069ebaa99 100644 --- a/li.strolch.service/src/main/java/li/strolch/command/XmlExportModelCommand.java +++ b/li.strolch.service/src/main/java/li/strolch/command/XmlExportModelCommand.java @@ -24,8 +24,8 @@ import java.nio.file.Files; import java.text.MessageFormat; import java.util.Date; import java.util.HashSet; +import java.util.List; import java.util.Set; -import java.util.TreeSet; import java.util.concurrent.TimeUnit; import javax.xml.stream.XMLStreamWriter; @@ -162,7 +162,7 @@ public class XmlExportModelCommand extends Command { if (this.doResources) { ResourceMap resourceMap = tx().getResourceMap(); - Set resourceTypesToExport = new TreeSet<>(resourceMap.getTypes(tx())); + Set resourceTypesToExport = resourceMap.getTypes(tx()); if (!this.resourceTypes.isEmpty()) resourceTypesToExport.retainAll(this.resourceTypes); @@ -192,7 +192,7 @@ public class XmlExportModelCommand extends Command { if (this.doOrders) { OrderMap orderMap = tx().getOrderMap(); - Set orderTypesToExport = new TreeSet<>(orderMap.getTypes(tx())); + Set orderTypesToExport = orderMap.getTypes(tx()); if (!this.orderTypes.isEmpty()) orderTypesToExport.retainAll(this.orderTypes); @@ -221,7 +221,7 @@ public class XmlExportModelCommand extends Command { if (this.doActivities) { ActivityMap activityMap = tx().getActivityMap(); - Set activityTypesToExport = new TreeSet<>(activityMap.getTypes(tx())); + Set activityTypesToExport = activityMap.getTypes(tx()); if (!this.activityTypes.isEmpty()) activityTypesToExport.retainAll(this.activityTypes); @@ -276,27 +276,18 @@ public class XmlExportModelCommand extends Command { private void writeOrdersByType(XMLStreamWriter writer, OrderMap orderMap, String type) { StrolchElementToSaxWriterVisitor visitor = new StrolchElementToSaxWriterVisitor(writer); - Set keysByType = new TreeSet<>(orderMap.getKeysBy(tx(), type)); - for (String id : keysByType) { - Order order = orderMap.getBy(tx(), type, id); + List orders = orderMap.getElementsBy(tx(), type); + for (Order order : orders) { order.accept(visitor); this.statistics.nrOfOrders++; logElementsWritten(); } } - private void logElementsWritten() { - if (this.nextLogTime < System.currentTimeMillis()) { - logger.info("Wrote " + this.statistics.getNrOfElements() + " of " + this.elementsToWrite + " Elements."); - this.nextLogTime = System.currentTimeMillis() + LOG_INTERVAL; - } - } - private void writeResourcesByType(XMLStreamWriter writer, ResourceMap resourceMap, String type) { StrolchElementToSaxWriterVisitor visitor = new StrolchElementToSaxWriterVisitor(writer); - Set keysByType = new TreeSet<>(resourceMap.getKeysBy(tx(), type)); - for (String id : keysByType) { - Resource resource = resourceMap.getBy(tx(), type, id); + List resources = resourceMap.getElementsBy(tx(), type); + for (Resource resource : resources) { resource.accept(visitor); this.statistics.nrOfResources++; logElementsWritten(); @@ -305,15 +296,21 @@ public class XmlExportModelCommand extends Command { private void writeActivitiesByType(XMLStreamWriter writer, ActivityMap activityMap, String type) { StrolchElementToSaxWriterVisitor visitor = new StrolchElementToSaxWriterVisitor(writer); - Set keysByType = new TreeSet<>(activityMap.getKeysBy(tx(), type)); - for (String id : keysByType) { - Activity activity = activityMap.getBy(tx(), type, id); + List activities = activityMap.getElementsBy(tx(), type); + for (Activity activity : activities) { activity.accept(visitor); this.statistics.nrOfActivities++; logElementsWritten(); } } + private void logElementsWritten() { + if (this.nextLogTime < System.currentTimeMillis()) { + logger.info("Wrote " + this.statistics.getNrOfElements() + " of " + this.elementsToWrite + " Elements."); + this.nextLogTime = System.currentTimeMillis() + LOG_INTERVAL; + } + } + /** * @param modelFile * the modelFile to set