Skip to content
Snippets Groups Projects
Commit d23ef604 authored by Sebastian Ebert's avatar Sebastian Ebert
Browse files

removed now obsolete code, changed transformation, todo: export of...

removed now obsolete code, changed transformation, todo: export of pub/sub/service mapping in toolspecifics
parent 4d7fcc38
No related branches found
No related tags found
No related merge requests found
......@@ -16,15 +16,15 @@ 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/pnml-relast-tools/pnml-relast-nets/src/main/resources/topicTestNets/structureTestNets/topic-structure-correct.pnml");
List<PetriNet> petriNets = PnmlParser.parsePnml(inputPath);
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<List<PetriNet>> disconnectedPetriNets = new ArrayList<>();
GlobalToLocalNetsPostProcessor processor = new GlobalToLocalNetsPostProcessor();
......
package de.tudresden.inf.st.pnml.splitter.postprocessing;
import de.tudresden.inf.st.pnml.base.constants.PnmlConstants;
import de.tudresden.inf.st.pnml.base.data.CommunicatorInformation;
import de.tudresden.inf.st.pnml.jastadd.model.*;
import de.tudresden.inf.st.pnml.splitter.constants.SplitterPnmlConstants;
import fr.lip6.move.pnml.framework.utils.exception.InvalidIDException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
......@@ -47,6 +49,8 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> {
Set<String> locations = getNodes(serviceCutNet);
updateToolSpecificsWithPlaceInfos(serviceCutNet);
logger.info("##############################################################################################");
PostProcessingUtils.printNet(serviceCutNet, true, false);
......@@ -283,55 +287,98 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> {
return petriNet;
}
private ToolInfo updateToolSpecificsWithPlaceInfos(ToolInfo oldToolInfo) {
private void updateToolSpecificsWithPlaceInfos(PetriNet petriNet) {
ToolInfo ti = buildToolSpecifics(petriNet);
JastAddList<ToolInfo> tiList = new JastAddList<>();
tiList.add(ti);
petriNet.setToolspecificList(tiList);
petriNet.flushTreeCache();
return null;
}
private ToolInfo buildToolSpecifics(ToolInfo oldToolInfo) {
private void buildPlaceInfoListPart(Document doc, Element ports, Map<String, List<DinerosPlace>> map, String placeType) {
StringBuffer oldXMLContent = oldToolInfo.getFormattedXMLBuffer();
for (Map.Entry<String, List<DinerosPlace>> entry : map.entrySet()) {
for (DinerosPlace dp : entry.getValue()) {
Element port = doc.createElement(PnmlConstants.CHANNEL_PORT_KEY);
port.appendChild(doc.createTextNode(dp.getId()));
try {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Attr attr1 = doc.createAttribute(PnmlConstants.CHANNEL_NAME_KEY);
attr1.setValue(entry.getKey());
port.setAttributeNode(attr1);
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement(SplitterPnmlConstants.TOOLSPECIFIC_KEY);
rootElement.setAttribute(SplitterPnmlConstants.TOOL_KEY, SplitterPnmlConstants.SPLITTER_TOOL_NAME);
rootElement.setAttribute(SplitterPnmlConstants.VERSION_KEY, SplitterPnmlConstants.SPLITTER_TOOL_VERSION);
doc.appendChild(rootElement);
Attr attr2 = doc.createAttribute(PnmlConstants.CHANNEL_PLACE_TYPE_KEY);
attr2.setValue(placeType);
port.setAttributeNode(attr2);
ports.appendChild(port);
}
}
}
Element pubPlaces = doc.createElement("publisherPlaces");
Element subPlaces = doc.createElement("publisherPlaces");
private void buildPlaceInfoListServerPart(Document doc, Element ports, Map<String, DinerosPlace> map, String placeType) {
for (Map.Entry<String, DinerosPlace> entry : map.entrySet()) {
for (Map.Entry<String, List<DinerosPlace>> entry : topicPublisherPlaces.entrySet()) {
Element port = doc.createElement(PnmlConstants.CHANNEL_PORT_KEY);
port.appendChild(doc.createTextNode(entry.getValue().getId()));
}
Attr attr1 = doc.createAttribute(PnmlConstants.CHANNEL_NAME_KEY);
attr1.setValue(entry.getKey());
port.setAttributeNode(attr1);
Attr attr2 = doc.createAttribute(PnmlConstants.CHANNEL_PLACE_TYPE_KEY);
attr2.setValue(placeType);
port.setAttributeNode(attr2);
/* for (InputSignalBinding isb : inputSignalBindings) {
ports.appendChild(port);
Element binding = doc.createElement(PnmlConstants.INPUT_SIGNAL_BINDING_KEY);
}
}
Element transitionID = doc.createElement(PnmlConstants.TRANSITION_ID_KEY);
transitionID.appendChild(doc.createTextNode(isb.getTransitionID()));
binding.appendChild(transitionID);
private ToolInfo buildToolSpecifics(PetriNet petriNet) {
Element inputsignalID = doc.createElement(PnmlConstants.INPUT_SIGNAL_ID_KEY);
inputsignalID.appendChild(doc.createTextNode(isb.getInputSignalID()));
binding.appendChild(inputsignalID);
// get old infos
CommunicatorInformation ci = ToolSpecificsParser.getCommunicatorInformationFromToolSpecifics(petriNet.getToolspecifics());
Element initialvalue = doc.createElement(PnmlConstants.CURRENT_VALUE_KEY);
initialvalue.appendChild(doc.createTextNode(String.valueOf(isb.getInputSignalValue())));
binding.appendChild(initialvalue);
// build place infos
try {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
bindings.appendChild(binding);
}
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement(SplitterPnmlConstants.TOOLSPECIFIC_KEY);
rootElement.setAttribute(SplitterPnmlConstants.TOOL_KEY, SplitterPnmlConstants.SPLITTER_TOOL_NAME);
rootElement.setAttribute(SplitterPnmlConstants.VERSION_KEY, SplitterPnmlConstants.SPLITTER_TOOL_VERSION);
doc.appendChild(rootElement);
Element ports = doc.createElement(PnmlConstants.CHANNEL_PORTS_KEY);
buildPlaceInfoListPart(doc, ports, topicPublisherPlaces, PnmlConstants.CHANNEL_PLACE_TYPE_PUB_KEY);
buildPlaceInfoListPart(doc, ports, topicSubscriberPlaces, PnmlConstants.CHANNEL_PLACE_TYPE_SUB_KEY);
buildPlaceInfoListPart(doc, ports, serviceClientReqPlaces, PnmlConstants.CHANNEL_PLACE_TYPE_CLIENT_REQ_KEY);
buildPlaceInfoListPart(doc, ports, serviceClientResPlaces, PnmlConstants.CHANNEL_PLACE_TYPE_CLIENT_RES_KEY);
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);
}
}
rootElement.appendChild(bindings);
rootElement.appendChild(coms);
rootElement.appendChild(ports);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer trans = tf.newTransformer();
......@@ -343,12 +390,13 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> {
toolInfo.setVersion(SplitterPnmlConstants.SPLITTER_TOOL_VERSION);
toolInfo.setTool(SplitterPnmlConstants.SPLITTER_TOOL_NAME);
return toolInfo;*/
return toolInfo;
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (TransformerException e) {
throw new RuntimeException(e);
}
return null;
}
}
\ No newline at end of file
......@@ -267,7 +267,10 @@ public class PostProcessingUtils {
if (ist != null && ist.getMutableTransitionInformation() == null) {
if(ist.getStaticTransitionInformation().isSignalTransitionInformation()){
System.out.println(ist.getStaticTransitionInformation().asSignalTransitionInformation().getClause().printClause());
InputSignalClause isc = ist.getStaticTransitionInformation().asSignalTransitionInformation().getClause();
if(isc != null){
System.out.println(isc.printClause());
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment