Пример #1
0
  /**
   * 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");
  }
Пример #2
0
  private static void AML2PNML(String[] args) {
    if (args.length != 3) {
      System.out.println("���ṩAML����Ŀ¼��PNML���Ŀ¼�Լ��ֵ��ļ�!");
      System.exit(-1);
    }
    System.out.println("����Ŀ¼��" + args[0]);
    System.out.println("���Ŀ¼��" + args[1]);
    System.out.println("�ֵ��ļ���" + args[2]);
    // load the dict
    AMLtoPNML.loadDict(args[2]);
    File srcDir = new File(args[0]);
    File[] lstAML = srcDir.listFiles();
    PnmlExport export = new PnmlExport();
    for (int i = 0; i < lstAML.length; i++) {
      if (lstAML[i].isDirectory()) {
        continue;
      }
      System.out.print(lstAML[i].getName() + "==>");
      try {
        FileInputStream fis = new FileInputStream(lstAML[i]);
        int idx = lstAML[i].getName().indexOf(".xml");
        File outFile = new File(args[1] + "/" + lstAML[i].getName().substring(0, idx) + ".pnml");
        FileOutputStream fos = new FileOutputStream(outFile);
        EPCResult epcRes = (EPCResult) AMLtoPNML.importFile(fis);
        ConfigurableEPC epc = epcRes.getMainEPC();
        PetriNet petri = AMLtoPNML.convert(epc);
        export.export(new ProvidedObject("PetriNet", new Object[] {petri}), fos);
        System.out.println(outFile.getName());
      } catch (FileNotFoundException ex) {
        ex.printStackTrace(System.out);
      } catch (IOException ioe) {
        ioe.printStackTrace(System.out);
      } catch (Exception e) {
        e.printStackTrace(System.out);
      }
    }

    System.out.println("Conversion Done");
  }
Пример #3
0
  public static MiningResult importFile(InputStream input) throws IOException {
    try {
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      Document doc;
      // NodeList netNodes;
      dbf.setValidating(false);
      dbf.setIgnoringComments(true);
      dbf.setIgnoringElementContentWhitespace(true);
      // dbf.setExpandEntityReferences(false);
      // dbf.setNamespaceAware(false);

      DocumentBuilder db = dbf.newDocumentBuilder();

      db.setEntityResolver(
          new EntityResolver() {
            public InputSource resolveEntity(String publicId, String systemId) {
              if (systemId.indexOf("ARIS-Export") != -1) {
                return new InputSource("file:" + About.EXTLIBLOCATION() + "ARIS-Export101.dtd");
              } else {
                return null;
              }
            }
          });

      InputSource inpStream = new InputSource(input);
      inpStream.setSystemId("file:" + System.getProperty("user.dir", ""));
      doc = db.parse(inpStream);

      // check if root element is a aml tag
      Message.add("parsing done" + doc, Message.DEBUG);
      if (!(doc.getDocumentElement().getNodeName().equals("AML"))) {
        Message.add("aml tag not found", Message.ERROR);
        throw new Exception("aml tag not found");
      } else {
        Message.add("aml root element found");
      }

      EPCResult result = new EPCResult(null, (EPC) null);
      HashMap ObjDef_LinkId = new HashMap();
      HashMap modelid_net = new HashMap();
      HashMap ObjDef_Name = new HashMap();
      HashMap function_LinkId = new HashMap();
      HashMap ModelId_ModelType = new HashMap();
      traverseAMLforObjectNames(
          ObjDef_Name, doc.getDocumentElement(), ObjDef_LinkId, ModelId_ModelType);
      Iterator findLinkToEpc = ObjDef_LinkId.keySet().iterator();
      while (findLinkToEpc.hasNext()) {
        String currentObjDef = (String) findLinkToEpc.next();
        String Links = (String) ObjDef_LinkId.get(currentObjDef);
        StringTokenizer linkSet = new StringTokenizer(Links);
        String realEpcLink = "";
        while (linkSet.hasMoreTokens()) {
          String currentLink = linkSet.nextToken();
          if (ModelId_ModelType.get(currentLink).equals("MT_EEPC")) {
            realEpcLink = currentLink;
            break;
          }
        }
        if (realEpcLink.equals(" ")) {
          ObjDef_LinkId.remove(currentObjDef);
        } else {
          ObjDef_LinkId.put(currentObjDef, realEpcLink);
        }
      }
      result =
          traverseAML(
              result,
              doc.getDocumentElement(),
              null,
              ObjDef_Name,
              ObjDef_LinkId,
              modelid_net,
              function_LinkId);
      Iterator hierarchicalFunctions = function_LinkId.keySet().iterator();
      while (hierarchicalFunctions.hasNext()) {
        EPCSubstFunction f = (EPCSubstFunction) hierarchicalFunctions.next();
        f.setSubstitutedEPC((EPC) modelid_net.get(function_LinkId.get(f)));
        // Message.add(f.getSubstitutedEPC().getName());
      }

      return result;

    } catch (Throwable x) {
      Message.add(x.toString());
      throw new IOException(x.getMessage());
    }
  }
Пример #4
0
  public static void main(String[] args) {
    AML2PNML(args);
    // EPML2PNML(args);

    System.exit(0);
  }