/** * Generate metadata for Data Source. * @param ds * A Data Source (from the Ondex API). * @return JSONObject * JSONObject containing information about the Data Source. */ private JSONObject buildDataSource(DataSource ds) { JSONObject dsJson= new JSONObject(); dsJson.put(JSONAttributeNames.ID, ds.getId()); dsJson.put(JSONAttributeNames.FULLNAME, ds.getFullname()); dsJson.put(JSONAttributeNames.DESCRIPTION, ds.getDescription()); return dsJson; }
/** * Generate metadata for Data Source. * @param ds * A Data Source (from the Ondex API). * @return String * String containing full name or id. */ private String/*JSONObject*/ buildDataSource(DataSource ds) { String elementOf; /* JSONObject dsJson= new JSONObject(); dsJson.put(JSONAttributeNames.ID, ds.getId()); dsJson.put(JSONAttributeNames.FULLNAME, ds.getFullname()); dsJson.put(JSONAttributeNames.DESCRIPTION, ds.getDescription()); */ if(ds.getId().equals("")) { elementOf= ds.getFullname(); } else { elementOf= ds.getId(); } return elementOf/*dsJson*/; }
public void start() { ONDEXGraphMetaData metadata = graph.getMetaData(); for (ConceptClass cc : metadata.getConceptClasses()) { System.out.println("ConceptClass " + cc.getId() + " " + cc.getFullname()); System.out.println("\tConcepts = " + graph.getConceptsOfConceptClass(cc).size()); } for (DataSource dataSource : metadata.getDataSources()) { System.out.println("DataSource " + dataSource.getId() + " " + dataSource.getFullname()); System.out.println("\tConcepts = " + graph.getConceptsOfDataSource(dataSource).size()); } for (AttributeName att : metadata.getAttributeNames()) { System.out.println("AttributeName " + att.getId() + " " + att.getFullname()); System.out.println("\tConcepts = " + graph.getConceptsOfAttributeName(att).size()); System.out.println("\tRelations = " + graph.getRelationsOfAttributeName(att).size()); } for (RelationType rt : metadata.getRelationTypes()) { System.out.println("RelationType " + rt.getId() + " " + rt.getFullname()); System.out.println("\tRelations = " + graph.getRelationsOfRelationType(rt).size()); } }
/** * Add DataSource restriction valid at any depth for the to Concept If no DataSource * restriction are set then any DataSource is valid * * @param fromDataSource * the fromDataSource that will be valid * @param toDataSource * the toDataSource that will be valid */ public void addDataSourcePair(DataSource fromDataSource, DataSource toDataSource) { if (validDataSourcePair == null) { validDataSourcePair = new HashMap<String, Set<String>>(1); } Set<String> validToDataSources = validDataSourcePair.get(fromDataSource.getId()); if (validToDataSources == null) { validToDataSources = new HashSet<String>(1); validDataSourcePair.put(fromDataSource.getId(), validToDataSources); } validToDataSources.add(toDataSource.getId()); }
/** * Returns a JLabel for the data source */ @Override public Object getElementAt(int index) { JLabel label = null; if (index > -1) { DataSource dataSource = dataSources.get(index); String name = dataSource.getFullname(); if (name.trim().length() == 0) name = dataSource.getId(); label = new JLabel(name); label.setName(dataSource.getId()); label.setToolTipText("(" + dataSource.getId() + ") " + dataSource.getDescription()); } return label; }
etName = et.getId(); String dsName = ds.getFullname(); if (dsName == null || dsName.length() == 0) dsName = ds.getId(); if (dataSource != null) dsName = dataSource;
/** * Returns node color for a given DataSource. * * @param ds * DataSource * @return Color */ public static Color getColorForDataSource(DataSource ds) { String key = "DataSource.Color." + ds.getId(); if (visual.getProperty(key) != null) { return convertToColor(visual.getProperty(key)); } return defaultColor; }
/** * Constructs user input to add a DataSource. * * @param aog * AbstractONDEXGraph to add to * @param dataSource * DataSource to use */ public DialogDataSource(ONDEXGraph aog, DataSource dataSource) { super("Dialog.DataSource.Title", "Properties16.gif"); this.aog = aog; // set existing information id.setText(dataSource.getId()); fullname.setText(dataSource.getFullname()); description.setText(dataSource.getDescription()); // set everything to disabled id.setEditable(false); fullname.setEditable(false); description.setEnabled(false); this.getContentPane().setLayout(new BorderLayout()); this.getContentPane().add(makeProperties(), BorderLayout.CENTER); this.getContentPane().add(makeButtonsPanel(null, "Dialog.DataSource.Cancel"), BorderLayout.SOUTH); this.pack(); }
public static String dataSourceToUri(String graphUri, DataSource dataSource) { return toUri(graphUri, "cv", dataSource.getId()); } public static String ccToUri(String graphUri, ConceptClass cc) {
/** * Writes DataSource content in a xml stream writer. * * @param xmlw * xml stream to write in * @param dataSource * DataSource object * @throws XMLStreamException * if xml writing fails */ private void buildDataSourceContent(XMLStreamWriter2 xmlw, DataSource dataSource, RefOrVal rov) throws XMLStreamException { switch (rov) { case REF: buildIdRef(xmlw, dataSource); break; case VAL: xmlw.writeStartElement(XMLTagNames.ID); xmlw.writeCharacters(dataSource.getId()); xmlw.writeEndElement(); xmlw.writeStartElement(XMLTagNames.FULLNAME); xmlw.writeCharacters(dataSource.getFullname()); xmlw.writeEndElement(); xmlw.writeStartElement(XMLTagNames.DESCRIPTION); xmlw.writeCharacters(dataSource.getDescription()); xmlw.writeEndElement(); } }
public String getValue(ONDEXEntity cOrr) throws InvalidOndexEntityException { if(AbstractConcept.class.isAssignableFrom(cOrr.getClass())){ return ((ONDEXConcept)cOrr).getElementOf().getId(); } throw new InvalidOndexEntityException(cOrr.getClass()+": is not an Ondex class for which cv is known"); }
if (!nomd.checkDataSource(dataSource.getId())) nomd .createDataSource(dataSource.getId(), dataSource.getFullname(), dataSource .getDescription());
@Override public Set<ONDEXConcept> getConceptsOfDataSource(DataSource dataSource) { Set<Integer> is = new HashSet<Integer>(); try { PreparedStatement getCofDataSource = conn .prepareStatement("select id from concept where sid = ? and DataSource = ?"); getCofDataSource.setLong(1, sid); getCofDataSource.setString(2, dataSource.getId()); ResultSet rs = getCofDataSource.executeQuery(); while (rs.next()) { is.add(rs.getInt(1)); } rs.close(); getCofDataSource.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return BitSetFunctions.create(this, ONDEXConcept.class, is); }
private void step() { boolean match = false; next = null; List<String> ofInterest = new ArrayList<String>(); while (!match && view.hasNext()) { ONDEXConcept c = view.next(); String[] cCvs = c.getElementOf().getId().split(":"); for (String cCv : cCvs) { // System.err.println(cCv+" :: "+validArgs+" :: "+validArgs.contains(cCv.trim())); if (validArgs.contains(cCv)) { match = true; ofInterest.add(cCv); } } } if (ofInterest.size() == 0) { next = null; } else { next = ofInterest.toArray(new String[ofInterest.size()]); } } }
@Override public void start() { for (DataSource dataSource : graph.getMetaData().getDataSources()) { Set<ONDEXConcept> concepts = graph.getConceptsOfDataSource(dataSource); System.out.println("Data source C.V. id\tNumber of instances"); if (concepts.size() > 0) { System.out.println(dataSource.getId() + "\t" + concepts.size()); } } }
@Override public boolean deleteConceptAccession(String accession, DataSource elementOf) { try { PreparedStatement deleteCA = sg.getConnection().prepareStatement("delete from conceptaccession where (sid,id) = (?,?) and accession = ? and DataSource = ?"); deleteCA.setLong(1, getSID()); deleteCA.setInt(2, id); deleteCA.setString(3, accession); deleteCA.setString(4, elementOf.getId()); deleteCA.execute(); deleteCA.close(); return true; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return false; }
private void step() { boolean match = false; next = null; List<String> ofInterest = new ArrayList<String>(); while (!match && view.hasNext()) { ONDEXRelation r = view.next(); String[] cCvs = arrAnd(r.getFromConcept().getElementOf().getId().split(":"), r.getToConcept().getElementOf().getId().split(":"), validArgs); if (cCvs.length > 0) { match = true; next = cCvs; } } } }
/** * * @param conceptAccessions * @return */ private static final String getAccessionOfCV(Set<ConceptAccession> conceptAccessions, String cv) { for (ConceptAccession acc : conceptAccessions) { if (acc.getElementOf().getId().equals(cv)) { return acc.getAccession(); } } return null; }
/** * Returns a byte array serialisation of this class. * * @return byte[] */ @Override public byte[] serialise(long sid) { try { // create a byte output stream ByteArrayOutputStream baos = new ByteArrayOutputStream(100); // object output stream for serialisation DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(baos)); dos.writeLong(sid); dos.writeInt(conceptId); dos.writeUTF(accession); dos.writeUTF(elementOf.getId()); dos.writeBoolean(ambiguous); dos.flush(); byte[] retVal = baos.toByteArray(); // make sure streams are closed dos.close(); baos.close(); return retVal; } catch (IOException ioe) { throw new StorageException(ioe.getMessage()); } }