net.sourceforge.ondex.core.DataSource类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中net.sourceforge.ondex.core.DataSource类的一些代码示例,展示了DataSource类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataSource类的具体详情如下:
包路径:net.sourceforge.ondex.core.DataSource
类名称:DataSource

DataSource介绍

[英]This class represents the data source for the created Concepts and Relations. It has a mandatory name and an optional description field for additional information.
[中]此类表示所创建概念和关系的数据源。它有一个必需的名称和一个可选的描述字段以获取附加信息。

代码示例

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

  1. @Override
  2. public int compare(DataSource o1, DataSource o2) {
  3. return o1.getId().compareToIgnoreCase(o2.getId());
  4. }
  5. });

代码示例来源:origin: net.sourceforge.ondex.modules/json

  1. /**
  2. * Generate metadata for Data Source.
  3. * @param ds
  4. * A Data Source (from the Ondex API).
  5. * @return JSONObject
  6. * JSONObject containing information about the Data Source.
  7. */
  8. private JSONObject buildDataSource(DataSource ds) {
  9. JSONObject dsJson= new JSONObject();
  10. dsJson.put(JSONAttributeNames.ID, ds.getId());
  11. dsJson.put(JSONAttributeNames.FULLNAME, ds.getFullname());
  12. dsJson.put(JSONAttributeNames.DESCRIPTION, ds.getDescription());
  13. return dsJson;
  14. }

代码示例来源:origin: net.sourceforge.ondex.modules/cyjs_json

  1. /**
  2. * Generate metadata for Data Source.
  3. * @param ds
  4. * A Data Source (from the Ondex API).
  5. * @return String
  6. * String containing full name or id.
  7. */
  8. private String/*JSONObject*/ buildDataSource(DataSource ds) {
  9. String elementOf;
  10. /* JSONObject dsJson= new JSONObject();
  11. dsJson.put(JSONAttributeNames.ID, ds.getId());
  12. dsJson.put(JSONAttributeNames.FULLNAME, ds.getFullname());
  13. dsJson.put(JSONAttributeNames.DESCRIPTION, ds.getDescription());
  14. */
  15. if(ds.getId().equals("")) {
  16. elementOf= ds.getFullname();
  17. }
  18. else {
  19. elementOf= ds.getId();
  20. }
  21. return elementOf/*dsJson*/;
  22. }

代码示例来源:origin: net.sourceforge.ondex.modules/generic

  1. public void start() {
  2. ONDEXGraphMetaData metadata = graph.getMetaData();
  3. for (ConceptClass cc : metadata.getConceptClasses()) {
  4. System.out.println("ConceptClass " + cc.getId() + " " + cc.getFullname());
  5. System.out.println("\tConcepts = " + graph.getConceptsOfConceptClass(cc).size());
  6. }
  7. for (DataSource dataSource : metadata.getDataSources()) {
  8. System.out.println("DataSource " + dataSource.getId() + " " + dataSource.getFullname());
  9. System.out.println("\tConcepts = " + graph.getConceptsOfDataSource(dataSource).size());
  10. }
  11. for (AttributeName att : metadata.getAttributeNames()) {
  12. System.out.println("AttributeName " + att.getId() + " " + att.getFullname());
  13. System.out.println("\tConcepts = " + graph.getConceptsOfAttributeName(att).size());
  14. System.out.println("\tRelations = " + graph.getRelationsOfAttributeName(att).size());
  15. }
  16. for (RelationType rt : metadata.getRelationTypes()) {
  17. System.out.println("RelationType " + rt.getId() + " " + rt.getFullname());
  18. System.out.println("\tRelations = " + graph.getRelationsOfRelationType(rt).size());
  19. }
  20. }

代码示例来源:origin: net.sourceforge.ondex.core/algorithms

  1. /**
  2. * Add DataSource restriction valid at any depth for the to Concept If no DataSource
  3. * restriction are set then any DataSource is valid
  4. *
  5. * @param fromDataSource
  6. * the fromDataSource that will be valid
  7. * @param toDataSource
  8. * the toDataSource that will be valid
  9. */
  10. public void addDataSourcePair(DataSource fromDataSource, DataSource toDataSource) {
  11. if (validDataSourcePair == null) {
  12. validDataSourcePair = new HashMap<String, Set<String>>(1);
  13. }
  14. Set<String> validToDataSources = validDataSourcePair.get(fromDataSource.getId());
  15. if (validToDataSources == null) {
  16. validToDataSources = new HashSet<String>(1);
  17. validDataSourcePair.put(fromDataSource.getId(), validToDataSources);
  18. }
  19. validToDataSources.add(toDataSource.getId());
  20. }

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

  1. /**
  2. * Returns a JLabel for the data source
  3. */
  4. @Override
  5. public Object getElementAt(int index) {
  6. JLabel label = null;
  7. if (index > -1) {
  8. DataSource dataSource = dataSources.get(index);
  9. String name = dataSource.getFullname();
  10. if (name.trim().length() == 0)
  11. name = dataSource.getId();
  12. label = new JLabel(name);
  13. label.setName(dataSource.getId());
  14. label.setToolTipText("(" + dataSource.getId() + ") " + dataSource.getDescription());
  15. }
  16. return label;
  17. }

代码示例来源:origin: net.sourceforge.ondex.modules/interaction

  1. etName = et.getId();
  2. String dsName = ds.getFullname();
  3. if (dsName == null || dsName.length() == 0)
  4. dsName = ds.getId();
  5. if (dataSource != null)
  6. dsName = dataSource;

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

  1. /**
  2. * Returns node color for a given DataSource.
  3. *
  4. * @param ds
  5. * DataSource
  6. * @return Color
  7. */
  8. public static Color getColorForDataSource(DataSource ds) {
  9. String key = "DataSource.Color." + ds.getId();
  10. if (visual.getProperty(key) != null) {
  11. return convertToColor(visual.getProperty(key));
  12. }
  13. return defaultColor;
  14. }

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

  1. /**
  2. * Constructs user input to add a DataSource.
  3. *
  4. * @param aog
  5. * AbstractONDEXGraph to add to
  6. * @param dataSource
  7. * DataSource to use
  8. */
  9. public DialogDataSource(ONDEXGraph aog, DataSource dataSource) {
  10. super("Dialog.DataSource.Title", "Properties16.gif");
  11. this.aog = aog;
  12. // set existing information
  13. id.setText(dataSource.getId());
  14. fullname.setText(dataSource.getFullname());
  15. description.setText(dataSource.getDescription());
  16. // set everything to disabled
  17. id.setEditable(false);
  18. fullname.setEditable(false);
  19. description.setEnabled(false);
  20. this.getContentPane().setLayout(new BorderLayout());
  21. this.getContentPane().add(makeProperties(), BorderLayout.CENTER);
  22. this.getContentPane().add(makeButtonsPanel(null, "Dialog.DataSource.Cancel"), BorderLayout.SOUTH);
  23. this.pack();
  24. }

代码示例来源:origin: net.sourceforge.ondex.modules/rdf

  1. public static String dataSourceToUri(String graphUri, DataSource dataSource) {
  2. return toUri(graphUri, "cv", dataSource.getId());
  3. }
  4. public static String ccToUri(String graphUri, ConceptClass cc) {

代码示例来源:origin: net.sourceforge.ondex.modules/oxl

  1. /**
  2. * Writes DataSource content in a xml stream writer.
  3. *
  4. * @param xmlw
  5. * xml stream to write in
  6. * @param dataSource
  7. * DataSource object
  8. * @throws XMLStreamException
  9. * if xml writing fails
  10. */
  11. private void buildDataSourceContent(XMLStreamWriter2 xmlw,
  12. DataSource dataSource, RefOrVal rov) throws XMLStreamException {
  13. switch (rov) {
  14. case REF:
  15. buildIdRef(xmlw, dataSource);
  16. break;
  17. case VAL:
  18. xmlw.writeStartElement(XMLTagNames.ID);
  19. xmlw.writeCharacters(dataSource.getId());
  20. xmlw.writeEndElement();
  21. xmlw.writeStartElement(XMLTagNames.FULLNAME);
  22. xmlw.writeCharacters(dataSource.getFullname());
  23. xmlw.writeEndElement();
  24. xmlw.writeStartElement(XMLTagNames.DESCRIPTION);
  25. xmlw.writeCharacters(dataSource.getDescription());
  26. xmlw.writeEndElement();
  27. }
  28. }

代码示例来源:origin: net.sourceforge.ondex.modules/tab-tools

  1. public String getValue(ONDEXEntity cOrr) throws InvalidOndexEntityException {
  2. if(AbstractConcept.class.isAssignableFrom(cOrr.getClass())){
  3. return ((ONDEXConcept)cOrr).getElementOf().getId();
  4. }
  5. throw new InvalidOndexEntityException(cOrr.getClass()+": is not an Ondex class for which cv is known");
  6. }

代码示例来源:origin: net.sourceforge.ondex.core/tools

  1. if (!nomd.checkDataSource(dataSource.getId()))
  2. nomd
  3. .createDataSource(dataSource.getId(), dataSource.getFullname(), dataSource
  4. .getDescription());

代码示例来源:origin: net.sourceforge.ondex.core/sql

  1. @Override
  2. public Set<ONDEXConcept> getConceptsOfDataSource(DataSource dataSource) {
  3. Set<Integer> is = new HashSet<Integer>();
  4. try {
  5. PreparedStatement getCofDataSource = conn
  6. .prepareStatement("select id from concept where sid = ? and DataSource = ?");
  7. getCofDataSource.setLong(1, sid);
  8. getCofDataSource.setString(2, dataSource.getId());
  9. ResultSet rs = getCofDataSource.executeQuery();
  10. while (rs.next()) {
  11. is.add(rs.getInt(1));
  12. }
  13. rs.close();
  14. getCofDataSource.close();
  15. } catch (SQLException e) {
  16. // TODO Auto-generated catch block
  17. e.printStackTrace();
  18. }
  19. return BitSetFunctions.create(this, ONDEXConcept.class, is);
  20. }

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

  1. private void step() {
  2. boolean match = false;
  3. next = null;
  4. List<String> ofInterest = new ArrayList<String>();
  5. while (!match && view.hasNext()) {
  6. ONDEXConcept c = view.next();
  7. String[] cCvs = c.getElementOf().getId().split(":");
  8. for (String cCv : cCvs) {
  9. // System.err.println(cCv+" :: "+validArgs+" :: "+validArgs.contains(cCv.trim()));
  10. if (validArgs.contains(cCv)) {
  11. match = true;
  12. ofInterest.add(cCv);
  13. }
  14. }
  15. }
  16. if (ofInterest.size() == 0) {
  17. next = null;
  18. } else {
  19. next = ofInterest.toArray(new String[ofInterest.size()]);
  20. }
  21. }
  22. }

代码示例来源:origin: net.sourceforge.ondex.modules/generic

  1. @Override
  2. public void start() {
  3. for (DataSource dataSource : graph.getMetaData().getDataSources()) {
  4. Set<ONDEXConcept> concepts = graph.getConceptsOfDataSource(dataSource);
  5. System.out.println("Data source C.V. id\tNumber of instances");
  6. if (concepts.size() > 0) {
  7. System.out.println(dataSource.getId() + "\t" + concepts.size());
  8. }
  9. }
  10. }

代码示例来源:origin: net.sourceforge.ondex.core/sql

  1. @Override
  2. public boolean deleteConceptAccession(String accession,
  3. DataSource elementOf) {
  4. try {
  5. PreparedStatement deleteCA = sg.getConnection().prepareStatement("delete from conceptaccession where (sid,id) = (?,?) and accession = ? and DataSource = ?");
  6. deleteCA.setLong(1, getSID());
  7. deleteCA.setInt(2, id);
  8. deleteCA.setString(3, accession);
  9. deleteCA.setString(4, elementOf.getId());
  10. deleteCA.execute();
  11. deleteCA.close();
  12. return true;
  13. } catch (SQLException e) {
  14. // TODO Auto-generated catch block
  15. e.printStackTrace();
  16. }
  17. return false;
  18. }

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

  1. private void step() {
  2. boolean match = false;
  3. next = null;
  4. List<String> ofInterest = new ArrayList<String>();
  5. while (!match && view.hasNext()) {
  6. ONDEXRelation r = view.next();
  7. String[] cCvs = arrAnd(r.getFromConcept().getElementOf().getId().split(":"), r.getToConcept().getElementOf().getId().split(":"), validArgs);
  8. if (cCvs.length > 0) {
  9. match = true;
  10. next = cCvs;
  11. }
  12. }
  13. }
  14. }

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

  1. /**
  2. *
  3. * @param conceptAccessions
  4. * @return
  5. */
  6. private static final String getAccessionOfCV(Set<ConceptAccession> conceptAccessions, String cv) {
  7. for (ConceptAccession acc : conceptAccessions) {
  8. if (acc.getElementOf().getId().equals(cv)) {
  9. return acc.getAccession();
  10. }
  11. }
  12. return null;
  13. }

代码示例来源:origin: net.sourceforge.ondex.core/berkeley

  1. /**
  2. * Returns a byte array serialisation of this class.
  3. *
  4. * @return byte[]
  5. */
  6. @Override
  7. public byte[] serialise(long sid) {
  8. try {
  9. // create a byte output stream
  10. ByteArrayOutputStream baos = new ByteArrayOutputStream(100);
  11. // object output stream for serialisation
  12. DataOutputStream dos = new DataOutputStream(
  13. new BufferedOutputStream(baos));
  14. dos.writeLong(sid);
  15. dos.writeInt(conceptId);
  16. dos.writeUTF(accession);
  17. dos.writeUTF(elementOf.getId());
  18. dos.writeBoolean(ambiguous);
  19. dos.flush();
  20. byte[] retVal = baos.toByteArray();
  21. // make sure streams are closed
  22. dos.close();
  23. baos.close();
  24. return retVal;
  25. } catch (IOException ioe) {
  26. throw new StorageException(ioe.getMessage());
  27. }
  28. }

相关文章