// The model element processor is the only object that knows how to
// properly connect
// petri-net model elements, taking into account inner transitions
// for operators
// So we will be using it here to instantiate the serialized arcs
PetriNetModelProcessor processor = new PetriNetModelProcessor();
processor.setElementContainer(currentContainer);
for (int i = 0; i < arcs.length; i++) {
AbstractPetriNetElementModel currentSourceModel = null;
AbstractPetriNetElementModel currentTargetModel = null;
ArcModel arc = null;
try {
currentSourceModel = (AbstractPetriNetElementModel) currentContainer
.getElementById(arcs[i].getSource());
currentTargetModel = (AbstractPetriNetElementModel) currentContainer
.getElementById(arcs[i].getTarget());
String tempID;
if (ConfigurationManager.getConfiguration()
.isImportToolspecific()) {
try {
if (currentTargetModel == null
&& currentSourceModel != null) {
// if the current arcs target is an operator this
// block is executed
if (arcs[i].getTarget().indexOf(
OperatorTransitionModel.INNERID_SEPERATOR) != 0) {
tempID = arcs[i]
.getTarget()
.substring(
0,
arcs[i]
.getTarget()
.indexOf(
OperatorTransitionModel.OPERATOR_SEPERATOR_TRANSITION));
} else {
tempID = arcs[i]
.getTarget()
.substring(
0,
arcs[i]
.getTarget()
.indexOf(
OperatorTransitionModel.INNERID_SEPERATOR_OLD));
}
if (isOperator(currentContainer, tempID)) {
String sourceId = arcs[i].getSource();
String targetId = tempID;
arc = processor.createArc(arcs[i].getId(),
sourceId, targetId, new Point2D[0],
true);
}
}
if (currentSourceModel == null
&& currentTargetModel != null) {
// if the current arcs source is an operator this
// block is executed
if (arcs[i].getSource().indexOf(
OperatorTransitionModel.INNERID_SEPERATOR) != 0) {
tempID = arcs[i]
.getSource()
.substring(
0,
arcs[i]
.getSource()
.indexOf(
OperatorTransitionModel.OPERATOR_SEPERATOR_TRANSITION));
} else {
tempID = arcs[i]
.getSource()
.substring(
0,
arcs[i]
.getSource()
.indexOf(
OperatorTransitionModel.INNERID_SEPERATOR_OLD));
}
if (isOperator(currentContainer, tempID)) {
String sourceId = tempID;
String targetId = arcs[i].getTarget();
arc = processor.createArc(arcs[i].getId(),
sourceId, targetId, new Point2D[0],
true);
}
}
if (currentTargetModel != null
&& currentSourceModel != null) {
// in the easiest case if the imported arc isn't
// connected to an operator this block is executed
String sourceId = arcs[i].getSource();
String targetId = arcs[i].getTarget();
arc = processor.createArc(arcs[i].getId(),
sourceId, targetId, new Point2D[0], true);
}
if (arc != null) {
// Check whether we actually have an arc. If not, it
// does not make sense
// to import any tool-specific information.
// Note that internal arcs with no connection to any
// outer nodes
// will not be imported, they will be implicitly
// re-generated,
// e.g. XOR Split-Join
// Import toolspecific information for the arc
for (int j = 0; j < arcs[i].getToolspecificArray().length; j++) {
if ((arcs[i].getToolspecificArray(j).getTool() != null)
&& (arcs[i].getToolspecificArray(j)
.getTool().equals("WoPeD"))) {
if (arcs[i].getToolspecificArray(j)
.isSetRoute()
&& arcs[i].getToolspecificArray(j)
.getRoute())
arc.setRoute(true);
if (arcs[i].getToolspecificArray(j)
.isSetProbability())
arc.setProbability(arcs[i]
.getToolspecificArray(j)
.getProbability());
if (arcs[i].getToolspecificArray(j)
.isSetDisplayProbabilityOn())
arc.setDisplayOn(arcs[i]
.getToolspecificArray(j)
.getDisplayProbabilityOn());
if (arcs[i].getToolspecificArray(j)
.isSetDisplayProbabilityPosition()) {
Point location = new Point(
arcs[i]
.getToolspecificArray(j)
.getDisplayProbabilityPosition()
.getX().intValue(),
arcs[i]
.getToolspecificArray(j)
.getDisplayProbabilityPosition()
.getY().intValue());
arc.setLabelPosition(location);
}
} else {
arc.addUnknownToolSpecs(arcs[i]
.getToolspecificArray(j));
}
}
}
} catch (Exception e) {
warnings
.add("- ARC LOST INFORMATION ("
+ arcs[i].getId()
+ "): Exception while importing lesser important information.");
}
} else {
// if toolspecific import is disabled then import the arc
// "as is" (and don't replace transitions with toolspecific
// operators)
String sourceId = arcs[i].getSource();
String targetId = arcs[i].getTarget();
arc = processor.createArc(arcs[i].getId(), sourceId,
targetId, new Point2D[0], true);
}
if (arcs[i].isSetGraphics() && arc != null) {
// Create two standard points that need to be always present
// When created using the editor, those points are added