/** * Import a pnml file. Note: A pnml file can contains one or MORE nets. * * @see <a href="http://www.pnml.org/">http://www.pnml.org/</a> * @param File pnml complaint file */ private void importFile(File filePnml) { try { DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.parse(filePnml); doc.getDocumentElement().normalize(); for (final Node netNode : new IterableNodeList(doc.getElementsByTagName(Constants.PNML_NET))) { // Sets the graph id as the filename without ext String defaultId = filePnml.getName().substring(0, filePnml.getName().lastIndexOf('.')); insertGraph(filePnml.getName(), PetriNetGraph.factory(netNode, defaultId)); } } catch (ParserConfigurationException | SAXException | IOException ex) { showErrorMessage(ex); } }
/** * Execute an operation (composition) to a graph. * * <p>The graph can be a valid workflownet or a simple petrinet. Specific checks will be made in * Operation(). * * @todo refactor this * @param operationName */ public void executeOperation(String operationName) { Operation operation = null; PetriNetGraph operationGraph = new PetriNetGraph("new_" + (indexOpenedGraphs + 1)); try { switch (operationName) { case Constants.OPERATION_ALTERNATION: { OperationDialog selectionBox = new OperationDialog(getOpenedGraphs(), 1); if (selectionBox.getSelectedGraphs().size() > 0) { operation = new AlternationOperation( operationGraph, getSelectedGraph(), selectionBox.getSelectedGraphs().get(0)); } break; } case Constants.OPERATION_CLONEGRAPH: { operation = new CloneGraphOperation(operationGraph, getSelectedGraph()); break; } case Constants.OPERATION_DEFFEREDCHOICE: { OperationDialog selectionBox = new OperationDialog(getOpenedGraphs(), 1); if (selectionBox.getSelectedGraphs().size() > 0) { operation = new DefferedChoiceOperation( operationGraph, getSelectedGraph(), selectionBox.getSelectedGraphs().get(0)); } break; } case Constants.OPERATION_EXPLICITCHOICE: { OperationDialog selectionBox = new OperationDialog(getOpenedGraphs(), 1); if (selectionBox.getSelectedGraphs().size() > 0) { operation = new ExplicitChoiceOperation( operationGraph, getSelectedGraph(), selectionBox.getSelectedGraphs().get(0)); } break; } case Constants.OPERATION_ITERATIONONEORMORE: { operation = new OneOrMoreIterationOperation(operationGraph, getSelectedGraph()); break; } case Constants.OPERATION_ITERATIONONESERVEPERTIME: { operation = new OneServePerTimeOperation(operationGraph, getSelectedGraph()); break; } case Constants.OPERATION_ITERATIONZEROORMORE: { operation = new ZeroOrMoreIterationOperation(operationGraph, getSelectedGraph()); break; } case Constants.OPERATION_MUTUALEXCLUSION: { OperationDialog selectionBox = new OperationDialog(getOpenedGraphs(), 1); if (selectionBox.getSelectedGraphs().size() > 0) { operation = new MutualExclusionOperation( operationGraph, getSelectedGraph(), selectionBox.getSelectedGraphs().get(0)); } break; } case Constants.OPERATION_FULLMERGE: { OperationDialog selectionBox = new OperationDialog(getOpenedGraphs(), 1); if (selectionBox.getSelectedGraphs().size() > 0) { operation = new FullMergeOperation( operationGraph, getSelectedGraph(), selectionBox.getSelectedGraphs().get(0)); } break; } case Constants.OPERATION_PARALLELISM: { OperationDialog selectionBox = new OperationDialog(getOpenedGraphs(), 1); if (selectionBox.getSelectedGraphs().size() > 0) { operation = new ParallelismOperation( operationGraph, getSelectedGraph(), selectionBox.getSelectedGraphs().get(0)); } break; } case Constants.OPERATION_SEQUENCING: { OperationDialog selectionBox = new OperationDialog(getOpenedGraphs(), 1); if (selectionBox.getSelectedGraphs().size() > 0) { operation = new SequencingOperation( operationGraph, getSelectedGraph(), selectionBox.getSelectedGraphs().get(0)); } break; } // new operation case Constants.OPERATION_WRAP: { operation = new WrapGraphOperation(operationGraph, getSelectedGraph()); break; } } if (operation != null) { operationGraph = operation.getOperationGraph(); insertGraph(operationGraph.getId(), operationGraph); executeLayout(operationGraph, Constants.LAYOUT_VERTICALTREE); } } catch (Exception ex) { showErrorMessage(ex); } }