JADE
package examples.content.musicShopOntology; import jade.content.onto.*; import jade.content.schema.*; import jade.content.schema.facets.*; import examples.content.ecommerceOntology.*; /** * Ontology containing music related concepts. * @author Giovanni Caire - TILAB */ public class MusicShopOntology extends Ontology implements MusicShopVocabulary { // NAME public static final String ONTOLOGY_NAME = "Music-shop-ontology"; // The singleton instance of this ontology // It "inherits" from the ecommerceontology private static Ontology theInstance = new MusicShopOntology(ECommerceOntology.getInstance()); public static Ontology getInstance() { return theInstance; } /** * Constructor */ private MusicShopOntology(Ontology base) { super(ONTOLOGY_NAME, base); try { //Thre are CDs, tracks, and singles (songs) add(new ConceptSchema(CD), CD.class); add(new ConceptSchema(TRACK), Track.class); add(new ConceptSchema(SINGLE), Single.class); //Our cs for a CD ConceptSchema cs = (ConceptSchema) getSchema(CD); //extends ecommerceontoloty cs.addSuperSchema((ConceptSchema) getSchema(ECommerceOntology.ITEM)); //A CD has a title cs.add(CD_TITLE, (PrimitiveSchema) getSchema(BasicOntology.STRING)); //and tracks cs.add(CD_TRACKS, (ConceptSchema) getSchema(TRACK), 1, ObjectSchema.UNLIMITED); //a track cs = (ConceptSchema) getSchema(TRACK); //has a name cs.add(TRACK_NAME, (TermSchema) getSchema(BasicOntology.STRING)); //and a duration cs.add(TRACK_DURATION, (TermSchema) getSchema(BasicOntology.INTEGER), ObjectSchema.OPTIONAL); //and pcm cs.add(TRACK_PCM, (TermSchema) getSchema(BasicOntology.BYTE_SEQUENCE), ObjectSchema.OPTIONAL); cs = (ConceptSchema) getSchema(SINGLE); cs.addSuperSchema((ConceptSchema) getSchema(CD)); // A SINGLE only includes two tracks cs.addFacet(CD_TRACKS, new CardinalityFacet(2, 2)); } catch (OntologyException oe) { oe.printStackTrace(); } } }
19 of 21