diff --git a/src/main/java/de/tudresden/inf/st/pnml/splitter/Main.java b/src/main/java/de/tudresden/inf/st/pnml/splitter/Main.java index 3a09e700dc4fe6f96b1cafd3fcb7efb5a4597f60..de39f4d618097a7393b58cddc0f3404205112710 100644 --- a/src/main/java/de/tudresden/inf/st/pnml/splitter/Main.java +++ b/src/main/java/de/tudresden/inf/st/pnml/splitter/Main.java @@ -16,15 +16,14 @@ public class Main { public static void main(String[] args) { - /* String inputPath = (args.length > 0) ? args[0] : null; + String inputPath = (args.length > 0) ? args[0] : null; if (inputPath == null) { logger.error("No model found on given input path."); return; - }*/ + } - List<PetriNet> petriNets = PnmlParser.parsePnml("/home/sebastian/git/dineros-v2/dineros/pnml-relast-tools/pnml-relast-splitter/src/main/nets/TestNet1.pnml"); - // List<PetriNet> petriNets = PnmlParser.parsePnml(inputPath); + List<PetriNet> petriNets = PnmlParser.parsePnml(inputPath); List<List<PetriNet>> disconnectedPetriNets = new ArrayList<>(); GlobalToLocalNetsPostProcessor processor = new GlobalToLocalNetsPostProcessor(); diff --git a/src/main/java/de/tudresden/inf/st/pnml/splitter/postprocessing/GlobalToLocalNetsPostProcessor.java b/src/main/java/de/tudresden/inf/st/pnml/splitter/postprocessing/GlobalToLocalNetsPostProcessor.java index 1147fa617f8e37f0a1a974d1e49ee159319ec243..ed4e6b3fb2aa92132302904a9948d787844e0bb9 100644 --- a/src/main/java/de/tudresden/inf/st/pnml/splitter/postprocessing/GlobalToLocalNetsPostProcessor.java +++ b/src/main/java/de/tudresden/inf/st/pnml/splitter/postprocessing/GlobalToLocalNetsPostProcessor.java @@ -300,7 +300,13 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> { private void buildPlaceInfoListPart(Document doc, Element ports, Map<String, List<DinerosPlace>> map, String placeType) { for (Map.Entry<String, List<DinerosPlace>> entry : map.entrySet()) { + + System.out.println("- " + entry.getKey()); + for (DinerosPlace dp : entry.getValue()) { + + System.out.println("- - - " + dp.getId()); + Element port = doc.createElement(PnmlConstants.CHANNEL_PORT_KEY); port.appendChild(doc.createTextNode(dp.getId())); @@ -362,22 +368,25 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> { buildPlaceInfoListServerPart(doc, ports, serviceServerReqPlaces, PnmlConstants.CHANNEL_PLACE_TYPE_SERVER_REQ_KEY); buildPlaceInfoListServerPart(doc, ports, serviceServerResPlaces, PnmlConstants.CHANNEL_PLACE_TYPE_SERVER_RES_KEY); - Element coms = doc.createElement(PnmlConstants.COMMUNICATORS); - - for(String s : ci.getCommunicatorMapping().keySet()){ - for(String type : ci.getCommunicatorMapping().get(s)){ - Element com = doc.createElement(PnmlConstants.COMMUNICATOR); - Element cType = doc.createElement(PnmlConstants.COMMUNICATOR_TYPE); - cType.setTextContent(type); - com.appendChild(cType); - Element cSubnet = doc.createElement(PnmlConstants.COMMUNICATOR_SUBNET); - cSubnet.setTextContent(s); - com.appendChild(cSubnet); - coms.appendChild(com); - } + if(ci.getCommunicatorMapping().keySet().size() > 0) { + Element coms = doc.createElement(PnmlConstants.COMMUNICATORS); + + for (String s : ci.getCommunicatorMapping().keySet()) { + for (String type : ci.getCommunicatorMapping().get(s)) { + Element com = doc.createElement(PnmlConstants.COMMUNICATOR); + Element cType = doc.createElement(PnmlConstants.COMMUNICATOR_TYPE); + cType.setTextContent(type); + com.appendChild(cType); + Element cSubnet = doc.createElement(PnmlConstants.COMMUNICATOR_SUBNET); + cSubnet.setTextContent(s); + com.appendChild(cSubnet); + coms.appendChild(com); + } + } + + rootElement.appendChild(coms); } - rootElement.appendChild(coms); rootElement.appendChild(ports); TransformerFactory tf = TransformerFactory.newInstance(); diff --git a/src/main/nets/TestNet1.pnml b/src/main/nets/TestNet1.pnml index 30e4c57e2dca82a54342ff54e3d1b32502a3ac10..fdb0c17ac7727bc00c78683f82b7779ac369e3cf 100644 --- a/src/main/nets/TestNet1.pnml +++ b/src/main/nets/TestNet1.pnml @@ -25,7 +25,7 @@ </page> <transition id="sampleTopic"> <toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1"> - <type>topic</type> + <type>topicTransitionType</type> <topicName>sampleTopic</topicName> <publishers> <publisher>