/** * Generate metadata for Relation Type. * @param rt * Relation Type (from the Ondex API). * @return JSONObject * JSONObject containing information about the Relation Type. */ private JSONObject buildRelationType(RelationType rt) { JSONObject rtJson= new JSONObject(); rtJson.put(JSONAttributeNames.ID, rt.getId()); rtJson.put(JSONAttributeNames.FULLNAME, rt.getFullname()); rtJson.put(JSONAttributeNames.INVERSENAME, rt.getInverseName()); rtJson.put(JSONAttributeNames.ISANTISYMMETRIC, String.valueOf(rt.isAntisymmetric())); rtJson.put(JSONAttributeNames.ISREFLEXTIVE, String.valueOf(rt.isReflexive())); rtJson.put(JSONAttributeNames.ISTRANSITIVE, String.valueOf(rt.isTransitiv())); rtJson.put(JSONAttributeNames.ISSYMMETRIC, String.valueOf(rt.isSymmetric())); rtJson.put(JSONAttributeNames.DESCRIPTION, rt.getDescription()); // RelationType SpecialisationOf (optional). RelationType spec= rt.getSpecialisationOf(); if(spec != null) { rtJson.put(JSONAttributeNames.SPECIALISATIONOF, buildRelationType(spec)); } return rtJson; }
specialisationOf.setSelectedItem(relationType.getSpecialisationOf().getId()); antisym.setSelectedItem(Boolean.valueOf(relationType.isAntisymmetric())); reflexive.setSelectedItem(Boolean.valueOf(relationType.isReflexive())); sym.setSelectedItem(Boolean.valueOf(relationType.isSymmetric()));
nomd.createRelationType(rt.getId(), rt.getFullname(), rt .getDescription(), rt.getInverseName(), rt .isAntisymmetric(), rt.isReflexive(), rt.isSymmetric(), rt.isTransitiv(), newSpec);
/** * Cast a given RelationType into a BerkeleyRelationType. * * @param old * RelationType * @return BerkeleyRelationType */ protected static BerkeleyRelationType convert(RelationType old) { BerkeleyRelationType nu = new BerkeleyRelationType(old.getSID(), old.getId(), old.getFullname(), old.getDescription(), old.getInverseName(), old.isAntisymmetric(), old.isReflexive(), old.isSymmetric(), old.isTransitiv(), old.getSpecialisationOf()); return nu; }
xmlw.writeEndElement(); boolean isAntisymmetric = rt.isAntisymmetric(); xmlw.writeStartElement(XMLTagNames.ISANTISYMMETRIC); xmlw.writeCharacters(String.valueOf(isAntisymmetric));