@Override public int compare(ConceptName o1, ConceptName o2) { if (o1.isPreferred() && !o2.isPreferred()) return -1; else if (!o1.isPreferred() && o2.isPreferred()) return 1; else return o1.getName().compareTo(o2.getName()); }
/** * Generate metadata for Concept Name. * @param coname * A Concept Name (from the Ondex API). * @return JSONObject * JSONObject containing information about the Concept Name. */ private JSONObject buildConceptName(ConceptName coname) { JSONObject conameJson= new JSONObject(); conameJson.put(JSONAttributeNames.NAME, coname.getName()); conameJson.put(JSONAttributeNames.ISPREFERRED, String.valueOf(coname.isPreferred())); return conameJson; }
/** * Generate metadata for Concept Name. * @param coname * A Concept Name (from the Ondex API). * @return JSONObject * JSONObject containing information about the Concept Name. */ private JSONObject buildConceptName(ConceptName coname) { JSONObject conameJson= new JSONObject(); conameJson.put(JSONAttributeNames.NAME, coname.getName()); conameJson.put(JSONAttributeNames.ISPREFERRED, String.valueOf(coname.isPreferred())); return conameJson; }
private String getShortestPreferredConceptName(Set<ConceptName> conames) { String shortest_coname=" "; int length= 100000; for(ConceptName coname : conames) { if((coname.isPreferred()) && (coname.getName() != null)) { // if((coname.getName().trim().length() >= 3) && (coname.getName().trim().length() <= 6)) { if(coname.getName().trim().length() <= length) { shortest_coname= coname.getName().trim(); // use this preferred concept name instead. length= shortest_coname.length(); } } } return shortest_coname; }
private String getShortestPreferredConceptName(Set<ConceptName> conames) { String shortest_coname=" "; int length= 100000; for(ConceptName coname : conames) { if((coname.isPreferred()) && (coname.getName() != null)) { // if((coname.getName().trim().length() >= 3) && (coname.getName().trim().length() <= 6)) { if(coname.getName().trim().length() <= length) { shortest_coname= coname.getName().trim(); // use this preferred concept name instead. length= shortest_coname.length(); } } } return shortest_coname; }
@Override protected ConceptName retrievePreferredConceptName() { for (ConceptName cn : retrieveConceptNameAll()) { if (cn.isPreferred()) { ((Updatable) cn).setUpdateListener(this); return cn; } } return null; }
private String getShortestPreferredConceptName(Set<ConceptName> conames) { String shortest_coname=" "; int length= 100000; for(ConceptName coname : conames) { // System.out.println("\t coname: "+ coname.getName().trim() +", isPreferred: "+ coname.isPreferred()); if((coname.isPreferred()) && (coname.getName() != null)) { // if((coname.getName().trim().length() >= 3) && (coname.getName().trim().length() <= 6)) { if(coname.getName().trim().length() <= length) { shortest_coname= coname.getName().trim(); // use this preferred concept name instead. length= shortest_coname.length(); } } } // System.out.println("\t shortest_coname: "+ shortest_coname); return shortest_coname; }
/** * Modify given concept name * * @param name * ConceptName to modify */ public ConceptNamePopup(ConceptName name) { this.name = name; // editor panel BoxLayout layout = new BoxLayout(this, BoxLayout.LINE_AXIS); this.setLayout(layout); // check box for preferred box = new JCheckBox("Is a preferred concept name?"); box.setSelected(name.isPreferred()); this.add(box); // button to close popup JButton close = new JButton("close"); close.addActionListener(this); this.add(close); }
private String getShortestPreferredConceptName(Set<ConceptName> conames) { String shortest_coname=" "; int length= 100000; for(ConceptName coname : conames) { // System.out.println("\t coname: "+ coname.getName().trim() +", isPreferred: "+ coname.isPreferred()); if((coname.isPreferred()) && (coname.getName() != null)) { // if((coname.getName().trim().length() >= 3) && (coname.getName().trim().length() <= 6)) { if(coname.getName().trim().length() <= length) { shortest_coname= coname.getName().trim(); // use this preferred concept name instead. length= shortest_coname.length(); } } } // System.out.println("\t shortest_coname: "+ shortest_coname); return shortest_coname; }
clause.append(quote(cn.getName())); clause.append("',"); clause.append(cn.isPreferred()); clause.append(").\n"); writer.write(clause.toString());
names.put(cn.getName(), cn.isPreferred());
public String getName(ONDEXConcept ac) { String label = ""; // get first preferred name as label for (ConceptName cn : ac.getConceptNames()) { if (cn.isPreferred()) { label = cn.getName(); break; } } // next try annotation if (label == null || label.trim().length() == 0) { label = ac.getAnnotation(); } // next try description if (label == null || label.trim().length() == 0) { label = ac.getDescription(); } // next try pid if (label == null || label.trim().length() == 0) { label = ac.getPID(); } // last resort to concept id if (label == null || label.trim().length() == 0) { label = String.valueOf(ac.getId()); } return label; }
/** * Copies all names from old concept to new concept. * * @param oldC * old ONDEXConcept * @param newC * new ONDEXConcept */ private void copyNames(ONDEXConcept oldC, ONDEXConcept newC) { // iterate over all old names for (ConceptName name : oldC.getConceptNames()) { // clone old name on new concept newC.createConceptName(name.getName(), name.isPreferred()); } }
public String getValue(ONDEXEntity cOrr) throws InvalidOndexEntityException { if(AbstractConcept.class.isAssignableFrom(cOrr.getClass())){ String preferedName = ""; for(ConceptName cn : ((ONDEXConcept)cOrr).getConceptNames()){ if(cn.isPreferred()){ preferedName = cn.getName(); } } if (preferedName.length() ==0) { preferedName = ((ONDEXConcept)cOrr).getPID(); } /** if (useLinks && preferedName.length() > 0 && ((AbstractConcept)cOrr).getElementOf().getId().endsWith("PlnTFDB")) { AbstractONDEXValidator validator = ONDEXRegistry.validators.get("htmlaccessionlink"); Condition condition = new Condition(((AbstractConcept)cOrr).getElementOf().getId(), ((AbstractConcept)cOrr).getOfType().getId()); String url = (String) validator.validate(condition); if (url != null) { return "=HYPERLINK(\""+url+preferedName +"\",\""+preferedName+"\")"; } } */ return preferedName; } throw new InvalidOndexEntityException(cOrr.getClass()+": is not an Ondex class for which a name is known"); }
if (cn != null) { String tmp = cn.getName().trim(); if (tmp.length() > 0 && cn.isPreferred()) { if (hasOneEntry) { sb.append("|"); if (cn != null) { String tmp = cn.getName().trim(); if (tmp.length() > 0 && !cn.isPreferred()) { if (hasOneEntry) { sb.append("|");
public static BerkeleyConceptName convert(ConceptName old) { long sid = old.getSID(); BerkeleyConceptName nu = new BerkeleyConceptName(sid, old.getOwnerId(), old.getName(), old.isPreferred()); return nu; }
@Override public Object getCellEditorValue() { // this is value returned by default editor String newName = super.getCellEditorValue().toString(); if (name == null) { // construct new CN with defaults if (newName.trim().length() > 0) name = concept.createConceptName(newName, false); } else { // existing CN check name update if (!newName.equals(name.getName())) { // delete old one ConceptName old = concept.getConceptName(name.getName()); concept.deleteConceptName(name.getName()); // keep preferred setting and create non empty name if (newName.trim().length() > 0) name = concept.createConceptName(newName, old.isPreferred()); else // clear existing concept name from table name = null; } } // return concept name instead of string return name; }
ConceptName cn = (ConceptName) value; value = cn.getName(); if (cn.isPreferred()) {
/** * Writes concept_name tag in a xml stream writer. * * @param xmlw * xml stream to write in * @param cn * a ConceptName object * @throws XMLStreamException * if xml writing fails if writing the xml failed */ protected void buildConceptName(XMLStreamWriter2 xmlw, ConceptName cn) throws XMLStreamException { xmlw.writeStartElement(XMLTagNames.CONCEPTNAME); xmlw.writeStartElement(XMLTagNames.NAME); xmlw.writeCharacters(stripInvalidXMLCharacters(cn.getName())); xmlw.writeEndElement(); boolean isPreferred = cn.isPreferred(); xmlw.writeStartElement(XMLTagNames.ISPREFERRED); xmlw.writeCharacters(String.valueOf(isPreferred)); xmlw.writeEndElement(); xmlw.writeEndElement(); // end tag CONCEPTNAME }