public String toString() { return "State for " + cc.getId(); }
/** * Extracts the label from a given ConceptClass. * * @param cc * ConceptClass * @return String */ private String getLabel(ConceptClass cc) { String label = null; // first try fullname of cc label = cc.getFullname(); // else take id of cc if (label.trim().length() == 0) { label = cc.getId(); } return label; }
/** * Cast a given ConceptClass into a BerkeleyConceptClass. * * @param old * ConceptClass * @return BerkeleyConceptClass */ protected static BerkeleyConceptClass convert(ConceptClass old) { BerkeleyConceptClass nu = new BerkeleyConceptClass(old.getSID(), old.getId(), old.getFullname(), old.getDescription(), old.getSpecialisationOf()); return nu; }
/** * Returns a JLabel for the concept class */ @Override public Object getElementAt(int index) { JLabel label = null; if (index > -1) { ConceptClass cc = conceptClasses.get(index); String name = cc.getFullname(); if (name.trim().length() == 0) name = cc.getId(); label = new JLabel(name); label.setName(cc.getId()); label.setToolTipText("(" + cc.getId() + ") " + cc.getDescription()); } return label; }
/** * Returns node shape code for a given ConceptClass. * * @param cc * ConceptClass * @return shape code */ public static int getShapeForConceptClass(ConceptClass cc) { String key = "ConceptClass.Shape." + cc.getId(); if (visual.getProperty(key) != null) { return Integer.valueOf(visual.getProperty(key)); } else { // maybe parent concept class exist in mapping ConceptClass parent = cc.getSpecialisationOf(); if (parent != null) { return getShapeForConceptClass(parent); } } return defaultShape; }
@Override public boolean isAssignableFrom(ConceptClass cc) { ConceptClass curr = cc; while (!curr.equals(this)) { curr = curr.getSpecialisationOf(); if (curr == null) { return false; } } return true; }
/** * returns the name of the current variable. */ public String getVariableName() { if (variable instanceof AttributeName) return ((AttributeName) variable).getFullname(); else if (variable instanceof ConceptClass) return ((ConceptClass) variable).getFullname(); else if (variable instanceof RelationType) return ((RelationType) variable).getFullname(); else if (variable instanceof String) return (String) variable; else return null; }
/** * Returns node size for a given ConceptClass * * @param cc * ConceptClass * @return node size */ public static Integer getSizeForConceptClass(ConceptClass cc) { String key = "ConceptClass.Size." + cc.getId(); if (visual.getProperty(key) != null) { return Integer.valueOf(visual.getProperty(key)); } else { // maybe parent concept class exist in mapping ConceptClass parent = cc.getSpecialisationOf(); if (parent != null) { return getSizeForConceptClass(parent); } } return defaultNodeSize; }
/** * Returns whether this concept class is a transitive superclass of * <code>cc</code>. */ @Override public boolean isAssignableFrom(ConceptClass cc) { ConceptClass curr = cc; while (!curr.equals(this)) { curr = curr.getSpecialisationOf(); if (curr == null) { return false; } } return true; }
else name = concept.getOfType().getFullname();
/** * Generate metadata for Concept Class. * @param cc * A Concept Class (from the Ondex API). * @return String * String containing full name or id. */ private String/*JSONObject*/ buildConceptClass(ConceptClass cc) { String ofType; /* JSONObject ccJson= new JSONObject(); ccJson.put(JSONAttributeNames.ID, cc.getId()); ccJson.put(JSONAttributeNames.FULLNAME, cc.getFullname()); ccJson.put(JSONAttributeNames.DESCRIPTION, cc.getDescription()); // ConceptClass SpecialisationOf (optional). ConceptClass spec= cc.getSpecialisationOf(); if(spec != null) { ccJson.put(JSONAttributeNames.SPECIALISATIONOF, buildConceptClass(spec)); } */ if(cc.getFullname().equals("")) { ofType= cc.getId(); } else { ofType= cc.getFullname(); } return ofType/*ccJson*/; }
/** * @param ccs * @param omd * copy from MetaData * @param nomd * copy to MetaData */ private void copyConceptClasses(Iterable<ConceptClass> ccs, ONDEXGraphMetaData omd, ONDEXGraphMetaData nomd) { // "specializations_of"s that occur before there specialization HashSet<ConceptClass> ccDependencyNotResolved = new HashSet<ConceptClass>(); for (ConceptClass cc : ccs) { ConceptClass ccSpec = cc.getSpecialisationOf(); ConceptClass newCCSpec = null; if (ccSpec != null) { newCCSpec = nomd.getConceptClass(ccSpec.getId()); if (newCCSpec == null) { ccDependencyNotResolved.add(cc); continue; } } if (!nomd.checkConceptClass(cc.getId())) nomd.createConceptClass(cc.getId(), cc.getFullname(), cc .getDescription(), newCCSpec); } // recursively resolve specialisations if (ccDependencyNotResolved.size() > 0) { copyConceptClasses(ccDependencyNotResolved, omd, nomd); } }
/** * Returns node color for a given ConceptClass. * * @param cc * ConceptClass * @return Color */ public static Color getColorForConceptClass(ConceptClass cc) { String key = "ConceptClass.Color." + cc.getId(); if (visual.getProperty(key) != null) { return convertToColor(visual.getProperty(key)); } else { // maybe parent concept class exist in mapping ConceptClass parent = cc.getSpecialisationOf(); if (parent != null) { return getColorForConceptClass(parent); } } return defaultColor; }
private boolean instanceOf(ConceptClass cc, ONDEXConcept c) { ConceptClass cc_query = c.getOfType(); while (!cc_query.equals(cc)) { if (cc_query.getSpecialisationOf() == null) { return false; } cc_query = cc_query.getSpecialisationOf(); } return true; }
/** * adds a concept class filter to the list of filters. * * @param cc * the concept class to filter for */ public void addCCFilter(ConceptClass cc) { ccFilters.add(cc.getId()); }
/** * Generate metadata for Concept Class. * @param cc * A Concept Class (from the Ondex API). * @return JSONObject * JSONObject containing information about the Concept Class. */ private String/*JSONObject*/ buildConceptClass(ConceptClass cc) { String ofType; /* JSONObject ccJson= new JSONObject(); ccJson.put(JSONAttributeNames.ID, cc.getId()); ccJson.put(JSONAttributeNames.FULLNAME, cc.getFullname()); ccJson.put(JSONAttributeNames.DESCRIPTION, cc.getDescription()); // ConceptClass SpecialisationOf (optional). ConceptClass spec= cc.getSpecialisationOf(); if(spec != null) { ccJson.put(JSONAttributeNames.SPECIALISATIONOF, buildConceptClass(spec)); } */ if(cc.getFullname().equals("")) { ofType= cc.getId(); } else { ofType= cc.getFullname(); } return ofType/*ccJson*/; }
/** * Constructs user input to add a ConceptClass. * * @param aog * AbstractONDEXGraph to add to * @param conceptClass * Concept Class to use */ public DialogConceptClass(ONDEXGraph aog, ConceptClass conceptClass) { super("Dialog.ConceptClass.Title", "Properties16.gif"); this.aog = aog; initSpecialisationOf(); // set existing information id.setText(conceptClass.getId()); fullname.setText(conceptClass.getFullname()); description.setText(conceptClass.getDescription()); ConceptClass specialisation = conceptClass.getSpecialisationOf(); if (specialisation != null) specialisationOf.setSelectedItem(specialisation.getId()); // set everything to disabled id.setEditable(false); fullname.setEditable(false); description.setEnabled(false); specialisationOf.setEnabled(false); this.getContentPane().setLayout(new BorderLayout()); this.getContentPane().add(makeProperties(), BorderLayout.CENTER); this.getContentPane().add(makeButtonsPanel(null, "Dialog.ConceptClass.Cancel"), BorderLayout.SOUTH); this.pack(); }
ConceptClass sp = cc.getSpecialisationOf(); if (sp != null) { String spid = sp.getId(); clause.append(map); clause.append("(A,B,C,D,E) :- "); String id = cc.getId(); map = makeLower(cc.getId()); if (ccMapping.containsKey(id)) map = ccMapping.get(id);
/** * returns whether the ConceptClass <code>subClass</code> equals or is a subclass of * the ConceptClass <code>superClass</code> * * @param subClass the potential subclass * @param superClass the potential superclass * @return the above. */ private boolean inherited(ConceptClass subClass, ConceptClass superClass) { ConceptClass cc_curr = subClass; while (!cc_curr.equals(superClass)) { cc_curr = cc_curr.getSpecialisationOf(); if (cc_curr == null) { return false; } } return true; }