/* * 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; }
/** * 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; }
/** * 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); }
/** * 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); }
/** * 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); }