PlaceModel pm;
// loop over all places
while (iterPlace.hasNext()) {
pm = (PlaceModel) iterPlace.next();
lNet.getPlaceNode(new PlaceNode(pm.getTokenCount(), pm.getVirtualTokenCount(), pm.getId(), pm
.getNameValue(), makeOriginId(pm.getId())));
}
// loops over all transitions and set predecessors and successors
while (iterTransition.hasNext()) {
AbstractPetriNetElementModel trans = iterTransition.next();
AbstractPetriNetElementModel opTrans = null;
tm = (TransitionModel) trans;
successors = NetAlgorithms.getDirectlyConnectedNodes(tm, NetAlgorithms.connectionTypeOUTBOUND);
predecessors = NetAlgorithms.getDirectlyConnectedNodes(tm, NetAlgorithms.connectionTypeINBOUND);
ModelElementContainer mec;
AbstractPetriNetElementModel elem = null;
Iterator<ModelElementContainer> ownerIterator = trans.getOwningContainersIterator();
while (ownerIterator.hasNext()) {
mec = ownerIterator.next();
elem = mec.getOwningElement();
if (elem != null && elem.getType() == TransitionModel.TRANS_OPERATOR_TYPE) {
opTrans = (TransitionModel)elem;
break;
}
}
// add current transition node
TransitionNode tNode;
if (opTrans != null && opTrans.getType() == TransitionModel.TRANS_OPERATOR_TYPE) {
tNode = lNet.getTransitionNode(new TransitionNode(tm.getId(), tm.getNameValue(),
makeOriginId(tm.getId()), ((OperatorTransitionModel)opTrans).getOperatorType()));
}
else {
tNode = lNet.getTransitionNode(new TransitionNode(tm.getId(), tm.getNameValue(),
makeOriginId(tm.getId()), OperatorTransitionModel.TRANS_SIMPLE_TYPE));
}
// add predecessor of current transition node
for (AbstractPetriNetElementModel predecessor : predecessors) {
lNet.getPlaceNode(
new PlaceNode(((PlaceModel) predecessor).getTokenCount(), ((PlaceModel) predecessor)
.getVirtualTokenCount(), predecessor.getId(), predecessor.getNameValue(),
makeOriginId(predecessor.getId()))).addPostNode(tNode);
}
// add successor of current transition node
for (AbstractPetriNetElementModel successor : successors) {
tNode.addPostNode(lNet.getPlaceNode(new PlaceNode(((PlaceModel) successor).getTokenCount(),
((PlaceModel) successor).getVirtualTokenCount(), successor.getId(), successor.getNameValue(),
makeOriginId(successor.getId()))));
}
}