/** * Returns a JLabel for the attribute name */ @Override public Object getElementAt(int index) { JLabel label = null; if (attributeNames.size() == 0 && index == 0) { label = new JLabel("no attributes present!"); } else if (index > -1) { AttributeName an = attributeNames.get(index); String name = an.getFullname(); if (name.trim().length() == 0) name = an.getId(); label = new JLabel(name); label.setName(an.getId()); label.setToolTipText("(" + an.getId() + ") " + an.getDescription()); } return label; }
/** * Generate metadata for Attribute Name. * @param attr * An AttributeName (from the Ondex API). * @return JSONObject * JSONObject containing information about the Attribute. */ private JSONObject buildAttributeName(AttributeName attrName) { JSONObject attrNameJson= new JSONObject(); attrNameJson.put(JSONAttributeNames.ID, attrName.getId()); attrNameJson.put(JSONAttributeNames.FULLNAME, attrName.getFullname()); // Attribute Unit (optional). Unit attrUnit= attrName.getUnit(); if(attrUnit != null) { attrNameJson.put(JSONAttributeNames.UNIT, buildUnit(attrUnit)); } attrNameJson.put(JSONAttributeNames.DATATYPE, attrName.getDataTypeAsString()); attrNameJson.put(JSONAttributeNames.DESCRIPTION, attrName.getDescription()); // Attribute SpecialisationOf (optional). AttributeName spec= attrName.getSpecialisationOf(); if(spec != null) { attrNameJson.put(JSONAttributeNames.SPECIALISATIONOF, buildAttributeName(spec)); } return attrNameJson; }
anID = an.getId(); anFull = an.getFullname(); anDesc = an.getDescription(); className = an.getDataTypeAsString(); selectedUnit = an.getUnit();
if (attNew == null) attNew = ondexMetaData.createAttributeName(name, att.getFullname(), att.getDescription(), att.getUnit(), att.getDataType(), att.getSpecialisationOf()); return attNew;
/** * @param attNames * @param omd * copy from MetaData * @param nomd * copy to MetaData */ private void copyAttributeNames(Iterable<AttributeName> attNames, ONDEXGraphMetaData omd, ONDEXGraphMetaData nomd) { // "specializations_of"s that occur before there specialisation HashSet<AttributeName> atDependencyNotResolved = new HashSet<AttributeName>(); for (AttributeName att : attNames) { AttributeName spec = att.getSpecialisationOf(); AttributeName newSpec = null; if (spec != null) { newSpec = nomd.getAttributeName(spec.getId()); if (newSpec == null) { atDependencyNotResolved.add(att); continue; } } if (!nomd.checkAttributeName(att.getId())) nomd.createAttributeName(att.getId(), att.getFullname(), att .getDescription(), att.getUnit(), att.getDataType(), newSpec); } if (atDependencyNotResolved.size() > 0) { copyAttributeNames(atDependencyNotResolved, omd, nomd); } }
/** * Cast a given AttributeName into a BerkeleyAttributeName. * * @param old * AttributeName * @return BerkeleyAttributeName */ protected static BerkeleyAttributeName convert(AttributeName old) { BerkeleyAttributeName nu = new BerkeleyAttributeName(old.getSID(), old.getId(), old.getFullname(), old.getDescription(), old.getUnit(), old.getDataTypeAsString(), old.getSpecialisationOf()); return nu; }
xmlw.writeCharacters(attr.getDescription()); xmlw.writeEndElement();