Пример #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 EPCResult traverseAML(
     EPCResult partialResult,
     Node currentNode,
     Object parent,
     HashMap ObjDef_Name,
     HashMap ObjDef_LinkId,
     HashMap modelid_net,
     HashMap function_LinkId)
     throws Exception {
   if (currentNode.hasChildNodes()) {
     for (int i = 0; i < currentNode.getChildNodes().getLength(); i++) {
       Node currentChild = currentNode.getChildNodes().item(i);
       if (currentChild.getNodeName().equals("Group")) {
         String id = currentChild.getAttributes().getNamedItem("Group.ID").getNodeValue();
         String GroupName = "";
         if (currentChild.hasChildNodes()) {
           NodeList currentChildren = currentChild.getChildNodes();
           for (int j = 0; j < currentChildren.getLength(); j++) {
             Node Child = currentChildren.item(j);
             if (!(Child.getNodeName().equals("AttrDef"))) {
               continue;
             }
             if (Child.getAttributes()
                 .getNamedItem("AttrDef.Type")
                 .getNodeValue()
                 .equals("AT_NAME")) {
               if (Child.hasChildNodes()) {
                 for (int l = 0; l < Child.getChildNodes().getLength(); l++) {
                   if (!(Child.getChildNodes().item(l).getNodeName().equals("AttrValue"))) {
                     continue;
                   } else {
                     GroupName = getTextContent(Child.getChildNodes().item(l));
                   }
                 }
                 break;
               }
             }
           }
           if (GroupName.equals("")) {
             GroupName = id;
           }
         }
         ModelHierarchyDirectory dir = new ModelHierarchyDirectory(id, GroupName);
         partialResult.addInHierarchy(dir, parent, GroupName);
         partialResult =
             traverseAML(
                 partialResult,
                 currentChild,
                 dir,
                 ObjDef_Name,
                 ObjDef_LinkId,
                 modelid_net,
                 function_LinkId);
       }
       if (currentChild.getNodeName().equals("Model")
           && currentChild
               .getAttributes()
               .getNamedItem("Model.Type")
               .getNodeValue()
               .equals("MT_EEPC")) {
         String ModelName = "gaga";
         if (currentChild.hasChildNodes()) {
           NodeList currentChildren = currentChild.getChildNodes();
           for (int j = 0; j < currentChildren.getLength(); j++) {
             Node Child = currentChildren.item(j);
             if (!(Child.getNodeName().equals("AttrDef"))) {
               continue;
             }
             if (Child.getAttributes()
                 .getNamedItem("AttrDef.Type")
                 .getNodeValue()
                 .equals("AT_NAME")) {
               if (Child.hasChildNodes()) {
                 for (int l = 0; l < Child.getChildNodes().getLength(); l++) {
                   if (!(Child.getChildNodes().item(l).getNodeName().equals("AttrValue"))) {
                     continue;
                   } else {
                     ModelName = getTextContent(Child.getChildNodes().item(l));
                   }
                 }
               }
               break;
             }
           }
         }
         try {
           ModelName = ModelName.replaceAll("\n", " ");
           EPC net = read(currentChild, ObjDef_Name, ObjDef_LinkId, function_LinkId, ModelName);
           partialResult.addInHierarchy(net, parent, ModelName);
           modelid_net.put(
               currentChild.getAttributes().getNamedItem("Model.ID").getNodeValue(), net);
         } catch (Throwable x) {
           Message.add(x.getClass().getName());
           // throw new IOException(x.getMessage());
         }
       }
     }
   }
   return partialResult;
 }