public static PetriNet epcToPetriNet(ConfigurableEPC epc) throws SerendipException { PetriNet pn = null; if (null == epc) { throw new SerendipException("No model is available"); } log.debug("Converting EPC: " + epc.getIdentifier()); // Conversion // EPCToPetriNetConverterPlugin epcToPNplugin = new // EPCToPetriNetConverterPlugin(); // pn = epcToPNplugin.convert(epc); pn = EPCToPetriNetConverter.convert(epc, new HashMap(), null, null); // DEBUG Iterator<EPCEvent> events = epc.getEvents().iterator(); while (events.hasNext()) { log.debug(">" + events.next().getIdentifier()); } Iterator<Place> places = pn.getPlaces().iterator(); while (places.hasNext()) { log.debug("]" + places.next().getIdentifier()); } // end DEBUG if (null == pn) { throw new SerendipException("Cannot get the equivalent petrinet of " + epc.getId()); } pn.setName(epc.getIdentifier()); return pn; }
/** * EPML2PNML * * @param args String[] */ private static void EPML2PNML(String[] args) { if (args.length != 2) { System.out.println("���ṩEPML�ļ�·����PNML���Ŀ¼!"); System.exit(-1); } epmlImport epml = new epmlImport(); // load the single epml file String filename = args[0]; try { EPCResult epcRes = (EPCResult) epml.importFile(new FileInputStream(filename)); // convert all epc models to pnml files ArrayList<ConfigurableEPC> alEPCs = epcRes.getAllEPCs(); PnmlExport export = new PnmlExport(); for (ConfigurableEPC epc : alEPCs) { String id = epc.getIdentifier(); if (id.equals("1An_klol") || id.equals("1An_l1y8") || id.equals("1Ex_dzq9") || id.equals("1Ex_e6dx") || id.equals("1Ku_9soy") || id.equals("1Ku_a4cg") || id.equals("1Or_lojl") || id.equals("1Pr_d1ur") || id.equals("1Pr_djki") || id.equals("1Pr_dkfa") || id.equals("1Pr_dl73") || id.equals("1Ve_musj") || id.equals("1Ve_mvwz")) continue; // save pnml files to the same folder File outFile = new File(args[1] + "/" + id + ".pnml"); if (outFile.exists()) continue; FileOutputStream fos = new FileOutputStream(outFile); PetriNet petri = AMLtoPNML.convert(epc); try { export.export(new ProvidedObject("PetriNet", new Object[] {petri}), fos); } catch (Exception ex1) { ex1.printStackTrace(System.out); } } } catch (IOException ex) { ex.printStackTrace(System.out); } System.out.println("EPML Conversion Done"); }