/* private void addEvaInverse(EVA ownerEva, ClassDef ownerEvaClass, WDBObject ownerEvaObject, ParserAdapter scda) throws Exception { //Try to see if other class's inverse EVA is declared on my side ClassDef myClass = this.getClassDef(scda); Attribute myAttribute = myClass.getAttribute(ownerEva.inverseEVA); if(myAttribute != null && myAttribute.getClass() == EVA.class) { //Oh it is, good. Use the declared settings if(((EVA)myAttribute).cardinality == EVA.MULTIVALUED) { ArrayList targetObjectList = ((ArrayList)this.evaObjects.get(myAttribute.name)); if(targetObjectList == null) { targetObjectList = new ArrayList(); } targetObjectList.add(ownerEvaObject.getUid()); this.evaObjects.put(myAttribute.name, targetObjectList); } else if(((EVA)myAttribute).cardinality == EVA.SINGLEVALUED) { //For singlevalued EVAs, just put the UID as the value; this.evaObjects.put(myAttribute.name, ownerEvaObject.getUid()); } else { throw new NoSuchFieldException("Attribute \"" + myAttribute.name + "\" uses a invalid cardinality"); } } else { throw new Exception("Implication of target class inverse EVAs is not implemented"); //The inverse EVA is not defined in this class or there is no inverse EVA specified //We have to infer the cardinality of our inverse based on the cardinality EVA from the owner's class if(ownerEva.cardinality == EVA.SINGLEVALUED) { //Imply MV UNIQUE if(myAttribute != null) { ArrayList targetObjectList = ((ArrayList)this.evaObjects.get(myAttribute.name)); if(targetObjectList == null) { targetObjectList = new ArrayList(); } targetObjectList.add(ownerEvaObject.getUid()); } } } this.commit(scda); } */ public WDBObject[] getEvaObjects(String evaName, ParserAdapter scda) throws Exception { ClassDef myClass = this.getClassDef(scda); Attribute myAttribute = myClass.getAttribute(evaName); WDBObject[] evaObjects = new WDBObject[0]; if (myAttribute != null && myAttribute.getClass() == EVA.class) { if (((EVA) myAttribute).cardinality.equals(EVA.MULTIVALUED)) { ArrayList<Object> targetObjectList = ((ArrayList) this.evaObjects.get(evaName)); ArrayList<WDBObject> targetObjects = new ArrayList<WDBObject>(); if (targetObjectList != null) { for (int i = 0; i < targetObjectList.size(); i++) { String[] targetKey = ((String) targetObjectList.get(i)).split(":"); String targetClass = targetKey[0]; Integer targetUid = Integer.valueOf(targetKey[1]); WDBObject targetObject = scda.getObject(targetClass, targetUid); targetObjects.add(targetObject); } evaObjects = ((WDBObject[]) targetObjects.toArray(evaObjects)); } } else if (((EVA) myAttribute).cardinality.equals(EVA.SINGLEVALUED)) { if (this.evaObjects.get(evaName) != null) { String[] targetKey = ((String) this.evaObjects.get(evaName)).split(":"); String targetClass = targetKey[0]; Integer targetUid = Integer.valueOf(targetKey[1]); WDBObject targetObject = scda.getObject(targetClass, targetUid); if (targetObject != null) { WDBObject[] targetObjs = {((WDBObject) targetObject)}; evaObjects = targetObjs; } } } else { throw new NoSuchFieldException("Attribute \"" + evaName + "\" uses a invalid cardinality"); } } else if (myClass.getClass() == SubclassDef.class) { Enumeration e = parents.keys(); while (true) { try { String parentClass = (String) e.nextElement(); Integer parentUid = (Integer) parents.get(parentClass); WDBObject parent = scda.getObject(parentClass, parentUid); return parent.getEvaObjects(evaName, scda); // If we reached here, we get our value. Get out of here // break; } catch (NoSuchFieldException nsfe) { // Can't find DVA going up that parent's heirarchy. Continue on to another parent if (!e.hasMoreElements()) { // No more parents to try. We are here if we exausted our parent's list and // still can't find the DVA. Throw exception throw nsfe; } } } } // value can't be found and I'm not a subclass. It doesn't exist in this heirarchy else { throw new NoSuchFieldException("Attribute \"" + evaName + "\" is not a valid EVA"); } return evaObjects; }