コード例 #1
0
ファイル: PDMModel.java プロジェクト: CaoAo/BeehiveZ
 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;
 }
コード例 #2
0
ファイル: PDMModel.java プロジェクト: CaoAo/BeehiveZ
 /**
  * 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;
 }
コード例 #3
0
ファイル: PDMModel.java プロジェクト: CaoAo/BeehiveZ
  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;
  }