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

fixed place reference related bugs, added testnets for new services and topics

parent efbc11cc
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,20 @@ buildscript {
dependencies {
classpath group: 'org.jastadd', name: 'jastaddgradle', version: '1.13.3'
}
configurations {
classpath {
exclude group: 'org.slf4j', module: 'slf4j-api'//, version: '1.7.30'
}
}
/* configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.name == 'org.slf4j') {
details.useTarget 'org.slf4j:slf4j-api:1.7.+'
}
}
}*/
}
idea.module.generatedSourceDirs += file('src/gen/java')
......
......@@ -25,17 +25,14 @@ public class Main {
return;
}
// List<PetriNet> petriNets = PnmlParser.parsePnml("src/main/nets/jointTestNet1.pnml");
// List<PetriNet> petriNets = PnmlParser.parsePnml("pnml-relast-splitter/src/main/nets/serviceTest1.pnml");
List<PetriNet> petriNets = PnmlParser.parsePnml(inputPath);
List<List<PetriNet>> disconnectedPetriNets = new ArrayList<>();
// petriNets.forEach(pn -> disconnectedPetriNets.add(GlobalToLocalNetsPostProcessor.disconnectNets(pn)));
for (PetriNet pn : petriNets) {
PostProcessingUtils.printNet(pn);
List<PetriNet> pnl = GlobalToLocalNetsPostProcessor.disconnectNets(pn);
disconnectedPetriNets.add(pnl);
PostProcessingUtils.printNet(pnl.get(0));
}
for (List<PetriNet> petriNetList : disconnectedPetriNets) {
......@@ -45,7 +42,7 @@ public class Main {
}
}
logger.info("------------------------------------------------------------------------------------");
logger.info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
for (int i = 0; i < disconnectedPetriNets.size(); i++) {
for (int j = 0; j < disconnectedPetriNets.get(i).size(); j++) {
......
......@@ -138,7 +138,6 @@ public class PnmlExporter {
private static Set<RefPlaceHLAPI> convertAndIncludeRefPlaces(PetriNet petriNet, Set<PageHLAPI> convertedPages, Set<PlaceHLAPI> convertedPlaces) {
Set<RefPlaceHLAPI> convertedRefPlaces = new HashSet<>();
PlaceHLAPI rootPlace = null;
......@@ -148,20 +147,14 @@ public class PnmlExporter {
for (PlaceHLAPI ph : convertedPlaces) {
if (ph.getId().equals(p.getRef().getId())) {
rootPlace = ph;
break;
}
}
break;
}
}
// construct the first reference level
for(RefPlace p: petriNet.allRefPlaces()){
for (RefPlace p_one : petriNet.allRefPlaces()) {
assert rootPlace != null;
if(p.getRef().getId().equals(rootPlace.getId())){
RefPlaceHLAPI rph = PrimitiveElementsConverter.convertRefPlaceToPnmlObject(p, rootPlace, null);
if (p_one.getRef().getId().equals(rootPlace.getId())) {
RefPlaceHLAPI rph = PrimitiveElementsConverter.convertRefPlaceToPnmlObject(p_one, rootPlace, null);
for (PageHLAPI pageHLAPI : convertedPages) {
if(pageHLAPI.getId().equals(p.ContainingPage().getId())){
if (pageHLAPI.getId().equals(p_one.ContainingPage().getId())) {
assert rph != null;
rph.setContainerPageHLAPI(pageHLAPI);
break;
......@@ -172,12 +165,12 @@ public class PnmlExporter {
}
// construct the remaining levels
for(RefPlace p: petriNet.allRefPlaces()){
for (RefPlace p_tree : petriNet.allRefPlaces()) {
for (RefPlaceHLAPI convRef : convertedRefPlaces) {
if(convRef.getId().equals(p.getRef().getId())){
RefPlaceHLAPI rph = PrimitiveElementsConverter.convertRefPlaceToPnmlObject(p, null,convRef);
if (convRef.getId().equals(p_tree.getRef().getId())) {
RefPlaceHLAPI rph = PrimitiveElementsConverter.convertRefPlaceToPnmlObject(p_tree, null, convRef);
for (PageHLAPI pageHLAPI : convertedPages) {
if(pageHLAPI.getId().equals(p.ContainingPage().getId())){
if (pageHLAPI.getId().equals(p_tree.ContainingPage().getId())) {
assert rph != null;
rph.setContainerPageHLAPI(pageHLAPI);
break;
......@@ -187,6 +180,10 @@ public class PnmlExporter {
}
}
}
}
}
}
}
return convertedRefPlaces;
}
......
......@@ -43,7 +43,7 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> {
Set<String> locations = getLocations(serviceCuttedNet);
// serialize for deep copy
String serializedNetPath = PnmlExporter.serializeToPnmlFile(petriNet, "-pre-split.pnml");
String serializedNetPath = PnmlExporter.serializeToPnmlFile(serviceCuttedNet, "-pre-split.pnml");
// filter deep copy elements by location
for (String location : locations) {
......@@ -74,6 +74,15 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> {
logger.error("Found place without location.");
}
}
for(RefPlace rp : petriNet.allRefPlaces()){
if (rp.getSubNet() != null) {
allLocations.add(rp.getSubNet());
} else {
logger.error("Found reference place without location.");
}
}
return allLocations;
}
......@@ -197,7 +206,8 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> {
targetIst.setMutualTransitionInformation(tInfoTarget);
// Gel all outgoing arcs and connect them to new input transition
for (Arc arc : p.asOutputSignalPlace().getInArcList().toArray(new Arc[0])) {
// for (Arc arc : p.asOutputSignalPlace().getInArcList().toArray(new Arc[0])) {
for(Arc arc : ist.asInputSignalTransition().getOutArcList().toArray(new Arc[0])){
if (arc.getSource().getId().equals(transition.getId())) {
arc.setSource(targetIst);
}
......@@ -300,8 +310,8 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> {
subscriberIst.setMutualTransitionInformation(tInfoTarget);
// Gel all outgoing arcs and connect them to new input transition
for (Arc arc : p.asOutputSignalPlace().getInArcList().toArray(new Arc[0])) {
// for (Arc arc : p.asOutputSignalPlace().getInArcList().toArray(new Arc[0])) {
for(Arc arc : channelIst.asInputSignalTransition().getOutArcList().toArray(new Arc[0])){
if (arc.getSource().getId().equals(transition.getId())) {
arc.setSource(subscriberIst);
}
......@@ -374,7 +384,6 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> {
publisherCount++;
processedSubnets.add(p.asOutputSignalPlace().getStaticPlaceInformation().getSubNet());
} else {
for (Transition t : transitionsToAdd) {
if (t.asInputSignalTransition().getStaticTransitionInformation().getSubNet().equals(p.asOutputSignalPlace().getStaticPlaceInformation().getSubNet())) {
// Get all incoming arcs and connect them to new output transition
......@@ -390,11 +399,13 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> {
private static PetriNet createdSeparatedNetByLocation(PetriNet petriNet, String location) {
Set<String> removedTransitionIds = new HashSet<>();
Set<String> removePlaceIds = new HashSet<>();
Set<String> removedPlaceIds = new HashSet<>();
Set<String> removedRefTransitionIds = new HashSet<>();
Set<String> removeRefPlaceIds = new HashSet<>();
for (Place place : petriNet.allPlaces()) {
if (!place.asOutputSignalPlace().getStaticPlaceInformation().getSubNet().equals(location)) {
removePlaceIds.add(place.getId());
removedPlaceIds.add(place.getId());
}
}
......@@ -404,9 +415,23 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> {
}
}
for (RefPlace place : petriNet.allRefPlaces()) {
if (!place.getSubNet().equals(location)) {
removeRefPlaceIds.add(place.getId());
}
}
for (RefTransition transition : petriNet.allRefTransitions()) {
if (!transition.getSubNet().equals(location)) {
removedRefTransitionIds.add(transition.getId());
}
}
for (Arc arc : petriNet.allArcs()) {
if (removedTransitionIds.contains(arc.getSource().getId()) || removedTransitionIds.contains(arc.getTarget().getId())
|| removePlaceIds.contains(arc.getSource().getId()) || removePlaceIds.contains(arc.getTarget().getId())) {
|| removedPlaceIds.contains(arc.getSource().getId()) || removedPlaceIds.contains(arc.getTarget().getId())
|| removedRefTransitionIds.contains(arc.getSource().getId()) || removedRefTransitionIds.contains(arc.getTarget().getId())
|| removeRefPlaceIds.contains(arc.getSource().getId()) || removeRefPlaceIds.contains(arc.getTarget().getId())) {
logger.info("removing arc " + arc.getId() + " from net");
arc.removeSelf();
}
......@@ -419,6 +444,20 @@ public class GlobalToLocalNetsPostProcessor implements PostProcessor<PetriNet> {
}
}
for (RefPlace place : petriNet.allRefPlaces()) {
if (!place.getSubNet().equals(location)) {
logger.info("removing ref place " + place.getId() + " from net");
place.removeSelf();
}
}
for (RefTransition transition : petriNet.allRefTransitions()) {
if (!transition.getSubNet().equals(location)) {
logger.info("removing ref transition " + transition.getId() + " from net");
transition.removeSelf();
}
}
for (Transition transition : petriNet.allTransitions()) {
if(transition.asInputSignalTransition().getStaticTransitionInformation().isTopicTransitionInformation()){
......
......@@ -237,6 +237,18 @@ public class PostProcessingUtils {
}
}
logger.info("----------------- REF PLACES -----------------");
for (RefPlace rp : petriNet.allRefPlaces()){
logger.info("--- RefPlace: " + rp.getId());
}
logger.info("----------------- REF TRANSITIONS -----------------");
for (RefTransition rt : petriNet.allRefTransitions()){
logger.info("--- RefTransition: " + rt.getId());
}
logger.info("----------------- ARCS -----------------");
for (Arc a : petriNet.allArcs()) {
......
<pnml xmlns="http://www.pnml.org/version-2009/grammar/pnml">
<net id="n-E2D0-BCF46-0" type ="http://www.pnml.org/version-2009/grammar/ptnet">
<name>
<text>topicTest1</text>
</name>
<page id="top">
<page id="sourcePage">
<referencePlace id="rp1" ref="channelInPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc2</location>
<subnet>loc2</subnet>
</toolspecific>
<name>
<text>rp1</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="20" y="20"/>
</graphics>
</referencePlace>
<place id="responsePlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc2</location>
<subnet>loc2</subnet>
</toolspecific>
<name>
<text>responsePlace</text>
<graphics>
<offset x="0" y="-10" />
</graphics>
</name>
<graphics>
<position x="635" y="90"/>
</graphics>
</place>
</page>
<page id="channelPage">
<place id="channelInPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc2</location>
<subnet>loc2</subnet>
</toolspecific>
<name>
<text>channelInPlace</text>
<graphics>
<offset x="0" y="-10" />
</graphics>
</name>
<graphics>
<position x="635" y="90"/>
</graphics>
</place>
<transition id="requestTransition">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>channel</location>
<subnet>channel</subnet>
<type>serviceTransitionTypeRequest</type>
<serviceName>sampleService</serviceName>
</toolspecific>
<name>
<text>requestTransition</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="285" y="205"/>
</graphics>
</transition>
<referencePlace id="rp2" ref="responseSourcePlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc3</location>
<subnet>loc3</subnet>
</toolspecific>
<name>
<text>rp2</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="20" y="20"/>
</graphics>
</referencePlace>
<place id="responseInPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc3</location>
<subnet>loc3</subnet>
</toolspecific>
<name>
<text>responseInPlace</text>
<graphics>
<offset x="0" y="-10" />
</graphics>
</name>
<graphics>
<position x="635" y="90"/>
</graphics>
</place>
<transition id="responseTransition">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>channel</location>
<subnet>channel</subnet>
<type>serviceTransitionTypeResponse</type>
<serviceName>sampleService</serviceName>
</toolspecific>
<name>
<text>responseTransition</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="285" y="205"/>
</graphics>
</transition>
<referencePlace id="rp4" ref="responsePlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc2</location>
<subnet>loc2</subnet>
</toolspecific>
<name>
<text>rp4</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="20" y="20"/>
</graphics>
</referencePlace>
<arc id="a1" source="channelInPlace" target="requestTransition">
</arc>
<arc id="a2" source="requestTransition" target="rp2">
</arc>
<arc id="a3" source="responseSourcePlace" target="responseTransition">
</arc>
<arc id="a4" source="responseTransition" target="rp4">
</arc>
</page>
<page id="targetPage">
<place id="responseSourcePlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc3</location>
<subnet>loc3</subnet>
</toolspecific>
<name>
<text>responseSourcePlace</text>
<graphics>
<offset x="0" y="-10" />
</graphics>
</name>
<graphics>
<position x="635" y="90"/>
</graphics>
</place>
<referencePlace id="rp3" ref="responseInPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc3</location>
<subnet>loc3</subnet>
</toolspecific>
<name>
<text>rp3</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="20" y="20"/>
</graphics>
</referencePlace>
</page>
</page>
</net>
</pnml>
\ No newline at end of file
<pnml xmlns="http://www.pnml.org/version-2009/grammar/pnml">
<net id="n-E2D0-BCF46-0" type ="http://www.pnml.org/version-2009/grammar/ptnet">
<name>
<text>topicTest1</text>
</name>
<page id="top">
<page id="sourcePage">
<referencePlace id="rp1" ref="channelInPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc2</location>
<subnet>loc2</subnet>
</toolspecific>
<name>
<text>rp1</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="20" y="20"/>
</graphics>
</referencePlace>
</page>
<page id="channelPage">
<place id="channelInPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc2</location>
<subnet>loc2</subnet>
</toolspecific>
<name>
<text>channelInPlace</text>
<graphics>
<offset x="0" y="-10" />
</graphics>
</name>
<graphics>
<position x="635" y="90"/>
</graphics>
</place>
<transition id="channelTransition">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>channel</location>
<subnet>channel</subnet>
<type>topicTransitionType</type>
<topic>sampleTopic</topic>
<inputlimit>10</inputlimit>
<outputlimit>10</outputlimit>
</toolspecific>
<name>
<text>channelTransition</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="285" y="205"/>
</graphics>
</transition>
<referencePlace id="rp2" ref="outRefPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc3</location>
<subnet>loc3</subnet>
</toolspecific>
<name>
<text>rp2</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="20" y="20"/>
</graphics>
</referencePlace>
<arc id="a1" source="channelInPlace" target="channelTransition">
</arc>
<arc id="a2" source="channelTransition" target="rp2">
</arc>
</page>
<page id="targetPage">
<place id="outRefPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc3</location>
<subnet>loc3</subnet>
</toolspecific>
<name>
<text>outRefPlace</text>
<graphics>
<offset x="0" y="-10" />
</graphics>
</name>
<graphics>
<position x="635" y="90"/>
</graphics>
</place>
</page>
</page>
</net>
</pnml>
\ No newline at end of file
<pnml xmlns="http://www.pnml.org/version-2009/grammar/pnml">
<net id="n-E2D0-BCF46-0" type ="http://www.pnml.org/version-2009/grammar/ptnet">
<name>
<text>topicTest1</text>
</name>
<page id="top">
<page id="sourcePage">
<referencePlace id="rp1" ref="channelInPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc2</location>
<subnet>loc2</subnet>
</toolspecific>
<name>
<text>rp1</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="20" y="20"/>
</graphics>
</referencePlace>
</page>
<page id="channelPage">
<place id="channelInPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc2</location>
<subnet>loc2</subnet>
</toolspecific>
<name>
<text>channelInPlace</text>
<graphics>
<offset x="0" y="-10" />
</graphics>
</name>
<graphics>
<position x="635" y="90"/>
</graphics>
</place>
<place id="channelInPlace2">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc2</location>
<subnet>loc2</subnet>
</toolspecific>
<name>
<text>channelInPlace2</text>
<graphics>
<offset x="0" y="-10" />
</graphics>
</name>
<graphics>
<position x="635" y="90"/>
</graphics>
</place>
<transition id="channelTransition">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>channel</location>
<subnet>channel</subnet>
<type>topicTransitionType</type>
<topic>sampleTopic</topic>
<inputlimit>10</inputlimit>
<outputlimit>10</outputlimit>
</toolspecific>
<name>
<text>channelTransition</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="285" y="205"/>
</graphics>
</transition>
<referencePlace id="rp2" ref="outRefPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc3</location>
<subnet>loc3</subnet>
</toolspecific>
<name>
<text>rp2</text>
<graphics>
<offset x="0" y="0" />
</graphics>
</name>
<graphics>
<position x="20" y="20"/>
</graphics>
</referencePlace>
<arc id="a1" source="channelInPlace" target="channelTransition">
</arc>
<arc id="a2" source="channelTransition" target="rp2">
</arc>
<arc id="a3" source="channelInPlace2" target="channelTransition">
</arc>
</page>
<page id="targetPage">
<place id="outRefPlace">
<toolspecific tool="de.tudresden.inf.st.pnml.distributedPN" version="0.1">
<location>loc3</location>
<subnet>loc3</subnet>
</toolspecific>
<name>
<text>outRefPlace</text>
<graphics>
<offset x="0" y="-10" />
</graphics>
</name>
<graphics>
<position x="635" y="90"/>
</graphics>
</place>
</page>
</page>
</net>
</pnml>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment