Example #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;
 }
Example #2
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;
 }
Example #3
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;
 }