コード例 #1
0
 /**
  * Creates a test class.
  *
  * @param ontology
  * @param parent
  * @param id
  * @param label
  * @param comment
  */
 private SrampOntology.Class createClass(
     SrampOntology ontology, SrampOntology.Class parent, String id, String label, String comment) {
   SrampOntology.Class rval = ontology.createClass(id);
   rval.setParent(parent);
   rval.setComment(comment);
   rval.setLabel(label);
   return rval;
 }
コード例 #2
0
  /** @throws SrampException */
  private SrampOntology createOntology() throws SrampException {
    SrampOntology ontology = new SrampOntology();
    ontology.setBase("urn:example.org/test2"); // $NON-NLS-1$
    ontology.setLabel("Test Ontology #2"); // $NON-NLS-1$
    ontology.setComment("This is my second test ontology."); // $NON-NLS-1$

    SrampOntology.Class world =
        createClass(
            ontology,
            null,
            "World",
            "World",
            "The entire world"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    SrampOntology.Class asia =
        createClass(ontology, world, "Asia", "Asia", null); // $NON-NLS-1$ //$NON-NLS-2$
    SrampOntology.Class europe =
        createClass(
            ontology,
            world,
            "Europe",
            "Europe",
            "Two world wars"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    SrampOntology.Class japan =
        createClass(
            ontology,
            asia,
            "Japan",
            "Japan",
            "Samurai *and* ninja?  Not fair."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    SrampOntology.Class china =
        createClass(
            ontology,
            asia,
            "China",
            "China",
            "Gunpowder!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    SrampOntology.Class uk =
        createClass(
            ontology,
            europe,
            "UnitedKingdom",
            "United Kingdom",
            "The food could be better"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    SrampOntology.Class germany =
        createClass(
            ontology,
            europe,
            "Germany",
            "Germany",
            "The fatherland"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    ontology.getRootClasses().add(world);

    world.getChildren().add(asia);
    world.getChildren().add(europe);
    asia.getChildren().add(japan);
    asia.getChildren().add(china);
    europe.getChildren().add(uk);
    europe.getChildren().add(germany);

    return persistenceManager.persistOntology(ontology);
  }