From ac33592658774940d21c405598b0531dc5a8757e Mon Sep 17 00:00:00 2001 From: SebastianEbert <sebastian.ebert@tu-dresden.de> Date: Tue, 23 May 2023 17:17:09 +0200 Subject: [PATCH] fixed processor, updated test nets --- .../tudresden/inf/st/pnml/splitter/Main.java | 7 ++-- .../GlobalToLocalNetsPostProcessor.java | 37 ++++++++++++------- src/main/nets/TestNet1.pnml | 2 +- 3 files changed, 27 insertions(+), 19 deletions(-) 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 3a09e70..de39f4d 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 1147fa6..ed4e6b3 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 30e4c57..fdb0c17 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> -- GitLab