// Their location (screen coordinates) are those of the original operator
// (and also have to be because the operator screen location is not stored separately
// but restored from its replacement elements)
LoggerManager.debug(Constants.FILE_LOGGER, " ... Setting InnerTtransitions for Operator (ID:" + currentModel.getId() + ")");
OperatorTransitionModel operatorModel = (OperatorTransitionModel) currentModel;
Iterator<AbstractPetriNetElementModel> simpleTransIter = operatorModel.getSimpleTransContainer().getElementsByType(AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE).values().iterator();
while (simpleTransIter.hasNext())
{
AbstractPetriNetElementModel simpleTransModel = (AbstractPetriNetElementModel) simpleTransIter.next();
if (simpleTransModel != null // Sometimes the iterator
// returns null...
&& operatorModel.getSimpleTransContainer().getElementById(simpleTransModel.getId()).getType() == AbstractPetriNetElementModel.TRANS_SIMPLE_TYPE)
{
initTransition(iNet.addNewTransition(), (TransitionModel) operatorModel.getSimpleTransContainer().getElementById(simpleTransModel.getId()), operatorModel);
}
}
if (operatorModel.getCenterPlace() != null)
{
PlaceType iCenterPlace = initPlace(iNet.addNewPlace(), operatorModel.getCenterPlace());
initToolspecific(iCenterPlace.addNewToolspecific(), operatorModel.getCenterPlace(), operatorModel.getId(), operatorModel.getOperatorType());
}
LoggerManager.debug(Constants.FILE_LOGGER, " ... InnerTtransitions set.");
}
for (int i = 0; i < statusBars.length; i++)
statusBars[i].nextStep();
}
/* ##### ARCS ##### */
// When iterating through our arcs, we remember all
// transitions that are either source or destination of
// any arc we encounter
// Instead of serializing the arc itself, we serialize
// the "inner arcs" of all such transitions
// To sort out duplicates, we create a set
Set<AbstractPetriNetElementModel> connectedTransitions = new HashSet<AbstractPetriNetElementModel>();
Iterator<String> arcIter = elementContainer.getArcMap().keySet().iterator();
while (arcIter.hasNext())
{
ArcModel currentArc = elementContainer.getArcById(arcIter.next());
AbstractPetriNetElementModel currentTargetModel = (AbstractPetriNetElementModel) elementContainer.getElementById(currentArc.getTargetId());
AbstractPetriNetElementModel currentSourceModel = (AbstractPetriNetElementModel) elementContainer.getElementById(currentArc.getSourceId());
// Remember either source or target if it is a transition
// Please note that one special condition of petri nets is that
// a transition is never directly connected to another transition
// so either source or target may be a transition, never both
if (currentTargetModel.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE)
connectedTransitions.add(currentTargetModel);
else if (currentSourceModel.getType() == AbstractPetriNetElementModel.TRANS_OPERATOR_TYPE)
connectedTransitions.add(currentSourceModel);
else
{
// The current arc is not connected to any transition
// We do not need to take care of any inner arcs
// and instead store the currentArc itself
initArc(iNet.addNewArc(), currentArc, null);
}
for (int i = 0; i < statusBars.length; i++)
statusBars[i].nextStep();
}
// A transition can be a very complex construct consisting
// of a lot more than just one primitive petri-net transition (e.g.
// XOR Split, XOR Join, ...
// When dumping the PNML structure we must create primitive petri-net
// objects for applications that cannot read our tool specific
// complex transitions
// This is why all transitions store a map of primitive transitions
// with (ID, Object-Reference) entries.
// For all transitions connected to at least one arc we will
// dump the internal arcs now instead of the (previously ignored) visible arcs
Iterator<AbstractPetriNetElementModel> currentTransition = connectedTransitions.iterator();
while (currentTransition.hasNext())
{
OperatorTransitionModel currentConnectedModel = (OperatorTransitionModel)currentTransition.next();
Iterator<String> innerArcIter = currentConnectedModel.getSimpleTransContainer().getArcMap().keySet().iterator();
while (innerArcIter.hasNext())
{
// Dump all inner arcs of connected transitions
ArcModel currentInnerArc = (ArcModel) currentConnectedModel.getSimpleTransContainer().getArcMap().get(innerArcIter.next());
// Find outer arc corresponding to inner arc
// (carries graphics information)
ArcModel currentOuterArc = null;
if (elementContainer.getElementById(currentInnerArc.getSourceId())!=null)
{
currentOuterArc = elementContainer.findArc(currentInnerArc.getSourceId(),
currentConnectedModel.getId());
}
if (elementContainer.getElementById(currentInnerArc.getTargetId())!=null)
{
currentOuterArc = elementContainer.findArc(currentConnectedModel.getId(),
currentInnerArc.getTargetId());
}
// Always try to pass an outer arc with graphics information
// (contains way points)