/** * Constructor sets Attribute. * * @param attribute * Attribute */ public GDSTableModel(Attribute attribute) { if (attribute != null) { this.attribute = attribute; this.dataType = attribute.getOfType().getDataTypeAsString(); } }
/** * Indexes all given attributes by their attribute name and add them to the * set of attributes. * * @param attributesMap * @param attributes */ private void fillAttributeIndex( Map<AttributeName, Set<Attribute>> attributesMap, Set<Attribute> attributes) { // iterate over every attribute for (Attribute attribute : attributes) { // add attribute to set indexed by attribute name AttributeName attName = attribute.getOfType(); if (!attributesMap.containsKey(attName)) attributesMap.put(attName, new HashSet<Attribute>()); attributesMap.get(attName).add(attribute); } }
@Override public int compareTo(Attribute o) { return this.attrname.compareTo(o.getOfType()); }
/** * Return all of attribute names of the relations * contained in the collection * * @param cs * @return set of attribute names */ public static Set<AttributeName> getRelationAttNames(Collection<ONDEXRelation> cs) { Set<AttributeName> result = new HashSet<AttributeName>(); for (ONDEXRelation c : cs) { for (Attribute g : c.getAttributes()) { result.add(g.getOfType()); } } return result; }
/** * Return all of attribute names of the concepts * contained in the collection * * @param cs * @return set of attribute names */ public static Set<AttributeName> getConceptAttNames(Collection<ONDEXConcept> cs) { Set<AttributeName> result = new HashSet<AttributeName>(); for (ONDEXConcept c : cs) { for (Attribute g : c.getAttributes()) { result.add(g.getOfType()); } } return result; }
/** * Return all of attribute names of the concepts * contained in the collection * * @param cs * @return set of attribute names */ public static Set<AttributeName> getConceptAttNames(Collection<ONDEXConcept> cs) { Set<AttributeName> result = new HashSet<AttributeName>(); for (ONDEXConcept c : cs) { for (Attribute g : c.getAttributes()) { result.add(g.getOfType()); } } return result; }
/** * Return all of attribute names of the relations * contained in the collection * * @param cs * @return set of attribute names */ public static Set<AttributeName> getRelationAttNames(Collection<ONDEXRelation> cs) { Set<AttributeName> result = new HashSet<AttributeName>(); for (ONDEXRelation c : cs) { for (Attribute g : c.getAttributes()) { result.add(g.getOfType()); } } return result; }
private void step() { boolean match = false; next = null; while (!match && view.hasNext()) { ONDEXConcept r = view.next(); List<String> gds = new ArrayList<String>(); for (Attribute g : r.getAttributes()) { String name = g.getOfType().getId(); if (validArgs.contains(name)) gds.add(name); } if (gds.size() > 0) { match = true; next = gds.toArray(new String[gds.size()]); } } } }
/** * Generate metadata for Attribute. * @param attr * An Attribute (from the Ondex API). * @return JSONObject * JSONObject containing information about the Attribute including its Attribute Name, * Unit(s) & SpecialisationOf. */ private JSONObject buildAttribute(Attribute attr) { JSONObject attrJson= new JSONObject(); attrJson.put(JSONAttributeNames.ATTRIBUTENAME, buildAttributeName(attr.getOfType())); // Attribute value (can be a String or any other data type or an Object or a Java class instance). attrJson.put(JSONAttributeNames.VALUE, attr.getValue().toString()); /** ^^using String for now. */ // attrJson.put(JSONAttributeNames.DOINDEX, String.valueOf(attr.isDoIndex())); return attrJson; }
private void step() { boolean match = false; next = null; while (!match && view.hasNext()) { ONDEXRelation r = view.next(); List<String> gds = new ArrayList<String>(); for (Attribute g : r.getAttributes()) { String name = g.getOfType().getId(); if (validArgs.contains(name)) gds.add(name); } if (gds.size() > 0) { match = true; next = gds.toArray(new String[gds.size()]); } } } }
/** * Generate metadata for Attribute. * @param attr * An Attribute (from the Ondex API). * @return JSONObject * JSONObject containing information about the Attribute including its Attribute Name, * Unit(s) & SpecialisationOf. */ private JSONObject buildAttribute(Attribute attr) { JSONObject attrJson= new JSONObject(); attrJson.put(JSONAttributeNames.ATTRIBUTENAME, buildAttributeName(attr.getOfType())); // Attribute value (can be a String or any other data type or an Object or a Java class instance). attrJson.put(JSONAttributeNames.VALUE, attr.getValue().toString()); /** ^^ fix this. */ attrJson.put(JSONAttributeNames.DOINDEX, String.valueOf(attr.isDoIndex())); return attrJson; }
@Override public boolean equals(Object o) { if (o == null) return false; if (o == this) return true; if (!(o instanceof Attribute)) return false; Attribute attribute = (Attribute) o; return getOfType().equals(attribute.getOfType()) && getValue().equals(attribute.getValue()); }
@Override public int compareTo(Attribute o) { return getOfType().compareTo(o.getOfType()); }
@Override public int compareTo(Attribute o) { return this.getOfType().compareTo(o.getOfType()); }
@Override public int compareTo(Attribute o) { return this.getOfType().compareTo(o.getOfType()); }
/** * Creates a gds on concept only if it does not already exists * * @param target * - relation * @param newAttribute * - attribute to create * @throws AccessDeniedException * @throws NullValueException */ public static void addNewAttribute(ONDEXConcept target, Attribute newAttribute) throws NullValueException, AccessDeniedException { if (target.getAttribute(newAttribute.getOfType()) == null) target.createAttribute(newAttribute.getOfType(), newAttribute.getValue(), newAttribute.isDoIndex()); }
/** * Creates a gds on relation only if it does not already exists * * @param target * - relation * @param newAttribute * - attribute to create * @throws AccessDeniedException * @throws NullValueException */ public static void addNewAttribute(ONDEXRelation target, Attribute newAttribute) throws NullValueException, AccessDeniedException { if (target.getAttribute(newAttribute.getOfType()) == null) target.createAttribute(newAttribute.getOfType(), newAttribute.getValue(), newAttribute.isDoIndex()); }
/** * Copies all Attribute from old concept to new concept. * * @param oldC * old ONDEXConcept * @param newC * new ONDEXConcept */ private void copyGDS(ONDEXConcept oldC, ONDEXConcept newC) { // iterate over all old Attribute for (Attribute attribute : oldC.getAttributes()) { // clone old Attribute on new concept newC.createAttribute(attribute.getOfType(), attribute.getValue(), attribute.isDoIndex()); } }
/** * Cast a given Attribute into a BerkeleyConceptAttribute. * * @param old * Attribute * @return BerkeleyConceptAttribute */ protected static BerkeleyConceptAttribute convert(Attribute old) { BerkeleyConceptAttribute nu = new BerkeleyConceptAttribute( old.getSID(), old.getOwnerId(), old.getOfType(), old.getValue(), old.isDoIndex()); return nu; }
/** * Cast a given Attribute into a BerkeleyRelationAttribute. * * @param old * Attribute * @return BerkeleyRelationAttribute */ protected static BerkeleyRelationAttribute convert(Attribute old) { BerkeleyRelationAttribute nu = new BerkeleyRelationAttribute( old.getSID(), old.getOwnerId(), old.getOfType(), old.getValue(), old.isDoIndex()); return nu; }