Esempio n. 1
1
 /*
  * public HashMap getLeafElements() { HashMap map = new HashMap(); Object[]
  * elts = dataElements.values().toArray(); for (int j=0; j<elts.length; j++)
  * { PDMDataElement data = (PDMDataElement) elts[j];
  * map.put(data.getID(),data); } Object[] ops =
  * operations.values().toArray(); for (int i=0; i<ops.length; i++){
  * PDMOperation op = (PDMOperation) ops[i]; if
  * (!(op.getInputElements().isEmpty())){ HashMap outs =
  * op.getOutputElements(); Object[] outArray = outs.values().toArray(); for
  * (int j=0; j<outArray.length; j++) { PDMDataElement d = (PDMDataElement)
  * outArray[j]; map.remove(d.getID()); } } } return map; }
  */
 public HashMap getLeafElements() {
   HashMap result = new HashMap();
   HashSet leafOps = getLeafOperations();
   if (!(leafOps.isEmpty())) {
     Iterator it = leafOps.iterator();
     while (it.hasNext()) {
       PDMOperation op = (PDMOperation) it.next();
       PDMDataElement data = op.getOutputElement();
       result.put(data.getID(), data);
     }
   } else {
     Object[] elts = dataElements.values().toArray();
     for (int j = 0; j < elts.length; j++) {
       PDMDataElement data = (PDMDataElement) elts[j];
       result.put(data.getID(), data);
     }
     Object[] ops = operations.values().toArray();
     for (int i = 0; i < ops.length; i++) {
       PDMOperation op = (PDMOperation) ops[i];
       HashMap outs = op.getOutputElements();
       Object[] outArray = outs.values().toArray();
       for (int j = 0; j < outArray.length; j++) {
         PDMDataElement d = (PDMDataElement) outArray[j];
         result.remove(d.getID());
       }
     }
   }
   return result;
 }
Esempio n. 2
0
 public static void traverseAMLforObjectNames(
     HashMap partialMap, Node currentNode, HashMap ObjDef_LinkId, HashMap ModelId_ModelType) {
   if (currentNode.hasChildNodes()) {
     for (int i = 0; i < currentNode.getChildNodes().getLength(); i++) {
       Node currentChild = currentNode.getChildNodes().item(i);
       if (currentChild.getNodeName().equals("Group")) {
         traverseAMLforObjectNames(partialMap, currentChild, ObjDef_LinkId, ModelId_ModelType);
       }
       if (currentChild.getNodeName().equals("Model")) {
         if (currentChild.hasAttributes()) {
           String mid = currentChild.getAttributes().getNamedItem("Model.ID").getNodeValue();
           String type = currentChild.getAttributes().getNamedItem("Model.Type").getNodeValue();
           ModelId_ModelType.put(mid, type);
         }
         // traverseAMLforObjectNames(partialMap, currentChild,
         // ObjDef_LinkId);
       }
       if (currentChild.getNodeName().equals("ObjDef")) {
         String id = currentChild.getAttributes().getNamedItem("ObjDef.ID").getNodeValue();
         NodeList currentChildren = currentChild.getChildNodes();
         String ObjName = "";
         for (int k = 0; k < currentChildren.getLength(); k++) {
           Node Child = currentChildren.item(k);
           if (!Child.getNodeName().equals("AttrDef")) {
             continue;
           } else if (!Child.getAttributes()
               .getNamedItem("AttrDef.Type")
               .getNodeValue()
               .equals("AT_NAME")) {
             continue;
           } else if (Child.hasChildNodes()) {
             for (int l = 0; l < Child.getChildNodes().getLength(); l++) {
               if (!(Child.getChildNodes().item(l).getNodeName().equals("AttrValue"))) {
                 continue;
               } else {
                 ObjName = getTextContent(Child.getChildNodes().item(l));
                 ObjName = ObjName.replaceAll("\n", "\\\\n");
                 break;
               }
             }
           }
         }
         partialMap.put(id, ObjName);
         for (int j = 0; j < currentChild.getAttributes().getLength(); j++) {
           if (currentChild.getAttributes().item(j).getNodeName().equals("LinkedModels.IdRefs")) {
             String links =
                 currentChild.getAttributes().getNamedItem("LinkedModels.IdRefs").getNodeValue();
             /*
              * if (links.indexOf(" ") > -1) {
              * Message.add("yes, yes, yes"); links =
              * links.substring(0, links.indexOf(" ")); }
              */
             ObjDef_LinkId.put(id, links);
           }
         }
       }
     }
   }
 }
Esempio n. 3
0
 /**
  * Returns a HashSet with the operations that have data element 'data' as output element.
  *
  * @param data PDMDataElement
  * @return HashSet
  */
 public HashSet getOperationsWithOutputElement(PDMDataElement data) {
   HashSet opso = new HashSet();
   Object[] ops = operations.values().toArray();
   for (int i = 0; i < ops.length; i++) {
     PDMOperation op = (PDMOperation) ops[i];
     HashMap outputs = op.getOutputElements();
     if (outputs.containsValue(data)) {
       opso.add(op);
     }
   }
   return opso;
 }
Esempio n. 4
0
 /**
  * Returns a HashMap with the preceeding data elements of data element 'data'
  *
  * @param data PDMDataElement
  * @return HashMap
  */
 public HashMap getPrecedingElements(PDMDataElement data) {
   HashMap precs = new HashMap();
   Object[] ops = operations.values().toArray();
   for (int i = 0; i < ops.length; i++) {
     PDMOperation op = (PDMOperation) ops[i];
     if (op.getOutputElements().containsValue(data)) {
       HashMap ins = op.getInputElements();
       Object[] inputs = ins.values().toArray();
       for (int j = 0; j < inputs.length; j++) {
         PDMDataElement el = (PDMDataElement) inputs[j];
         precs.put(el.getID(), el);
       }
     }
   }
   return precs;
 }
Esempio n. 5
0
  /**
   * Writes the model to DOT.
   *
   * @param bw The writer
   * @throws IOException If writing fails
   */
  public void writeToDot(Writer bw) throws IOException {
    // super.writeToDot(bw);

    // Preamble of dot file
    bw.write(
        "digraph G {ranksep=\".3\"; fontsize=\"8\"; remincross=true; margin=\"0.0,0.0\"; rankdir=TB; ");
    bw.write("fontname=\"Arial\"; \n");
    bw.write("edge [arrowsize=\"0.5\"];\n");
    bw.write("node [fontname=\"Arial\",fontsize=\"8\"];\n");

    // Add the Data Element nodes
    Iterator it = getVerticeList().iterator();
    while (it.hasNext()) {
      Object object = it.next();
      if (object instanceof PDMDataElement) {
        ((PDMDataElement) object).writeToDot(bw, this);
      }
    }

    // Add all edges
    it = operations.values().iterator();
    while (it.hasNext()) {
      Object object = it.next();
      if (object instanceof PDMOperation) {
        ((PDMOperation) object).writeToDot(bw, this);
      }
    }

    bw.write("\n}\n");
  }
Esempio n. 6
0
 public HashSet getLeafOperations() {
   HashSet result = new HashSet();
   Object[] ops = operations.values().toArray();
   for (int i = 0; i < ops.length; i++) {
     PDMOperation op = (PDMOperation) ops[i];
     if ((op.getInputElements().isEmpty())) {
       result.add(op);
     }
   }
   return result;
 }
Esempio n. 7
0
 /**
  * Export to PDM file.
  *
  * @param bw Writer
  * @throws IOException If writing fails
  */
 public void writeToPDM(Writer bw) throws IOException {
   bw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
   bw.write("<PDM\n");
   bw.write("\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
   bw.write(
       "\txsi:noNamespaceSchemaLocation=\"C:/Documents and Settings/ivdfeest/My Documents/Implementatie/PDM.xsd\"\n");
   bw.write(">\n");
   Iterator it = dataElements.values().iterator();
   while (it.hasNext()) {
     PDMDataElement dataElement = (PDMDataElement) it.next();
     dataElement.writeToPDM(bw);
   }
   Iterator it2 = resources.values().iterator();
   while (it2.hasNext()) {
     PDMResource resource = (PDMResource) it.next();
     resource.writeToPDM(bw);
   }
   Iterator it3 = operations.values().iterator();
   while (it3.hasNext()) {
     PDMOperation operation = (PDMOperation) it.next();
     operation.writeToPDM(bw);
   }
   bw.write("</PDM>\n");
 }
Esempio n. 8
0
 /**
  * Adds a Data Element to the set of Data Elements of the Product Data Model
  *
  * @param element PDMDataElement
  */
 public void addDataElement(PDMDataElement element) {
   dataElements.put(element.getID(), element);
   addVertex(element);
 }
Esempio n. 9
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;
 }
Esempio n. 10
0
  private static void parseNet(
      Node node,
      EPC net,
      HashMap ObjDef_Name,
      HashMap ObjDef_LinkId,
      HashMap function_LinkId,
      String ModelName)
      throws Exception {
    HashMap mapping = new HashMap();

    // read all nodes
    NodeList nodes = node.getChildNodes();
    net.setIdentifier(ModelName);
    // Message.add("here I am still happy");
    for (int i = 0; i < nodes.getLength(); i++) {
      Node n = nodes.item(i);
      if (!n.getNodeName().equals("ObjOcc")) {
        continue;
      }
      if (n.getAttributes().getNamedItem("SymbolNum") == null) {
        continue;
      }
      String symbolnum = n.getAttributes().getNamedItem("SymbolNum").getNodeValue();
      if (!(symbolnum.equals("ST_FUNC")
          || symbolnum.equals("ST_EV")
          || symbolnum.equals("ST_OPR_AND_1")
          || symbolnum.equals("ST_OPR_OR_1")
          || symbolnum.equals("ST_OPR_XOR_1"))) {
        continue;
      }

      String ObjDef = n.getAttributes().getNamedItem("ObjDef.IdRef").getNodeValue();
      String ownName = (String) ObjDef_Name.get(ObjDef);
      // Message.add("YES " +
      // n.getAttributes().getNamedItem("ObjOcc.ID").getNodeValue());
      String id = n.getAttributes().getNamedItem("ObjOcc.ID").getNodeValue();
      // Message.add(id + " " + ownName);
      if (ownName == null || ownName == "") {
        ownName = id.substring(7, 11);
      }
      if (symbolnum.equals("ST_FUNC")) {
        if (ObjDef_LinkId.containsKey(ObjDef)) {
          EPCSubstFunction sf =
              (EPCSubstFunction)
                  net.addFunction(
                      new EPCSubstFunction(new LogEvent(ownName, "unknown:normal"), net, null));
          sf.setIdentifier(ownName);
          mapping.put(id, sf);
          function_LinkId.put(sf, ObjDef_LinkId.get(ObjDef));
        } else {
          EPCFunction f =
              net.addFunction(new EPCFunction(new LogEvent(ownName, "unknown:normal"), net));
          f.setIdentifier(ownName);
          mapping.put(id, f);
        }
      } else if (symbolnum.equals("ST_EV")) {
        EPCEvent e = net.addEvent(new EPCEvent(ownName, net));
        e.setIdentifier(ownName);
        mapping.put(id, e);
      } else if (symbolnum.equals("ST_OPR_AND_1")) {
        EPCConnector c = net.addConnector(new EPCConnector(EPCConnector.AND, net));
        mapping.put(id, c);
      } else if (symbolnum.equals("ST_OPR_OR_1")) {
        // EPCConnector c = net.addConnector(new
        // EPCConnector(EPCConnector.OR, net));
        EPCConnector c = net.addConnector(new EPCConnector(EPCConnector.AND, net));
        mapping.put(id, c);
      } else if (symbolnum.equals("ST_OPR_XOR_1")) {
        EPCConnector c = net.addConnector(new EPCConnector(EPCConnector.XOR, net));
        mapping.put(id, c);
      }
    }

    for (int i = 0; i < nodes.getLength(); i++) {
      Node n = nodes.item(i);
      if (!n.getNodeName().equals("ObjOcc")) {
        continue;
      }
      if (n.getAttributes().getNamedItem("SymbolNum") == null) {
        continue;
      }
      String symbolnum = n.getAttributes().getNamedItem("SymbolNum").getNodeValue();
      if (!(symbolnum.equals("ST_FUNC")
          || symbolnum.equals("ST_EV")
          || symbolnum.equals("ST_OPR_AND_1")
          || symbolnum.equals("ST_OPR_OR_1")
          || symbolnum.equals("ST_OPR_XOR_1"))) {
        continue;
      }
      String source = n.getAttributes().getNamedItem("ObjOcc.ID").getNodeValue();
      if (n.hasChildNodes()) {
        for (int j = 0; j < n.getChildNodes().getLength(); j++) {
          if (n.getChildNodes().item(j).getNodeName().equals("CxnOcc")) {
            Node CxnOcc = n.getChildNodes().item(j);
            String dest = CxnOcc.getAttributes().getNamedItem("ToObjOcc.IdRef").getNodeValue();
            if (mapping.get(dest) == null) {
              continue;
            }
            if (net.addEdge((EPCObject) mapping.get(source), (EPCObject) mapping.get(dest))
                == null) {
              throw (new Exception(
                  "<html>Structural properties of EPCs are violated in input file.<br>"
                      + "The following edge could not be added:<br><br>"
                      + mapping.get(source).toString()
                      + " ==> "
                      + mapping.get(dest).toString()
                      + "<br><br>Import aborted.</html>"));
            }
          }
        }
      }
    }
  }
Esempio n. 11
0
 /**
  * Adds an Operation to the set of Operations of the Product Data Model
  *
  * @param operation PDMOperation
  */
 public void addOperation(PDMOperation operation) {
   operations.put(operation.getID(), operation);
 }
Esempio n. 12
0
 /**
  * Removes an Operation to the set of Operations of the Product Data Model added by Johfra
  *
  * @param operation PDMOperation
  */
 public void remOperation(PDMOperation operation) {
   operations.remove(operation.getID());
 }
Esempio n. 13
0
 /**
  * Adds a Resource to the set of Resources ot the Product Data Model NB: Later on this should be
  * moved to the section of the Organizational Model
  *
  * @param resource PDMResource
  */
 public void addResource(PDMResource resource) {
   resources.put(resource.getID(), resource);
 }
Esempio n. 14
0
 /**
  * Returns the Resource with identifier "id"
  *
  * @param id String
  * @return PDMResource
  */
 public PDMOperation getOperation(String id) {
   return (PDMOperation) operations.get(id);
 }
Esempio n. 15
0
  /**
   * Export PDM model to Declare process model.
   *
   * @param bw Writer
   * @throws IOException If writing fails
   */
  public void writePDMToDeclare(Writer bw) throws IOException {
    // write the preamble of the XML file
    bw.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
    bw.write("<model>\n");
    bw.write("<assignment language=\"ConDec\" name=\"" + name + "\">\n");

    // write the activity definitions, i.e. each operation in the PDM is an
    // activity definition in Declare
    bw.write("<activitydefinitions>\n");
    // start with an initial activity that puts the values for the leaf
    // elements of the PDM
    bw.write("<activity id=\"Initial\" name=\"Initial\">\n");
    bw.write("<authorization/>\n");
    bw.write("<datamodel>\n");
    // all leaf elements
    HashMap leafs = getLeafElements();
    Object[] leafElts = leafs.values().toArray();
    for (int i = 0; i < leafElts.length; i++) {
      PDMDataElement data = (PDMDataElement) leafElts[i];
      data.writePDMToDeclare(bw, "output");
    }
    bw.write("</datamodel>\n");
    bw.write("<attributes/>\n");
    bw.write("</activity>\n");

    // first remove input operations from the set of operations and then
    // write all real operations
    HashMap realOps = (HashMap) operations.clone();
    HashSet inputOps = getLeafOperations();
    Iterator it7 = inputOps.iterator();
    while (it7.hasNext()) {
      PDMOperation op = (PDMOperation) it7.next();
      realOps.remove(op.getID());
    }
    Iterator it4 = realOps.values().iterator();
    while (it4.hasNext()) {
      PDMOperation operation = (PDMOperation) it4.next();
      operation.writePDMToDeclare(bw);
    }
    bw.write("\n");
    // write all input operations (i.e. producing input data elements)
    Iterator it8 = inputOps.iterator();
    while (it8.hasNext()) {
      PDMOperation op = (PDMOperation) it8.next();
      op.writePDMToDeclare(bw);
    }

    bw.write("</activitydefinitions>\n");

    // write the constraint definition, for now we do not have any
    // constraints in the PDM that are translated to Declare
    bw.write("<constraintdefinitions>\n");
    bw.write("</constraintdefinitions>\n");

    // write all dataelements
    bw.write("<data>\n");
    Iterator it5 = dataElements.values().iterator();
    while (it5.hasNext()) {
      PDMDataElement dataElement = (PDMDataElement) it5.next();
      dataElement.writePDMToDeclare(bw);
    }
    bw.write("</data>\n");

    // write the organizational information
    bw.write("<team/>\n");

    // TODO: improve graphical positioning of activities. Now they are
    // presented in one long line.
    // write the graphical positioning information of the Declare model,
    // first the initial operation, then the real operations and then the
    // input operations.
    bw.write("<graphical>\n");
    bw.write("<cells>\n");
    Iterator it6 = realOps.values().iterator();
    Double pos = 10.0;
    while (it6.hasNext()) {
      PDMOperation operation = (PDMOperation) it6.next();
      bw.write(
          "<cell activitydefinition=\""
              + operation.getOperationNR()
              + "\" height=\"40.0\" width=\"80.0\" x=\""
              + pos
              + "\" y=\"90.0\" />\n");
      pos = pos + 85.0;
    }
    Iterator it9 = inputOps.iterator();
    pos = 10.0;
    while (it9.hasNext()) {
      PDMOperation operation = (PDMOperation) it9.next();
      bw.write(
          "<cell activitydefinition=\""
              + operation.getOperationNR()
              + "\" height=\"40.0\" width=\"80.0\" x=\""
              + pos
              + "\" y=\"180.0\" />\n");
      pos = pos + 85.0;
    }

    bw.write("</cells>\n");

    // write the connectors
    bw.write("<connectors/>\n");
    // close the XML file in the right way
    bw.write("</graphical>\n");
    bw.write("</assignment>\n");
    bw.write("</model>\n");
  }
Esempio n. 16
0
 /**
  * Returns the Resource with identifier "id"
  *
  * @param id String
  * @return PDMResource
  */
 public PDMResource getResource(String id) {
   return (PDMResource) resources.get(id);
 }
Esempio n. 17
0
  public static PetriNet convert(ConfigurableEPC baseEPC) {
    HashMap<EPCFunction, Transition> functionActivityMapping;
    HashMap<EPCConnector, Place> xorconnectorChoiceMapping;

    // HV: Initialize the mappings.
    functionActivityMapping = new HashMap<EPCFunction, Transition>();
    xorconnectorChoiceMapping = new HashMap<EPCConnector, Place>();

    // Check to use the weights if necessary
    // HV: Add both mappings. On completion, these will be filledd.
    PetriNet petrinet =
        EPCToPetriNetConverter.convert(
            baseEPC, new HashMap(), functionActivityMapping, xorconnectorChoiceMapping);

    HashSet visible = new HashSet();

    // HV: The next block is taken care of by the functionActivityMapping
    // below.
    /*
     * Iterator it = petrinet.getTransitions().iterator(); while
     * (it.hasNext()) { Transition t = (Transition) it.next(); if (t.object
     * instanceof EPCFunction) { // if (t.getLogEvent() != null) { // Add
     * transitions with LogEvent (i.e. referring to functions)
     * visible.add(t); } }
     */

    // HV: Prevent the places mapped onto from being reduced.
    visible.addAll(functionActivityMapping.values());
    visible.addAll(xorconnectorChoiceMapping.values());
    Message.add(visible.toString(), Message.DEBUG);

    Iterator it = petrinet.getPlaces().iterator();
    while (it.hasNext()) {
      Place p = (Place) it.next();
      if (p.inDegree() * p.outDegree() == 0) {
        // Add Initial and final places to visible, i.e. places that
        // refer to in and output events
        visible.add(p);
      }
    }

    // Reduce the PetriNet with Murata rules, while keeping the visible ones
    PetriNetReduction pnred = new PetriNetReduction();
    pnred.setNonReducableNodes(visible);

    HashMap pnMap = new HashMap(); // Used to map pre-reduction nodes to
    // post-reduction nodes.
    PetriNet reduced = pnred.reduce(petrinet, pnMap);

    if (reduced != petrinet) {
      // Update both mappings from pre-reduction nodes to post-reduction
      // nodes.
      HashMap<EPCFunction, Transition> newFunctionActivityMapping =
          new HashMap<EPCFunction, Transition>();
      for (EPCFunction function : functionActivityMapping.keySet()) {
        Transition transition = (Transition) functionActivityMapping.get(function);
        if (pnMap.keySet().contains(transition)) {
          newFunctionActivityMapping.put(function, (Transition) pnMap.get(transition));
        }
      }
      functionActivityMapping = newFunctionActivityMapping;
      HashMap<EPCConnector, Place> newXorconnectorChoiceMapping =
          new HashMap<EPCConnector, Place>();
      for (EPCConnector connector : xorconnectorChoiceMapping.keySet()) {
        Place place = (Place) xorconnectorChoiceMapping.get(connector);
        if (pnMap.keySet().contains(place)) {
          newXorconnectorChoiceMapping.put(connector, (Place) pnMap.get(place));
        }
      }
      xorconnectorChoiceMapping = newXorconnectorChoiceMapping;
    }
    reduced.makeClusters();

    // filter the \nunknown:normal
    ArrayList<Transition> alTrans = reduced.getVisibleTasks();
    for (int i = 0; i < alTrans.size(); i++) {
      Transition t = alTrans.get(i);
      String id = t.getIdentifier();
      int idx = id.indexOf("\\nunknown:normal");
      if (idx > 0) {
        id = id.substring(0, idx);
      }
      // �˴������ֵ��ѯ�滻���е�label
      String mappedId = htDict.get(id);
      if (mappedId != null) {
        t.setIdentifier(mappedId);
      } else {
        t.setIdentifier(id);
      }
    }

    return reduced;
  }
Esempio n. 18
0
  public PDMStateSpace calculateSimpleStateSpace(
      boolean root, boolean failure, boolean input, boolean colored, int numStates, int breadth) {
    PDMStateSpace result = new PDMStateSpace(this, colored);
    HashSet states = new HashSet();
    int j = (operations.size() + 1);

    if (!input) {
      HashSet empty = new HashSet();
      PDMState st = new PDMState(result, "state" + i, empty, empty, empty);
      result.addState(st);
      states.add(st);
      i++;
    } else {
      // Start with the complete set of input data elements available
      HashSet empty = new HashSet();
      String name = new String("state" + i);
      HashSet ins = new HashSet(); // this hashSet contains the input
      // elements to the process (input
      // elements of PDM)
      HashSet execOps = new HashSet();
      // Fill the hashSet with the leaf elements
      HashMap leafs = getLeafElements();
      Object[] leafElts = leafs.values().toArray();
      for (int i = 0; i < leafElts.length; i++) {
        PDMDataElement d = (PDMDataElement) leafElts[i];
        ins.add(d);
      }
      HashSet leafOps = getLeafOperations();
      Iterator it = leafOps.iterator();
      while (it.hasNext()) {
        PDMOperation op = (PDMOperation) it.next();
        execOps.add(op);
      }

      PDMState start = new PDMState(result, name, ins, execOps, empty); // start
      // state
      // of
      // the
      // statespace
      result.addState(start);
      i++;
      states.add(start);
    }
    while (!states.isEmpty()) {
      HashSet states2 = (HashSet) states.clone();
      Iterator it = states2.iterator();
      while (it.hasNext()) {
        PDMState state = (PDMState) it.next();
        HashSet nextStates = calculateNextStates(state, result, root, failure, numStates, breadth);
        Iterator it2 = nextStates.iterator();
        // Add the new states to iterator
        while (it2.hasNext()) {
          PDMState st = (PDMState) it2.next();
          states.add(st);
        }
        states.remove(state);
      }
    }
    i = 0;
    j = 0;
    Message.add("<PDMMDPStateSpace>", Message.TEST);
    Message.add("<NumberOfStates = " + result.getNumberOfStates() + " >", Message.TEST);
    Message.add("</PDMMDPStateSpace>", Message.TEST);
    return result;
  }
Esempio n. 19
0
  public HashSet calculateExecutableOperations(
      HashSet dataElts, HashSet executed, HashSet failed, boolean root) {
    HashSet result = new HashSet();
    HashSet enabledOperations = new HashSet();

    if (root) {
      // Calculate the enabled operations (i.e. those operation of which
      // all input elements are in the set of available elements)
      Object[] ops = operations.values().toArray();
      for (int i = 0; i < ops.length; i++) {
        PDMOperation op = (PDMOperation) ops[i];
        HashMap inputs = op.getInputElements();
        Object[] ins = inputs.values().toArray();
        boolean enabled = true;
        int k = 0;
        while (enabled && k < ins.length) {
          PDMDataElement d = (PDMDataElement) ins[k];
          if (!(dataElts.contains(d))) {
            enabled = false;
          }
          k++;
        }
        if (enabled) {
          enabledOperations.add(op);
          // System.out.println("Enabled operation: "+ op.getID());
        }
      }
    } else if (!(dataElts.contains(this.getRootElement()))) {
      // Calculate the enabled operations (i.e. those operation of which
      // all input elements are in the set of available elements)
      Object[] ops = operations.values().toArray();
      for (int i = 0; i < ops.length; i++) {
        PDMOperation op = (PDMOperation) ops[i];
        HashMap inputs = op.getInputElements();
        Object[] ins = inputs.values().toArray();
        boolean enabled = true;
        int k = 0;
        while (enabled && k < ins.length) {
          PDMDataElement d = (PDMDataElement) ins[k];
          if (!(dataElts.contains(d))) {
            enabled = false;
          }
          k++;
        }
        if (enabled) {
          enabledOperations.add(op);
        }
      }
    }
    // remove already executed operations
    Iterator exIt = executed.iterator();
    while (exIt.hasNext()) {
      PDMOperation op = (PDMOperation) exIt.next();
      enabledOperations.remove(op);
    }
    // remove already failed operations
    Iterator fIt = failed.iterator();
    while (fIt.hasNext()) {
      PDMOperation op = (PDMOperation) fIt.next();
      enabledOperations.remove(op);
    }
    result = enabledOperations;
    return result;
  }
Esempio n. 20
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());
    }
  }
Esempio n. 21
0
 /**
  * Returns the Data Element with identifier "id"
  *
  * @param id String
  * @return PDMDataElement
  */
 public PDMDataElement getDataElement(String id) {
   return (PDMDataElement) dataElements.get(id);
 }