public static String getAttributeByName(GraphEntity ge, String attributeName) { for (GraphAttribute ga : ge.getAllAttrs()) { if (ga.getName().equals(attributeName)) { return ga.getSimpleValue(); } } return ""; }
public static String getAttributeByName(GraphEntity ge, String attributeName, String defaultValue) { for (GraphAttribute ga : ge.getAllAttrs()) { if (ga.getName().equals(attributeName)) { return (ga.getSimpleValue().equals("")) ? defaultValue : ga.getSimpleValue(); } } return defaultValue; }
private static void evaluateSimpleValueField(GraphEntity ent1, Vector<String> differences, GraphAttribute gaE1, GraphAttribute gaE2) { boolean found; String simpleValue1=null; String simpleValue2=null; simpleValue1=gaE1.getSimpleValue(); simpleValue2=gaE2.getSimpleValue(); if (simpleValue1==null && simpleValue1==null){ found=true; } else if (simpleValue1==null && simpleValue2!=null){ differences.add("entity " +ent1.getID()+":"+ent1.getType()+" has a null value for attribute "+ gaE1.getName()+" instead the second spec has "+simpleValue2); } else if (simpleValue1!=null && simpleValue2==null){ differences.add("entity " +ent1.getID()+":"+ent1.getType()+" has not the same values for attribute "+ gaE1.getName()+":"+simpleValue1+" instead the second spec has null"); } else if (simpleValue1!=null && simpleValue2!=null && !simpleValue1.equals(simpleValue2)){ differences.add("entity " +ent1.getID()+":"+ent1.getType()+" has a value \""+simpleValue1+"\" for attribute "+ gaE1.getName()+" instead the second spec has \""+simpleValue2+"\""); } }
boolean found=false; GraphAttribute gaE1=attsEnt1[k]; if (!gaE1.getName().equalsIgnoreCase("prefs")){ for (int j=0;j<attsEnt2.length && !found;j++) { GraphAttribute gaE2=attsEnt2[j]; if (gaE1.getName().equals(gaE2.getName())){ if (gaE1.isSimpleValue() && gaE2.isSimpleValue()){ evaluateSimpleValueField(ent1, differences, gaE1, gaE2); differences, gaE1, gaE2); else { differences.add("entity "+ent1.getID()+":"+ent1.getType()+" has an attribute named "+gaE1.getName()+" with different type in the second spec");
public void setAttribute(GraphAttribute ga) throws InvalidAttribute{ try { GraphAttribute oldga=this.getAttributeByName(ga.getName()); ((GraphAttributeImp)oldga).setValue(((GraphAttributeImp)ga).getValue()); Object nvalue=((GraphAttributeImp)ga).getValue(); Class nvalueclass=((TypedVector)nvalue).getType(); Class entclass=this.ent.getClass(); Method m=entclass.getMethod("add"+ga.getName(), new Class[]{nvalueclass}); TypedVector tv=(TypedVector)nvalue; Method m=entclass.getMethod("set"+ga.getName(), new Class[]{nvalue.getClass()});
if (entValue1!=null && entValue2==null){ differences.add("entity " +ent1.getID()+":"+ent1.getType()+" has not the same values for attribute "+ gaE1.getName()+":"+entValue1+" instead the second spec has null"); } else if (entValue1==null && entValue2!=null){ differences.add("entity " +ent1.getID()+":"+ent1.getType()+" has not the same values for attribute "+ gaE1.getName()+":null instead the second spec has \""+entValue2+"\""); } else if (entValue1!=null && entValue2!=null){
if (colValue1==null && colValue2!=null){ differences.add("entity " +ent1.getID()+":"+ent1.getType()+" has a null value for attribute "+ gaE1.getName()+" instead the second spec has "+colValue2); } else if (colValue1!=null && colValue2==null){ differences.add("entity " +ent1.getID()+":"+ent1.getType()+" has not the same values for attribute "+ gaE1.getName()+":"+colValue1+" instead the second spec has null"); } else if (colValue1!=null && colValue2!=null && } else { differences.add("entity " +ent1.getID()+":"+ent1.getType()+" has not the same number of values for attribute "+ gaE1.getName()+" with "+colValue1.size()+" instead the second spec has "+colValue2.size()+" elements");