This commit is contained in:
Laurent Fainsin 2021-10-10 13:48:27 +02:00
parent 6d2aa4acff
commit 5cc2138a0b
104 changed files with 4178 additions and 1739 deletions

View file

@ -31,3 +31,43 @@ java.lang.InterruptedException
at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:207)
at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:220)
at java.base/java.lang.Thread.run(Thread.java:829)
!SESSION 2021-10-10 00:17:29.406 -----------------------------------------------
eclipse.buildId=4.17.0.I20200902-1800
java.version=11.0.11
java.vendor=Ubuntu
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=fr_FR
Framework arguments: -product org.eclipse.epp.package.modeling.product
Command-line arguments: -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.modeling.product
!ENTRY org.eclipse.emf.cdo.explorer 4 0 2021-10-10 00:27:51.311
!MESSAGE InterruptedException
!STACK 0
java.lang.InterruptedException
at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1343)
at java.base/java.util.concurrent.Semaphore.acquire(Semaphore.java:318)
at org.eclipse.net4j.util.lifecycle.Lifecycle.lock(Lifecycle.java:312)
at org.eclipse.net4j.util.lifecycle.Lifecycle.internalDeactivate(Lifecycle.java:118)
at org.eclipse.net4j.util.lifecycle.ShareableLifecycle.internalDeactivate(ShareableLifecycle.java:52)
at org.eclipse.net4j.util.lifecycle.Lifecycle.deactivate(Lifecycle.java:170)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.deactivate(LifecycleUtil.java:235)
at org.eclipse.net4j.util.lifecycle.LifecycleUtil.deactivate(LifecycleUtil.java:225)
at org.eclipse.emf.cdo.internal.explorer.bundle.OM.disposeManagers(OM.java:83)
at org.eclipse.emf.cdo.internal.explorer.bundle.OM$Activator.doStop(OM.java:136)
at org.eclipse.net4j.util.om.OSGiActivator.stop(OSGiActivator.java:92)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:871)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.internal.framework.BundleContextImpl.stop(BundleContextImpl.java:863)
at org.eclipse.osgi.internal.framework.EquinoxBundle.stopWorker0(EquinoxBundle.java:1025)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.stopWorker(EquinoxBundle.java:370)
at org.eclipse.osgi.container.Module.doStop(Module.java:660)
at org.eclipse.osgi.container.Module.stop(Module.java:521)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.decStartLevel(ModuleContainer.java:1886)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1761)
at org.eclipse.osgi.container.SystemModule.stopWorker(SystemModule.java:275)
at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule.stopWorker(EquinoxBundle.java:202)
at org.eclipse.osgi.container.Module.doStop(Module.java:660)
at org.eclipse.osgi.container.Module.stop(Module.java:521)
at org.eclipse.osgi.container.SystemModule.stop(SystemModule.java:207)
at org.eclipse.osgi.internal.framework.EquinoxBundle$SystemBundle$EquinoxSystemModule$1.run(EquinoxBundle.java:220)
at java.base/java.lang.Thread.run(Thread.java:829)

View file

@ -0,0 +1,187 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.Node;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place started = myFactory.createPlace();
started.setName(name + "_started");
started.setTokens(0);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(0);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(0);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Arc start2started = myFactory.createArc();
start2started.setTarget(started);
start2started.setOutgoing(true);
start2started.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
start.getArcs().add(start2started);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(started);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Conversion des WorkSequence en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkSequence) {
WorkSequence ws = (WorkSequence) o;
WorkSequenceType type = ws.getLinkType();
WorkDefinition predecessor = ws.getPredecessor();
WorkDefinition successor = ws.getSuccessor();
Arc arc = myFactory.createArc();
arc.setOutgoing(false);
String predecessor_suffix = new String();
String successor_suffix = new String();
switch (type) {
case START_TO_START:
predecessor_suffix = "_started";
successor_suffix = "_start";
break;
case START_TO_FINISH:
predecessor_suffix = "_started";
successor_suffix = "_finished";
break;
case FINISH_TO_START:
predecessor_suffix = "_finished";
successor_suffix = "_start";
break;
case FINISH_TO_FINISH:
predecessor_suffix = "_finished";
successor_suffix = "_finish";
break;
default:
System.out.print("the fuck ?");
break;
}
for (Node node : network.getNodes()) {
if (node instanceof Place) {
Place place = (Place) node;
if (place.getName().equals(predecessor.getName() + predecessor_suffix)) {
arc.setTarget(place);
}
}
if (node instanceof Transition) {
Transition transition = (Transition) node;
if (transition.getName().equals(successor.getName() + successor_suffix)) {
transition.getArcs().add(arc);
}
}
}
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/test.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,193 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.Node;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place started = myFactory.createPlace();
started.setName(name + "_started");
started.setTokens(0);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(0);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(0);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Arc start2started = myFactory.createArc();
start2started.setTarget(started);
start2started.setOutgoing(true);
start2started.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
start.getArcs().add(start2started);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(started);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Conversion des WorkSequence en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkSequence) {
WorkSequence ws = (WorkSequence) o;
WorkSequenceType type = ws.getLinkType();
WorkDefinition predecessor = ws.getPredecessor();
WorkDefinition successor = ws.getSuccessor();
System.out.println(predecessor.getName());
// creation des suffixs permettant la recherche des noeuds
String predecessor_suffix = new String();
String successor_suffix = new String();
switch (type) {
case START_TO_START:
predecessor_suffix = "_started";
successor_suffix = "_start";
break;
case START_TO_FINISH:
predecessor_suffix = "_started";
successor_suffix = "_finished";
break;
case FINISH_TO_START:
predecessor_suffix = "_finished";
successor_suffix = "_start";
break;
case FINISH_TO_FINISH:
predecessor_suffix = "_finished";
successor_suffix = "_finish";
break;
default:
System.out.print("the fuck ?");
break;
}
// creation du read-arc
Arc arc1 = myFactory.createArc();
arc1.setOutgoing(false);
arc1.setWeight(1);
Arc arc2 = myFactory.createArc();
arc2.setOutgoing(true);
arc2.setWeight(1);
for (Node node : network.getNodes()) {
if (node instanceof Place) {
Place place = (Place) node;
if (place.getName().equals(predecessor.getName() + predecessor_suffix)) {
arc1.setTarget(place);
arc2.setTarget(place);
}
}
if (node instanceof Transition) {
Transition transition = (Transition) node;
if (transition.getName().equals(successor.getName() + successor_suffix)) {
transition.getArcs().add(arc1);
transition.getArcs().add(arc2);
}
}
}
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/Developpement_petrinet.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,194 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.Node;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place started = myFactory.createPlace();
started.setName(name + "_started");
started.setTokens(0);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(0);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(0);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Arc start2started = myFactory.createArc();
start2started.setTarget(started);
start2started.setOutgoing(true);
start2started.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
start.getArcs().add(start2started);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(started);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Conversion des WorkSequence en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkSequence) {
WorkSequence ws = (WorkSequence) o;
WorkSequenceType type = ws.getLinkType();
WorkDefinition predecessor = ws.getPredecessor();
WorkDefinition successor = ws.getSuccessor();
// creation des suffixs permettant la recherche des noeuds
String predecessor_suffix = new String();
String successor_suffix = new String();
switch (type) {
case START_TO_START:
predecessor_suffix = "_started";
successor_suffix = "_start";
break;
case START_TO_FINISH:
predecessor_suffix = "_started";
successor_suffix = "_finished";
break;
case FINISH_TO_START:
predecessor_suffix = "_finished";
successor_suffix = "_start";
break;
case FINISH_TO_FINISH:
predecessor_suffix = "_finished";
successor_suffix = "_finish";
break;
default:
System.out.print("the fuck ?");
break;
}
// creation du read-arc
Arc arc1 = myFactory.createArc();
arc1.setOutgoing(false);
arc1.setWeight(1);
Arc arc2 = myFactory.createArc();
arc2.setOutgoing(true);
arc2.setWeight(1);
for (Node node : network.getNodes()) {
if (node instanceof Place) {
Place place = (Place) node;
if (place.getName().equals(predecessor.getName() + predecessor_suffix)) {
arc1.setTarget(place);
arc2.setTarget(place);
}
}
if (node instanceof Transition) {
Transition transition = (Transition) node;
if (transition.getName().equals(successor.getName() + successor_suffix)) {
transition.getArcs().add(arc1);
transition.getArcs().add(arc2);
}
}
}
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/test.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,130 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place started = myFactory.createPlace();
started.setName(name + "_started");
started.setTokens(0);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(0);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(0);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Arc start2started = myFactory.createArc();
start2started.setTarget(started);
start2started.setOutgoing(true);
start2started.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
start.getArcs().add(start2started);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(started);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/test.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,192 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.Node;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place started = myFactory.createPlace();
started.setName(name + "_started");
started.setTokens(0);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(0);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(0);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Arc start2started = myFactory.createArc();
start2started.setTarget(started);
start2started.setOutgoing(true);
start2started.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
start.getArcs().add(start2started);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(started);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Conversion des WorkSequence en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkSequence) {
WorkSequence ws = (WorkSequence) o;
WorkSequenceType type = ws.getLinkType();
WorkDefinition predecessor = ws.getPredecessor();
WorkDefinition successor = ws.getSuccessor();
String predecessor_suffix = new String();
String successor_suffix = new String();
switch (type) {
case START_TO_START:
predecessor_suffix = "_started";
successor_suffix = "_start";
break;
case START_TO_FINISH:
predecessor_suffix = "_started";
successor_suffix = "_finished";
break;
case FINISH_TO_START:
predecessor_suffix = "_finished";
successor_suffix = "_start";
break;
case FINISH_TO_FINISH:
predecessor_suffix = "_finished";
successor_suffix = "_finish";
break;
default:
System.out.print("the fuck ?");
break;
}
Arc arc1 = myFactory.createArc();
arc1.setOutgoing(false);
arc1.setWeight(1);
Arc arc2 = myFactory.createArc();
arc2.setOutgoing(true);
arc2.setWeight(1);
for (Node node : network.getNodes()) {
if (node instanceof Place) {
Place place = (Place) node;
if (place.getName().equals(predecessor.getName() + predecessor_suffix)) {
arc1.setTarget(place);
arc2.setTarget(place);
}
}
if (node instanceof Transition) {
Transition transition = (Transition) node;
if (transition.getName().equals(successor.getName() + successor_suffix)) {
transition.getArcs().add(arc1);
transition.getArcs().add(arc2);
}
}
}
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/test.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,127 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
System.out.println(" - " + name);
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place started = myFactory.createPlace();
idle.setName(name + "_started");
idle.setTokens(0);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(0);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(0);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
System.out.println(" + " + idle.getName() + " (" + idle.getTokens() + ")");
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/test.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,190 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.Node;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place started = myFactory.createPlace();
started.setName(name + "_started");
started.setTokens(0);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(0);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(0);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Arc start2started = myFactory.createArc();
start2started.setTarget(started);
start2started.setOutgoing(true);
start2started.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
start.getArcs().add(start2started);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(started);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Conversion des WorkSequence en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkSequence) {
WorkSequence ws = (WorkSequence) o;
WorkSequenceType type = ws.getLinkType();
WorkDefinition predecessor = ws.getPredecessor();
WorkDefinition successor = ws.getSuccessor();
String predecessor_suffix = new String();
String successor_suffix = new String();
switch (type) {
case START_TO_START:
predecessor_suffix = "_started";
successor_suffix = "_start";
break;
case START_TO_FINISH:
predecessor_suffix = "_started";
successor_suffix = "_finished";
break;
case FINISH_TO_START:
predecessor_suffix = "_finished";
successor_suffix = "_start";
break;
case FINISH_TO_FINISH:
predecessor_suffix = "_finished";
successor_suffix = "_finish";
break;
default:
System.out.print("the fuck ?");
break;
}
Arc arc1 = myFactory.createArc();
arc1.setOutgoing(false);
arc1.setWeight(1);
Arc arc2 = myFactory.createArc();
arc2.setOutgoing(true);
arc2.setWeight(2);
for (Node node : network.getNodes()) {
if (node instanceof Place) {
Place place = (Place) node;
if (place.getName().equals(predecessor.getName() + predecessor_suffix)) {
arc.setTarget(place);
}
}
if (node instanceof Transition) {
Transition transition = (Transition) node;
if (transition.getName().equals(successor.getName() + successor_suffix)) {
transition.getArcs().add(arc);
}
}
}
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/test.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,44 @@
[comment encoding = UTF-8 /]
[module toTINA('http://petrinet')]
[template public networkToTINA(aNetwork : Network)]
[comment @main/]
[file (aNetwork.name + '.net', false, 'UTF-8')]
net [aNetwork.name/]
[let places : OrderedSet(Place) = aNetwork.getPlaces() ]
[if (places->size() > 0)]
[for (place : Place | places)]
pl [place.name/] ([place.tokens/])
[/for]
[else]
[/if]
[/let]
[let transitions : OrderedSet(Transition) = aNetwork.getTransitions() ]
[if (transitions->size() > 0)]
[for (transition : Transition | transitions)]
[transition.afficher()/]
[/for]
[else]
[/if]
[/let]
[/file]
[/template]
[query public getPlaces(n: Network) : OrderedSet(Place) =
n.nodes
->select( e | e.oclIsTypeOf(Place) )
->collect( e | e.oclAsType(Place) )
->asOrderedSet()
/]
[query public getTransitions(n: Network) : OrderedSet(Transition) =
n.nodes
->select( e | e.oclIsTypeOf(Transition) )
->collect( e | e.oclAsType(Transition) )
->asOrderedSet()
/]
[template public afficher(t : Transition) post (trim()) ]
[comment][let outgoing = t.getArcs()->select( e | e.isOutgoing() ) /][/comment]
tr [t.name/] [for (a : Arc | t.arcs)][if (not a.outgoing)][a.target.name/]*[a.weight/] [/if][/for]-> [for (a : Arc | t.arcs)][if (a.outgoing)][a.target.name/]*[a.weight/][/if][/for]
[/template]

View file

@ -0,0 +1,124 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
System.out.println(" - " + name);
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(1);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(1);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
System.out.println(" + " + idle.getName() + " (" + idle.getTokens() + ")");
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/test.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,191 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.Node;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place started = myFactory.createPlace();
started.setName(name + "_started");
started.setTokens(0);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(0);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(0);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Arc start2started = myFactory.createArc();
start2started.setTarget(started);
start2started.setOutgoing(true);
start2started.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
start.getArcs().add(start2started);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(started);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Conversion des WorkSequence en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkSequence) {
WorkSequence ws = (WorkSequence) o;
WorkSequenceType type = ws.getLinkType();
WorkDefinition predecessor = ws.getPredecessor();
WorkDefinition successor = ws.getSuccessor();
String predecessor_suffix = new String();
String successor_suffix = new String();
switch (type) {
case START_TO_START:
predecessor_suffix = "_started";
successor_suffix = "_start";
break;
case START_TO_FINISH:
predecessor_suffix = "_started";
successor_suffix = "_finished";
break;
case FINISH_TO_START:
predecessor_suffix = "_finished";
successor_suffix = "_start";
break;
case FINISH_TO_FINISH:
predecessor_suffix = "_finished";
successor_suffix = "_finish";
break;
default:
System.out.print("the fuck ?");
break;
}
Arc arc1 = myFactory.createArc();
arc1.setOutgoing(false);
arc1.setWeight(1);
Arc arc2 = myFactory.createArc();
arc2.setOutgoing(true);
arc2.setWeight(1);
for (Node node : network.getNodes()) {
if (node instanceof Place) {
Place place = (Place) node;
if (place.getName().equals(predecessor.getName() + predecessor_suffix)) {
arc1.setTarget(place);
arc2.setTarget(place);
}
}
if (node instanceof Transition) {
Transition transition = (Transition) node;
if (transition.getName().equals(successor.getName() + successor_suffix)) {
transition.getArcs().add(arc1);
}
}
}
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/test.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,193 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.Node;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place started = myFactory.createPlace();
started.setName(name + "_started");
started.setTokens(0);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(0);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(0);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Arc start2started = myFactory.createArc();
start2started.setTarget(started);
start2started.setOutgoing(true);
start2started.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
start.getArcs().add(start2started);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(started);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Conversion des WorkSequence en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkSequence) {
WorkSequence ws = (WorkSequence) o;
WorkSequenceType type = ws.getLinkType();
WorkDefinition predecessor = ws.getPredecessor();
WorkDefinition successor = ws.getSuccessor();
System.out.println(predecessor.getName());
// creation des suffixs permettant la recherche des noeuds
String predecessor_suffix = new String();
String successor_suffix = new String();
switch (type) {
case START_TO_START:
predecessor_suffix = "_started";
successor_suffix = "_start";
break;
case START_TO_FINISH:
predecessor_suffix = "_started";
successor_suffix = "_finished";
break;
case FINISH_TO_START:
predecessor_suffix = "_finished";
successor_suffix = "_start";
break;
case FINISH_TO_FINISH:
predecessor_suffix = "_finished";
successor_suffix = "_finish";
break;
default:
System.out.print("the fuck ?");
break;
}
// creation du read-arc
Arc arc1 = myFactory.createArc();
arc1.setOutgoing(false);
arc1.setWeight(1);
Arc arc2 = myFactory.createArc();
arc2.setOutgoing(true);
arc2.setWeight(1);
for (Node node : network.getNodes()) {
if (node instanceof Place) {
Place place = (Place) node;
if (place.getName().equals(predecessor.getName() + predecessor_suffix)) {
arc1.setTarget(place);
arc2.setTarget(place);
}
}
if (node instanceof Transition) {
Transition transition = (Transition) node;
if (transition.getName().equals(successor.getName() + successor_suffix)) {
transition.getArcs().add(arc1);
transition.getArcs().add(arc2);
}
}
}
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/test.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,133 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
System.out.println(" - " + name);
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place started = myFactory.createPlace();
started.setName(name + "_started");
started.setTokens(0);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(0);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(0);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Arc start2started = myFactory.createArc();
start2started.setTarget(started);
start2started.setOutgoing(true);
start2started.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
start.getArcs().add(start2started);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
System.out.println(" + " + idle.getName() + " (" + idle.getTokens() + ")");
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(started);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/test.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -3,45 +3,63 @@
<nodes xsi:type="petrinet:Place" name="Conception_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="Conception_start">
<arcs weight="1" target="//@nodes.0"/>
<arcs weight="1" outgoing="true" target="//@nodes.3"/>
<arcs weight="1" outgoing="true" target="//@nodes.2"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Conception_running" tokens="1"/>
<nodes xsi:type="petrinet:Place" name="Conception_started"/>
<nodes xsi:type="petrinet:Place" name="Conception_running"/>
<nodes xsi:type="petrinet:Transition" name="Conception_finish">
<arcs weight="1" target="//@nodes.2"/>
<arcs weight="1" outgoing="true" target="//@nodes.4"/>
<arcs weight="1" target="//@nodes.3"/>
<arcs weight="1" outgoing="true" target="//@nodes.5"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Conception_finished" tokens="1"/>
<nodes xsi:type="petrinet:Place" name="Conception_finished"/>
<nodes xsi:type="petrinet:Place" name="Programmation_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="Programmation_start">
<arcs weight="1" target="//@nodes.5"/>
<arcs weight="1" outgoing="true" target="//@nodes.7"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Programmation_running" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="Programmation_finish">
<arcs weight="1" target="//@nodes.7"/>
<arcs weight="1" target="//@nodes.6"/>
<arcs weight="1" outgoing="true" target="//@nodes.9"/>
<arcs weight="1" outgoing="true" target="//@nodes.8"/>
<arcs weight="1" target="//@nodes.5"/>
<arcs weight="1" outgoing="true" target="//@nodes.5"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Programmation_finished" tokens="1"/>
<nodes xsi:type="petrinet:Place" name="Programmation_started"/>
<nodes xsi:type="petrinet:Place" name="Programmation_running"/>
<nodes xsi:type="petrinet:Transition" name="Programmation_finish">
<arcs weight="1" target="//@nodes.9"/>
<arcs weight="1" outgoing="true" target="//@nodes.11"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Programmation_finished"/>
<nodes xsi:type="petrinet:Place" name="RedactionTests_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="RedactionTests_start">
<arcs weight="1" target="//@nodes.10"/>
<arcs weight="1" outgoing="true" target="//@nodes.12"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionTests_running" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="RedactionTests_finish">
<arcs weight="1" target="//@nodes.12"/>
<arcs weight="1" outgoing="true" target="//@nodes.15"/>
<arcs weight="1" outgoing="true" target="//@nodes.14"/>
<arcs weight="1" target="//@nodes.2"/>
<arcs weight="1" outgoing="true" target="//@nodes.2"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionTests_finished" tokens="1"/>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="RedactionDocs_start">
<nodes xsi:type="petrinet:Place" name="RedactionTests_started"/>
<nodes xsi:type="petrinet:Place" name="RedactionTests_running"/>
<nodes xsi:type="petrinet:Transition" name="RedactionTests_finish">
<arcs weight="1" target="//@nodes.15"/>
<arcs weight="1" outgoing="true" target="//@nodes.17"/>
<arcs weight="1" target="//@nodes.11"/>
<arcs weight="1" outgoing="true" target="//@nodes.11"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_running" tokens="1"/>
<nodes xsi:type="petrinet:Place" name="RedactionTests_finished"/>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="RedactionDocs_start">
<arcs weight="1" target="//@nodes.18"/>
<arcs weight="1" outgoing="true" target="//@nodes.21"/>
<arcs weight="1" outgoing="true" target="//@nodes.20"/>
<arcs weight="1" target="//@nodes.2"/>
<arcs weight="1" outgoing="true" target="//@nodes.2"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_started"/>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_running"/>
<nodes xsi:type="petrinet:Transition" name="RedactionDocs_finish">
<arcs weight="1" target="//@nodes.17"/>
<arcs weight="1" outgoing="true" target="//@nodes.19"/>
<arcs weight="1" target="//@nodes.21"/>
<arcs weight="1" outgoing="true" target="//@nodes.23"/>
<arcs weight="1" target="//@nodes.5"/>
<arcs weight="1" outgoing="true" target="//@nodes.5"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_finished" tokens="1"/>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_finished"/>
</petrinet:Network>

View file

@ -0,0 +1,191 @@
package simplepdl.manip;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import petrinet.PetrinetPackage;
import petrinet.Place;
import petrinet.Transition;
import petrinet.Arc;
import petrinet.Network;
import petrinet.Node;
import petrinet.PetrinetFactory;
import simplepdl.Process;
import simplepdl.WorkDefinition;
import simplepdl.WorkSequence;
import simplepdl.WorkSequenceType;
import simplepdl.SimplepdlPackage;
public class simplepdl2petrinet {
public static void main(String[] args) {
// Charger les package SimplePDL et Petrinet afin de les enregistrer dans le registre d'Eclipse.
SimplepdlPackage packageInstance = SimplepdlPackage.eINSTANCE;
PetrinetPackage packageInstance2 = PetrinetPackage.eINSTANCE;
// Enregistrer l'extension ".xmi" comme devant être ouverte à
// l'aide d'un objet "XMIResourceFactoryImpl"
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("xmi", new XMIResourceFactoryImpl());
// Créer un objet resourceSetImpl qui contiendra une ressource EMF (le modèle)
ResourceSet resSet = new ResourceSetImpl();
// Charger la ressource (notre modèle)
URI modelURI = URI.createURI("pdl-sujet.xmi");
Resource resource = resSet.getResource(modelURI, true);
// Récupérer le premier élément du modèle (élément racine)
Process process = (Process) resource.getContents().get(0);
// La fabrique pour fabriquer les éléments de PetriNET
PetrinetFactory myFactory = PetrinetFactory.eINSTANCE;
// Créer un élément Network
Network network = myFactory.createNetwork();
network.setName(process.getName());
// Conversion des WorkDefinition en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkDefinition) {
WorkDefinition wd = (WorkDefinition) o;
String name = wd.getName();
Place idle = myFactory.createPlace();
idle.setName(name + "_idle");
idle.setTokens(1);
Place started = myFactory.createPlace();
started.setName(name + "_started");
started.setTokens(0);
Place running = myFactory.createPlace();
running.setName(name + "_running");
running.setTokens(0);
Place finished = myFactory.createPlace();
finished.setName(name + "_finished");
finished.setTokens(0);
Arc pause2start = myFactory.createArc();
pause2start.setTarget(idle);
pause2start.setOutgoing(false);
pause2start.setWeight(1);
Arc start2running = myFactory.createArc();
start2running.setTarget(running);
start2running.setOutgoing(true);
start2running.setWeight(1);
Arc start2started = myFactory.createArc();
start2started.setTarget(started);
start2started.setOutgoing(true);
start2started.setWeight(1);
Transition start = myFactory.createTransition();
start.setName(name + "_start");
start.getArcs().add(pause2start);
start.getArcs().add(start2running);
start.getArcs().add(start2started);
Arc running2finish = myFactory.createArc();
running2finish.setTarget(running);
running2finish.setOutgoing(false);
running2finish.setWeight(1);
Arc finish2finished = myFactory.createArc();
finish2finished.setTarget(finished);
finish2finished.setOutgoing(true);
finish2finished.setWeight(1);
Transition finish = myFactory.createTransition();
finish.setName(name + "_finish");
finish.getArcs().add(running2finish);
finish.getArcs().add(finish2finished);
network.getNodes().add(idle);
network.getNodes().add(start);
network.getNodes().add(started);
network.getNodes().add(running);
network.getNodes().add(finish);
network.getNodes().add(finished);
}
}
// Conversion des WorkSequence en Node et Transition
for (Object o : process.getProcessElements()) {
if (o instanceof WorkSequence) {
WorkSequence ws = (WorkSequence) o;
WorkSequenceType type = ws.getLinkType();
WorkDefinition predecessor = ws.getPredecessor();
WorkDefinition successor = ws.getSuccessor();
// creation des suffixs permettant la recherche des noeuds
String predecessor_suffix = new String();
String successor_suffix = new String();
switch (type) {
case START_TO_START:
predecessor_suffix = "_started";
successor_suffix = "_start";
break;
case START_TO_FINISH:
predecessor_suffix = "_started";
successor_suffix = "_finished";
break;
case FINISH_TO_START:
predecessor_suffix = "_finished";
successor_suffix = "_start";
break;
case FINISH_TO_FINISH:
predecessor_suffix = "_finished";
successor_suffix = "_finish";
break;
default:
System.out.print("the fuck ?");
break;
}
// creation du read-arc
Arc arc1 = myFactory.createArc();
arc1.setOutgoing(false);
arc1.setWeight(1);
Arc arc2 = myFactory.createArc();
arc2.setOutgoing(true);
arc2.setWeight(1);
for (Node node : network.getNodes()) {
if (node instanceof Place) {
Place place = (Place) node;
if (place.getName().equals(predecessor.getName() + predecessor_suffix)) {
arc1.setTarget(place);
arc2.setTarget(place);
}
}
if (node instanceof Transition) {
Transition transition = (Transition) node;
if (transition.getName().equals(successor.getName() + successor_suffix)) {
transition.getArcs().add(arc1);
transition.getArcs().add(arc2);
}
}
}
}
}
// Créer le nouveau xmi (modèle convertit)
URI convURI = URI.createURI("models/test.xmi");
Resource conv = resSet.createResource(convURI);
// Ajouter le Network dans le nouveau modèle
conv.getContents().add(network);
// Sauver la ressource
try {
conv.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="ASCII"?>
<petrinet:Network xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:petrinet="http://petrinet" name="Developpement">
<nodes xsi:type="petrinet:Place" name="Conception_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="Conception_start">
<arcs weight="1" target="//@nodes.0"/>
<arcs weight="1" outgoing="true" target="//@nodes.3"/>
<arcs weight="1" outgoing="true" target="//@nodes.2"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Conception_started"/>
<nodes xsi:type="petrinet:Place" name="Conception_running"/>
<nodes xsi:type="petrinet:Transition" name="Conception_finish">
<arcs weight="1" target="//@nodes.3"/>
<arcs weight="1" outgoing="true" target="//@nodes.5"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Conception_finished"/>
<nodes xsi:type="petrinet:Place" name="Programmation_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="Programmation_start">
<arcs weight="1" target="//@nodes.6"/>
<arcs weight="1" outgoing="true" target="//@nodes.9"/>
<arcs weight="1" outgoing="true" target="//@nodes.8"/>
<arcs weight="1" target="//@nodes.5"/>
<arcs weight="1" outgoing="true" target="//@nodes.5"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Programmation_started"/>
<nodes xsi:type="petrinet:Place" name="Programmation_running"/>
<nodes xsi:type="petrinet:Transition" name="Programmation_finish">
<arcs weight="1" target="//@nodes.9"/>
<arcs weight="1" outgoing="true" target="//@nodes.11"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Programmation_finished"/>
<nodes xsi:type="petrinet:Place" name="RedactionTests_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="RedactionTests_start">
<arcs weight="1" target="//@nodes.12"/>
<arcs weight="1" outgoing="true" target="//@nodes.15"/>
<arcs weight="1" outgoing="true" target="//@nodes.14"/>
<arcs weight="1" target="//@nodes.2"/>
<arcs weight="1" outgoing="true" target="//@nodes.2"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionTests_started"/>
<nodes xsi:type="petrinet:Place" name="RedactionTests_running"/>
<nodes xsi:type="petrinet:Transition" name="RedactionTests_finish">
<arcs weight="1" target="//@nodes.15"/>
<arcs weight="1" outgoing="true" target="//@nodes.17"/>
<arcs weight="1" target="//@nodes.11"/>
<arcs weight="1" outgoing="true" target="//@nodes.11"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionTests_finished"/>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="RedactionDocs_start">
<arcs weight="1" target="//@nodes.18"/>
<arcs weight="1" outgoing="true" target="//@nodes.21"/>
<arcs weight="1" outgoing="true" target="//@nodes.20"/>
<arcs weight="1" target="//@nodes.2"/>
<arcs weight="1" outgoing="true" target="//@nodes.2"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_started"/>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_running"/>
<nodes xsi:type="petrinet:Transition" name="RedactionDocs_finish">
<arcs weight="1" target="//@nodes.21"/>
<arcs weight="1" outgoing="true" target="//@nodes.23"/>
<arcs weight="1" target="//@nodes.5"/>
<arcs weight="1" outgoing="true" target="//@nodes.5"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_finished"/>
</petrinet:Network>

View file

@ -1,5 +1,5 @@
PROBLEMS_FILTERS_MIGRATE=true
eclipse.preferences.version=1
platformState=1631777710672
platformState=1631777710673
quickStart=false
tipsAndTricks=true

View file

@ -7,7 +7,8 @@
<listEntry value="1"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_EXCLUDE_TEST_CODE" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="simplepdl.manip.simplepdl2petrinet"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="fr.n7.simplepdl"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="fr.n7.simplepdl"/>
</launchConfiguration>

View file

@ -4,7 +4,7 @@
<booleanAttribute key="org.eclipse.acceleo.ide.ui.COMPUTE_PROFILING" value="false"/>
<booleanAttribute key="org.eclipse.acceleo.ide.ui.COMPUTE_TRACEABILITY" value="false"/>
<stringAttribute key="org.eclipse.acceleo.ide.ui.LAUNCHING_STRATEGY_DESCRIPTION" value="Java Application"/>
<stringAttribute key="org.eclipse.acceleo.ide.ui.MODEL_PATH" value="/fr.n7.petrinet.exemples/net.xmi"/>
<stringAttribute key="org.eclipse.acceleo.ide.ui.MODEL_PATH" value="/fr.n7.petrinet.exemples/Developpement_petrinet.xmi"/>
<stringAttribute key="org.eclipse.acceleo.ide.ui.TARGET_PATH" value="/fr.n7.petrinet.exemples/gen"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/fr.n7.petrinet.toTINA/src/fr/n7/petrinet/toTINA/main/ToTINA.java"/>
@ -17,6 +17,6 @@
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="fr.n7.petrinet.toTINA.main.ToTINA"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="fr.n7.petrinet.toTINA"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="&quot;/home/lfainsin/miniproj_idm/eclipse-workspace/fr.n7.petrinet.exemples/net.xmi&quot; &quot;/home/lfainsin/miniproj_idm/eclipse-workspace/fr.n7.petrinet.exemples/gen&quot;"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="&quot;/home/lfainsin/miniproj_idm/eclipse-workspace/fr.n7.petrinet.exemples/Developpement_petrinet.xmi&quot; &quot;/home/lfainsin/miniproj_idm/eclipse-workspace/fr.n7.petrinet.exemples/gen&quot;"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="fr.n7.petrinet.toTINA"/>
</launchConfiguration>

View file

@ -2,8 +2,8 @@
<launchHistory>
<launchGroup id="org.eclipse.debug.ui.launchGroup.debug">
<mruHistory>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;simplepdl2petrinet&quot;/&gt;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;toTINA&quot;/&gt;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;simplepdl2petrinet&quot;/&gt;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;ToDOT&quot;/&gt;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;toHTML&quot;/&gt;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;SimplePDLCreator&quot;/&gt;&#10;"/>
@ -24,8 +24,8 @@
</launchGroup>
<launchGroup id="org.eclipse.debug.ui.launchGroup.run">
<mruHistory>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;simplepdl2petrinet&quot;/&gt;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;toTINA&quot;/&gt;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;simplepdl2petrinet&quot;/&gt;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;ToDOT&quot;/&gt;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;toHTML&quot;/&gt;&#10;"/>
<launch memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;launchConfiguration local=&quot;true&quot; path=&quot;SimplePDLCreator&quot;/&gt;&#10;"/>

File diff suppressed because one or more lines are too long

View file

@ -22,13 +22,13 @@ INDEX VERSION 1.131+/home/lfainsin/miniproj_idm/eclipse-workspace/.metadata/.plu
2320756977.index
3761123150.index
649822626.index
1610757853.index
3144173601.index
3144547538.index
638382064.index
1366149182.index
2662280364.index
3977823992.index
686276266.index
1027991553.index
2344539973.index
997444292.index

Binary file not shown.

Before

Width:  |  Height:  |  Size: 715 B

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 B

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 493 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 411 B

View file

@ -13,3 +13,6 @@
1633794227791 Delete element
1633817925558 Move file
1633818171927 Delete element
1633865744611 Delete element
1633865919357 Delete element
1633865970104 Copy file

View file

@ -1,2 +1,2 @@
#Cached timestamps
#Sun Oct 10 00:17:26 CEST 2021
#Sun Oct 10 00:27:50 CEST 2021

View file

@ -1,4 +1,4 @@
# List of external plug-in models previously loaded. Timestamp: 1633817862111
# List of external plug-in models previously loaded. Timestamp: 1633863537523
file:/mnt/n7fs/ens/tp_cregut/eclipse-gls-2020-09/plugins/com.google.guava_27.1.0.v20190517-1946.jar
file:/mnt/n7fs/ens/tp_cregut/eclipse-gls-2020-09/plugins/com.google.inject_3.0.0.v201605172100.jar
file:/mnt/n7fs/ens/tp_cregut/eclipse-gls-2020-09/plugins/com.ibm.icu_67.1.0.v20200706-1749.jar

View file

@ -1,3 +1,3 @@
#Sun Oct 10 00:17:33 CEST 2021
#Sun Oct 10 12:58:52 CEST 2021
org.eclipse.core.runtime=2
org.eclipse.platform=4.17.0.v20200902-1800

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="ASCII"?>
<petrinet:Network xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:petrinet="http://petrinet" name="Developpement">
<nodes xsi:type="petrinet:Place" name="Conception_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="Conception_start">
<arcs weight="1" target="//@nodes.0"/>
<arcs weight="1" outgoing="true" target="//@nodes.3"/>
<arcs weight="1" outgoing="true" target="//@nodes.2"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Conception_started"/>
<nodes xsi:type="petrinet:Place" name="Conception_running"/>
<nodes xsi:type="petrinet:Transition" name="Conception_finish">
<arcs weight="1" target="//@nodes.3"/>
<arcs weight="1" outgoing="true" target="//@nodes.5"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Conception_finished"/>
<nodes xsi:type="petrinet:Place" name="Programmation_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="Programmation_start">
<arcs weight="1" target="//@nodes.6"/>
<arcs weight="1" outgoing="true" target="//@nodes.9"/>
<arcs weight="1" outgoing="true" target="//@nodes.8"/>
<arcs weight="1" target="//@nodes.5"/>
<arcs weight="1" outgoing="true" target="//@nodes.5"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Programmation_started"/>
<nodes xsi:type="petrinet:Place" name="Programmation_running"/>
<nodes xsi:type="petrinet:Transition" name="Programmation_finish">
<arcs weight="1" target="//@nodes.9"/>
<arcs weight="1" outgoing="true" target="//@nodes.11"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="Programmation_finished"/>
<nodes xsi:type="petrinet:Place" name="RedactionTests_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="RedactionTests_start">
<arcs weight="1" target="//@nodes.12"/>
<arcs weight="1" outgoing="true" target="//@nodes.15"/>
<arcs weight="1" outgoing="true" target="//@nodes.14"/>
<arcs weight="1" target="//@nodes.2"/>
<arcs weight="1" outgoing="true" target="//@nodes.2"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionTests_started"/>
<nodes xsi:type="petrinet:Place" name="RedactionTests_running"/>
<nodes xsi:type="petrinet:Transition" name="RedactionTests_finish">
<arcs weight="1" target="//@nodes.15"/>
<arcs weight="1" outgoing="true" target="//@nodes.17"/>
<arcs weight="1" target="//@nodes.11"/>
<arcs weight="1" outgoing="true" target="//@nodes.11"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionTests_finished"/>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_idle" tokens="1"/>
<nodes xsi:type="petrinet:Transition" name="RedactionDocs_start">
<arcs weight="1" target="//@nodes.18"/>
<arcs weight="1" outgoing="true" target="//@nodes.21"/>
<arcs weight="1" outgoing="true" target="//@nodes.20"/>
<arcs weight="1" target="//@nodes.2"/>
<arcs weight="1" outgoing="true" target="//@nodes.2"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_started"/>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_running"/>
<nodes xsi:type="petrinet:Transition" name="RedactionDocs_finish">
<arcs weight="1" target="//@nodes.21"/>
<arcs weight="1" outgoing="true" target="//@nodes.23"/>
<arcs weight="1" target="//@nodes.5"/>
<arcs weight="1" outgoing="true" target="//@nodes.5"/>
</nodes>
<nodes xsi:type="petrinet:Place" name="RedactionDocs_finished"/>
</petrinet:Network>

Some files were not shown because too many files have changed in this diff Show more