/** * 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; }
anDesc = an.getDescription(); className = an.getDataTypeAsString(); selectedUnit = an.getUnit(); selectedAn = an.getSpecialisationOf();
.map ( aname -> aname.getId () + Optional.ofNullable ( aname.getUnit () ).map ( u -> u.getId () ).orElse ( "" ) + ObjectUtils.defaultIfNull ( aname.getDataTypeAsString (), "_" )
if (attNew == null) attNew = ondexMetaData.createAttributeName(name, att.getFullname(), att.getDescription(), att.getUnit(), att.getDataType(), att.getSpecialisationOf()); return attNew;
/** * 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; }
/** * @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); } }
xmlw.writeEndElement(); Unit unit = attr.getUnit();