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

bugfixes on service instances

parent c83abc31
No related branches found
No related tags found
No related merge requests found
...@@ -323,7 +323,7 @@ public abstract class DiNeRosNode extends AbstractNodeMain { ...@@ -323,7 +323,7 @@ public abstract class DiNeRosNode extends AbstractNodeMain {
for (int i = 0; i < limit; i++) { for (int i = 0; i < limit; i++) {
System.out.println("[" + nodeName + "] Copying server page " + key + " (" + i + ")."); System.out.println("[" + nodeName + "] Copying server page " + key + " (" + i + ").");
Page copy = ServiceInstanceUtil.treeCopyWithoutArcs(p); Page copy = ServiceInstanceUtil.treeCopyWithoutArcs(petriNet, p);
ServiceInstanceUtil.updateInstanceIds(copy, "-INSTANCE-" + i); ServiceInstanceUtil.updateInstanceIds(copy, "-INSTANCE-" + i);
copy.setId(p.getId() + "-INSTANCE-" + i); copy.setId(p.getId() + "-INSTANCE-" + i);
copy.getName().setText(copy.getId()); copy.getName().setText(copy.getId());
......
...@@ -33,7 +33,8 @@ public class ServiceInstanceUtil { ...@@ -33,7 +33,8 @@ public class ServiceInstanceUtil {
for (Arc a : originalArcs) { for (Arc a : originalArcs) {
Page originalArcPage = Objects.requireNonNull(getObjectInPage(original, a.getId()))._2; Page originalArcPage = Objects.requireNonNull(getObjectInPage(original, a.getId()))._2;
Page arcPage = Objects.requireNonNull(getObjectInPage(copy, originalArcPage.getId() + suffix))._1.asPage(); Page arcPage = Objects.requireNonNull(getObjectInPage(copy,
originalArcPage.getId() + suffix))._1.asPage();
Pair<PnObject, Page> source = getObjectInPage(copy, a.getSource().getId() + suffix); Pair<PnObject, Page> source = getObjectInPage(copy, a.getSource().getId() + suffix);
Pair<PnObject, Page> target = getObjectInPage(copy, a.getTarget().getId() + suffix); Pair<PnObject, Page> target = getObjectInPage(copy, a.getTarget().getId() + suffix);
Arc copyArc = new Arc(); Arc copyArc = new Arc();
...@@ -85,11 +86,11 @@ public class ServiceInstanceUtil { ...@@ -85,11 +86,11 @@ public class ServiceInstanceUtil {
} }
} }
public static Page treeCopyWithoutArcs(Page currentPage) { public static Page treeCopyWithoutArcs(PetriNet petriNet, Page currentPage) {
return treeCopyWithoutArcsInternal(currentPage, null); return treeCopyWithoutArcsInternal(petriNet, currentPage, null);
} }
private static Page treeCopyWithoutArcsInternal(Page currentPage, Page parent) { private static Page treeCopyWithoutArcsInternal(PetriNet petriNet, Page currentPage, Page parent) {
Map<String, PnObject> rMap = new HashMap<>(); Map<String, PnObject> rMap = new HashMap<>();
...@@ -108,7 +109,7 @@ public class ServiceInstanceUtil { ...@@ -108,7 +109,7 @@ public class ServiceInstanceUtil {
copyPage.setName(pnObject.getName().treeCopy()); copyPage.setName(pnObject.getName().treeCopy());
parent.addObject(copyPage); parent.addObject(copyPage);
treeCopyWithoutArcsInternal(pnObject.asPage(), copyPage); treeCopyWithoutArcsInternal(petriNet, pnObject.asPage(), copyPage);
} }
if (pnObject.isPlaceObject()) { if (pnObject.isPlaceObject()) {
...@@ -132,24 +133,26 @@ public class ServiceInstanceUtil { ...@@ -132,24 +133,26 @@ public class ServiceInstanceUtil {
} }
for (PnObject pnObject : currentPage.getObjects()) { for (PnObject pnObject : currentPage.getObjects()) {
if (pnObject.isTransitionObject() &&
pnObject.asDinerosTransition().isRefTransition()) { Name n = new Name();
n.setText(pnObject.getId());
if (pnObject.isRefTransitionObject()) {
RefTransition copyRt = new RefTransition(); RefTransition copyRt = new RefTransition();
copyRt.setId(pnObject.getId()); copyRt.setId(pnObject.getId());
copyRt.setName(pnObject.getName().treeCopy()); copyRt.setName(n.treeCopy());
copyRt.setRef(rMap.get(pnObject.asDinerosTransition(). copyRt.setRef(Objects.requireNonNull(getReferencedObject(petriNet,
asRefTransition().getRef().getId()).asDinerosTransition()); rMap, pnObject.asRefTransitionObject().getRef().getId())).asDinerosTransition());
copyRt.setToolspecificList(pnObject.getToolspecificList().treeCopy()); copyRt.setToolspecificList(pnObject.getToolspecificList().treeCopy());
parent.addObject(copyRt); parent.addObject(copyRt);
} }
if (pnObject.isPlaceObject() && if (pnObject.isRefPlaceObject()) {
pnObject.asDinerosPlace().isRefPlace()) {
RefPlace copyRp = new RefPlace(); RefPlace copyRp = new RefPlace();
copyRp.setId(pnObject.getId()); copyRp.setId(pnObject.getId());
copyRp.setName(pnObject.getName().treeCopy()); copyRp.setName(n.treeCopy());
copyRp.setRef(rMap.get(pnObject.asDinerosPlace(). copyRp.setRef(Objects.requireNonNull(getReferencedObject(petriNet,
asRefPlace().getRef().getId()).asDinerosPlace()); rMap, pnObject.asRefPlaceObject().getRef().getId())).asDinerosPlace());
copyRp.setToolspecificList(pnObject.getToolspecificList().treeCopy()); copyRp.setToolspecificList(pnObject.getToolspecificList().treeCopy());
parent.addObject(copyRp); parent.addObject(copyRp);
} }
...@@ -158,70 +161,22 @@ public class ServiceInstanceUtil { ...@@ -158,70 +161,22 @@ public class ServiceInstanceUtil {
return parent; return parent;
} }
/*public static void updateArcs(Page page, String suffix){ private static PnObject getReferencedObject(PetriNet petriNet, Map<String, PnObject> rMap, String id){
for(PnObject pnObject : page.getObjects()){ PnObject referencedObject = rMap.get(id);
if(pnObject.isArcNode()){
for(PnObject pnObjectIn : page.getObjects()){
if((pnObjectIn.isPlaceObject() || pnObjectIn.isTransitionObject()) &&
pnObjectIn.getId()
.equals(pnObject.asArc().getSource().getId() + suffix)){
pnObject.asArc().setSource(pnObjectIn.asNode());
System.out.println("Updating Arc " + pnObject.getId() + " -> new Source: " + pnObjectIn.getId());
}
if((pnObjectIn.isPlaceObject() || pnObjectIn.isTransitionObject()) &&
pnObjectIn.getId()
.equals(pnObject.asArc().getTarget().getId() + suffix)){
pnObject.asArc().setTarget(pnObjectIn.asNode());
System.out.println("Updating Arc " + pnObject.getId() + " -> new Target: " + pnObjectIn.getId());
}
}
}
if(pnObject.isPageNode()){ if(referencedObject == null){
updateArcs(pnObject.asPage(), suffix); System.out.println("Searching for external referenced object: " + id);
} for(PnObject pnObject : petriNet.allObjects()){
} if(pnObject.getId().equals(id)){
}*/ System.out.println("Found external referenced object: " + id);
return pnObject;
/* public static void removeIllegalRefsToArcs(Page page, String suffix){
for(PnObject pnObject : page.getObjects()){
if(pnObject.isPlaceObject()){
for (int i = 0; i < pnObject.asDinerosPlace().getInArcs().size(); i++){
if(!pnObject.asDinerosPlace().getInArcs().get(i).getId().contains(suffix)){
System.out.println("Removing ref on " +
pnObject.asDinerosPlace().getInArcs().get(i).getId() + " on " + pnObject.getId());
pnObject.asDinerosPlace().getInArcs().get(i).removeSelf();
}
}
for (int i = 0; i < pnObject.asDinerosPlace().getOutArcs().size(); i++){
if(!pnObject.asDinerosPlace().getOutArcs().get(i).getId().contains(suffix)){
System.out.println("Removing ref on " +
pnObject.asDinerosPlace().getOutArcs().get(i).getId() + " on " + pnObject.getId());
pnObject.asDinerosPlace().getOutArcs().get(i).removeSelf();
} }
} }
} else {
return referencedObject;
} }
if(pnObject.isTransitionObject()){ return null;
for (int i = 0; i < pnObject.asDinerosTransition().getInArcs().size(); i++){
if(!pnObject.asDinerosTransition().getInArcs().get(i).getId().contains(suffix)){
System.out.println("Removing ref on " +
pnObject.asDinerosTransition().getInArcs().get(i).getId() + " on " + pnObject.getId());
pnObject.asDinerosTransition().getInArcs().get(i).removeSelf();
}
}
for (int i = 0; i < pnObject.asDinerosTransition().getOutArcList().size(); i++){
if(!pnObject.asDinerosTransition().getOutArcs().get(i).getId().contains(suffix)){
System.out.println("Removing ref on " +
pnObject.asDinerosTransition().getOutArcs().get(i).getId() + " on " + pnObject.getId());
pnObject.asDinerosTransition().getOutArcs().get(i).removeSelf();
}
}
}
} }
}*/
} }
\ 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