/** * 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()); }
private void copyCVToRelation(ONDEXConcept to, ONDEXRelation relation, AttributeName att) { DataSource dataSource = to.getElementOf(); String[] typeIds = dataSource.getId().split(":"); for (String typeId : typeIds) { Attribute attribute = relation.getAttribute(att); if (attribute == null) { relation.createAttribute(att, typeId, false); } else if (attribute.getValue() instanceof Collection) { Collection collection = (Collection) attribute.getValue(); if (!collection.contains(typeId)) { collection.add(typeId); attribute.setValue(collection); } } else if (!attribute.getValue().equals(typeId)) { List<String> cvs = new ArrayList<String>(2); cvs.add(typeId); cvs.add((String) attribute.getValue()); attribute.setValue(cvs); } } }
/** * 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; }
/** * Constructor sets Attribute. * * @param attribute * Attribute */ public GDSTableModel(Attribute attribute) { this.attribute = attribute; this.o = attribute.getValue(); if (this.o instanceof Protein3dStructure) this.structure = (Protein3dStructure) o; }
AttributeName oldAttName = oldAtt.getOfType(); newRelation.createAttribute(oldAttName, oldAtt.getValue(), oldAtt.isDoIndex()); } else if (oldAtt.getValue() instanceof Collection && existingAtt.getValue() instanceof Collection) { Collection<?> oldCol = (Collection<?>) oldAtt.getValue(); .getValue(); existingAtt.setValue(set); } else if (!(oldAtt.getValue() instanceof Collection && existingAtt .getValue() instanceof Collection)) { newRelation.createAttribute(newAttName, oldAtt.getValue(), oldAtt.isDoIndex()); + oldAtt.getOfType().getId());
/** * Constructor sets Attribute. * * @param attribute * Attribute */ public GDSTableModel(Attribute attribute) { if (attribute != null) { this.attribute = attribute; this.dataType = attribute.getOfType().getDataTypeAsString(); } }
if(attribute.getOfType().getId().equals("AA") || attribute.getOfType().getId().equals("NA")){ continue; if(attribute.getOfType().getId().startsWith("AA_") || attribute.getOfType().getId().startsWith("NA_")){ continue; String value = attribute.getValue().toString(); attribute.setValue(newGDS); found = true;
public void setValueAt(Object value, int row, int col) { attribute.setValue(value); fireTableCellUpdated(row, col); } }
/** * Modify given concept Attribute * * @param attribute * Attribute to modify */ public GDSPopup(Attribute attribute) { this.attribute = attribute; // editor panel BoxLayout layout = new BoxLayout(this, BoxLayout.LINE_AXIS); this.setLayout(layout); // check box for do index box = new JCheckBox("Do index this Attribute?"); box.setSelected(attribute.isDoIndex()); this.add(box); // button to close popup JButton close = new JButton("close"); close.addActionListener(this); this.add(close); }
public Object getValueAt(int row, int col) { return attribute.getValue(); }
/** * 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; }
/** * 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); } }
/** * 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; }
/** * Determines the type of Attribute data. * * @param data * Attribute * @param clause * StringBuffer */ private void decideCompose(Attribute data, StringBuffer clause) { Object o = data.getValue(); if (o instanceof Number) { composeNumber((Number) o, clause); } else if (o instanceof Boolean) { composeBoolean((Boolean) o, clause); } else if (o instanceof String) { composeString((String) o, clause); } else { composeObject(o, clause); } clause.append(data.isDoIndex()); clause.append(").\n"); }
private void addAttribute(Object value, Attribute attribute, ONDEXRelation relation, AttributeName att) { if (value != null) { if (attribute == null) { relation.createAttribute(att, value, false); } else { attribute.setValue(value); } } }
public static void changeAttributeValue(ONDEXEntity e, AttributeName n, Object value) { if (e instanceof ONDEXConcept) { ONDEXConcept c = (ONDEXConcept) e; boolean doIndex = c.getAttribute(n).isDoIndex(); c.deleteAttribute(n); c.createAttribute(n, value, doIndex); } if (e instanceof ONDEXRelation) { ONDEXRelation r = (ONDEXRelation) e; boolean doIndex = r.getAttribute(n).isDoIndex(); r.deleteAttribute(n); r.createAttribute(n, value, doIndex); } else { throw new IllegalArgumentException( "This method only works with Ondex concepts and relations."); } }
/** * 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()); }
public Object getValueAt(int row, int col) { return attribute.getValue(); }