2ronwalf/*
2ronwalf * Created on Dec 10, 2004
2ronwalf */
2ronwalfpackage impl.jena;
2ronwalf
2ronwalfimport java.io.Reader;
2ronwalfimport java.io.StringReader;
2ronwalfimport java.net.URI;
2ronwalfimport java.util.ArrayList;
2ronwalfimport java.util.HashMap;
2ronwalfimport java.util.HashSet;
2ronwalfimport java.util.Iterator;
2ronwalfimport java.util.LinkedHashSet;
2ronwalfimport java.util.List;
2ronwalfimport java.util.Map;
2ronwalfimport java.util.Set;
22daenzeroramaimport java.util.Vector;
2ronwalf
2ronwalfimport org.mindswap.owl.OWLClass;
2ronwalfimport org.mindswap.owl.OWLDataProperty;
2ronwalfimport org.mindswap.owl.OWLDataValue;
2ronwalfimport org.mindswap.owl.OWLEntity;
2ronwalfimport org.mindswap.owl.OWLFactory;
2ronwalfimport org.mindswap.owl.OWLIndividual;
2ronwalfimport org.mindswap.owl.OWLIndividualList;
2ronwalfimport org.mindswap.owl.OWLKnowledgeBase;
2ronwalfimport org.mindswap.owl.OWLObjectProperty;
2ronwalfimport org.mindswap.owl.OWLOntology;
2ronwalfimport org.mindswap.owl.OWLProperty;
2ronwalfimport org.mindswap.owl.OWLValue;
39daenzeroramaimport org.mindswap.owls.OWLSFactory;
39daenzeroramaimport org.mindswap.owls.process.Binding;
39daenzeroramaimport org.mindswap.owls.process.BindingList;
39daenzeroramaimport org.mindswap.owls.process.Parameter;
2ronwalfimport org.mindswap.owls.service.Service;
22daenzeroramaimport org.mindswap.owls.vocabulary.MoreGroundings;
22daenzeroramaimport org.mindswap.owls.vocabulary.OWLS;
22daenzeroramaimport org.mindswap.owls.vocabulary.OWLS_Extensions;
2ronwalf
2ronwalfimport com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
2ronwalfimport com.hp.hpl.jena.ontology.OntModel;
2ronwalfimport com.hp.hpl.jena.rdf.model.Literal;
2ronwalfimport com.hp.hpl.jena.rdf.model.Model;
2ronwalfimport com.hp.hpl.jena.rdf.model.Property;
2ronwalfimport com.hp.hpl.jena.rdf.model.RDFNode;
39daenzeroramaimport com.hp.hpl.jena.rdf.model.ResIterator;
2ronwalfimport com.hp.hpl.jena.rdf.model.Resource;
2ronwalfimport com.hp.hpl.jena.rdf.model.Statement;
13daenzeroramaimport com.hp.hpl.jena.rdf.model.StmtIterator;
22daenzeroramaimport com.hp.hpl.jena.util.iterator.ExtendedIterator;
2ronwalfimport com.hp.hpl.jena.vocabulary.OWL;
2ronwalfimport com.hp.hpl.jena.vocabulary.RDF;
2ronwalf
2ronwalf/**
2ronwalf * @author Evren Sirin
2ronwalf */
2ronwalfpublic class OWLOntologyImpl extends OWLModelImpl implements OWLOntology, org.mindswap.owls.OWLSOntology {
2ronwalf private OWLKnowledgeBase kb;
2ronwalf
2ronwalf private OWLIndividual ontResource;
2ronwalf
2ronwalf private URI uri;
2ronwalf private URI fileURI;
2ronwalf
2ronwalf private Map imports;
2ronwalf
2ronwalf private OWLOntology sourceOntology;
22daenzerorama
22daenzerorama private Vector owlsNamespaces;
2ronwalf
2ronwalf public OWLOntologyImpl(OWLKnowledgeBase kb, URI uri, URI fileURI, Model jenaModel) {
2ronwalf super(jenaModel);
2ronwalf super.setBaseOntology(this);
2ronwalf
2ronwalf this.uri = uri;
2ronwalf this.fileURI = fileURI;
2ronwalf this.kb = kb;
2ronwalf
2ronwalf imports = new HashMap();
2ronwalf
2ronwalf sourceOntology = this;
2ronwalf
2ronwalf
2ronwalf }
2ronwalf
2ronwalf public OWLKnowledgeBase getKB() {
2ronwalf return kb;
2ronwalf }
2ronwalf
2ronwalf public Set getImports() {
2ronwalf return new HashSet( imports.values() );
2ronwalf }
2ronwalf
2ronwalf public Set getImports(boolean direct) {
2ronwalf if(!direct) {
2ronwalf LinkedHashSet importsClosure = new LinkedHashSet();
2ronwalf List orderedList = new ArrayList();
2ronwalf orderedList.add( this );
2ronwalf for( int i = 0; i < orderedList.size(); i++ ) {
2ronwalf OWLOntology ont = (OWLOntology) orderedList.get( i );
2ronwalf if( importsClosure.contains( ont ) )
2ronwalf continue;
2ronwalf else
2ronwalf importsClosure.add( ont );
2ronwalf
2ronwalf for(Iterator it = ont.getImports().iterator(); it.hasNext();) {
2ronwalf OWLOntology imported = (OWLOntology) it.next();
2ronwalf if( importsClosure.contains( imported ) )
2ronwalf continue;
2ronwalf else
2ronwalf orderedList.add( imported );
2ronwalf }
2ronwalf }
2ronwalf return importsClosure;
2ronwalf }
2ronwalf
2ronwalf return getImports();
2ronwalf }
2ronwalf
2ronwalf public void addImport(OWLOntology ontology) {
2ronwalf URI fileURI = ontology.getFileURI();
2ronwalf if( fileURI != null && !imports.containsKey( fileURI )) {
2ronwalf imports.put( fileURI, ontology );
2ronwalf }
2ronwalf }
2ronwalf
2ronwalf
2ronwalf public void addImports(Set theImports) {
2ronwalf Iterator aIter = theImports.iterator();
2ronwalf while (aIter.hasNext()) {
2ronwalf try {
2ronwalf OWLOntology aOnt = (OWLOntology)aIter.next();
2ronwalf addImport(aOnt);
2ronwalf }
2ronwalf catch (Exception ex) {
2ronwalf // probably a cast exception, someone trying to add an ontology that
2ronwalf // isnt actually an ontology object. just ignore, try the next one
2ronwalf }
2ronwalf }
2ronwalf //this.imports.addAll(theImports);
2ronwalf }
2ronwalf
2ronwalf public OWLClass createClass(URI uri) {
2ronwalf OWLClass c = getClass(uri);
2ronwalf
2ronwalf if(c == null) {
2ronwalf Resource r = asResource(uri);
2ronwalf ontModel.add(r, RDF.type, OWL.Class);
2ronwalf kb.refresh();
2ronwalf
2ronwalf c = new OWLClassImpl(this, r);
2ronwalf }
2ronwalf
2ronwalf return c;
2ronwalf }
2ronwalf
2ronwalf public OWLObjectProperty createObjectProperty(URI uri) {
2ronwalf OWLObjectProperty c = getObjectProperty(uri);
2ronwalf
2ronwalf if(c == null) {
2ronwalf Property r = asProperty(uri);
2ronwalf ontModel.add(r, RDF.type, OWL.ObjectProperty);
2ronwalf kb.refresh();
2ronwalf
2ronwalf c = new OWLObjectPropertyImpl(this, r);
2ronwalf }
2ronwalf
2ronwalf return c;
2ronwalf }
2ronwalf
2ronwalf public OWLDataProperty createDataProperty(URI uri) {
2ronwalf OWLDataProperty c = getDataProperty(uri);
2ronwalf
2ronwalf if(c == null) {
2ronwalf Property r = asProperty(uri);
2ronwalf ontModel.add(r, RDF.type, OWL.DatatypeProperty);
2ronwalf kb.refresh();
2ronwalf
2ronwalf c = new OWLDataPropertyImpl(this, r);
2ronwalf }
2ronwalf
2ronwalf return c;
2ronwalf }
2ronwalf
2ronwalf public OWLIndividual createIndividual(URI uri) {
2ronwalf OWLIndividual ind = getIndividual(uri);
2ronwalf
2ronwalf if(ind == null) {
2ronwalf Resource r = asResource(uri);
2ronwalf ind = new OWLIndividualImpl(this, r);
2ronwalf
2ronwalf kb.refresh();
2ronwalf }
2ronwalf
2ronwalf return ind;
2ronwalf }
2ronwalf
2ronwalf public OWLIndividual createInstance(OWLClass c) {
2ronwalf Resource r = ontModel.createResource();
2ronwalf ontModel.add(r, RDF.type, (Resource) c.getImplementation());
2ronwalf OWLIndividual ind = new OWLIndividualImpl(this, r);
2ronwalf kb.refresh();
2ronwalf
2ronwalf return ind;
2ronwalf }
2ronwalf
2ronwalf public OWLIndividual createInstance(OWLClass c, URI uri) {
2ronwalf Resource r = asResource(uri);
2ronwalf ontModel.add(r, RDF.type, (Resource) c.getImplementation());
2ronwalf OWLIndividual ind = new OWLIndividualImpl(this, r);
2ronwalf kb.refresh();
2ronwalf
2ronwalf return ind;
2ronwalf }
2ronwalf
2ronwalf public OWLDataValue createDataValue(String value) {
2ronwalf return new OWLDataValueImpl(ontModel.createLiteral(value));
2ronwalf }
2ronwalf
2ronwalf public OWLDataValue createDataValue(String value, String language) {
2ronwalf return new OWLDataValueImpl(ontModel.createLiteral(value, language));
2ronwalf }
2ronwalf
2ronwalf public OWLDataValue createDataValue(Object value, URI datatypeURI) {
2ronwalf if(datatypeURI.equals(org.mindswap.owl.vocabulary.RDF.XMLLiteral))
2ronwalf return new OWLDataValueImpl(ontModel.createLiteral(value.toString(), true));
2ronwalf else
2ronwalf return new OWLDataValueImpl(ontModel.createTypedLiteral(value, datatypeURI.toString()));
2ronwalf }
2ronwalf
2ronwalf public OWLDataValue createDataValue(Object value) {
2ronwalf if(value instanceof OWLDataValue )
2ronwalf return (OWLDataValue) value;
2ronwalf else if(value instanceof URI)
2ronwalf return new OWLDataValueImpl(ontModel.createTypedLiteral(value, XSDDatatype.XSDanyURI));
2ronwalf else
2ronwalf return new OWLDataValueImpl(ontModel.createTypedLiteral(value));
2ronwalf }
2ronwalf
2ronwalf public URI getURI() {
2ronwalf return uri;
2ronwalf }
2ronwalf
2ronwalf public URI getFileURI() {
2ronwalf return fileURI;
2ronwalf }
2ronwalf
2ronwalf /* (non-Javadoc)
2ronwalf * @see org.mindswap.owl.OWLObject#debugString()
2ronwalf */
2ronwalf public String debugString() {
2ronwalf return "Ontology (" + uri + ")";
2ronwalf }
2ronwalf
2ronwalf /* (non-Javadoc)
2ronwalf * @see org.mindswap.owl.OWLOntology#getOntologyObject()
2ronwalf */
2ronwalf public OWLEntity getOntologyObject() {
2ronwalf return ontResource;
2ronwalf }
2ronwalf
2ronwalf /* (non-Javadoc)
2ronwalf * @see org.mindswap.owl.OWLOntology#asSingletonKB()
2ronwalf */
2ronwalf public OWLKnowledgeBase asKB() {
2ronwalf return asKB(true);
2ronwalf }
2ronwalf
2ronwalf /* (non-Javadoc)
2ronwalf * @see org.mindswap.owl.OWLOntology#asSingletonKB(boolean)
2ronwalf */
2ronwalf public OWLKnowledgeBase asKB(boolean withImports) {
2ronwalf OWLKnowledgeBase kb = OWLFactory.createKB();
2ronwalf kb.load(this, withImports);
2ronwalf
2ronwalf return kb;
2ronwalf
2ronwalf }
2ronwalf
2ronwalf protected OWLDataValue wrapDataValue(Literal l, OWLOntology ont) {
2ronwalf return new OWLDataValueImpl(l);
2ronwalf }
2ronwalf
2ronwalf protected OWLIndividual wrapIndividual(Resource r, OWLOntology ont) {
2ronwalf return new OWLIndividualImpl(this, r);
2ronwalf }
2ronwalf
2ronwalf protected OWLClass wrapClass(Resource r, OWLOntology ont) {
2ronwalf return new OWLClassImpl(this, r);
2ronwalf }
2ronwalf
2ronwalf protected OWLObjectProperty wrapObjectProperty(Property p, OWLOntology ont) {
2ronwalf return new OWLObjectPropertyImpl(this, p);
2ronwalf }
2ronwalf
2ronwalf protected OWLDataProperty wrapDataProperty(Property p, OWLOntology ont) {
2ronwalf return new OWLDataPropertyImpl(this, p);
2ronwalf }
2ronwalf
2ronwalf public String toString() {
2ronwalf if(uri == null)
2ronwalf return "Ontology()";
2ronwalf
2ronwalf return "Ontology(" + uri + ")";
2ronwalf }
2ronwalf
2ronwalf public void setURI(URI uri) {
2ronwalf this.uri = uri;
2ronwalf
2ronwalf if(uri != null)
2ronwalf ontResource = new OWLIndividualImpl(this, ontModel.getResource(uri.toString()));
2ronwalf }
2ronwalf
2ronwalf public void setFileURI(URI uri) {
2ronwalf this.fileURI = uri;
2ronwalf }
2ronwalf
2ronwalf// public void setKB(OWLKnowledgeBase kb) {
2ronwalf// this.kb = kb;
2ronwalf// }
2ronwalf
2ronwalf// public void setImports(Set imports) {
2ronwalf// this.imports = imports;
2ronwalf// }
2ronwalf
2ronwalf public void refresh() {
2ronwalf ontModel.rebind();
2ronwalf kb.refresh();
2ronwalf }
2ronwalf
2ronwalf public void setProperty(OWLIndividual ind, OWLDataProperty prop, String value) {
2ronwalf setProperty(ind, prop, createDataValue(value));
2ronwalf }
2ronwalf
2ronwalf public void setProperty(OWLIndividual ind, OWLDataProperty prop, Object value) {
2ronwalf setProperty(ind, prop, createDataValue(value));
2ronwalf }
2ronwalf
2ronwalf public void setProperty(OWLIndividual ind, OWLDataProperty prop, OWLDataValue value) {
2ronwalf Resource subject = (Resource) ind.getImplementation();
2ronwalf Property predicate = (Property) prop.getImplementation();
2ronwalf Literal object = (Literal) value.getImplementation();
2ronwalf
2ronwalf ontModel.remove(ontModel.listStatements(subject, predicate, (Literal) null));
2ronwalf ontModel.add(subject, predicate, object);
2ronwalf kb.refresh();
2ronwalf }
2ronwalf
2ronwalf public void addProperty(OWLIndividual ind, OWLProperty prop, OWLValue value) {
2ronwalf if( prop instanceof OWLObjectProperty && value instanceof OWLIndividual )
2ronwalf addProperty( ind, (OWLObjectProperty) prop, (OWLIndividual) value );
2ronwalf else if( prop instanceof OWLDataProperty && value instanceof OWLDataValue )
2ronwalf addProperty( ind, (OWLDataProperty) prop, (OWLDataValue) value );
2ronwalf else
2ronwalf throw new IllegalArgumentException();
2ronwalf }
2ronwalf
2ronwalf public void addProperty(OWLIndividual ind, OWLDataProperty prop, OWLDataValue value) {
2ronwalf ontModel.add(
2ronwalf (Resource) ind.getImplementation(),
2ronwalf (Property) prop.getImplementation(),
2ronwalf (Literal) value.getImplementation());
2ronwalf kb.refresh();
2ronwalf }
2ronwalf
2ronwalf
2ronwalf public void addProperty(OWLIndividual ind, OWLDataProperty prop, String value) {
2ronwalf addProperty(ind, prop, createDataValue(value));
2ronwalf }
2ronwalf
2ronwalf public void addProperty(OWLIndividual ind, OWLDataProperty prop, Object value) {
2ronwalf addProperty(ind, prop, createDataValue(value));
2ronwalf }
2ronwalf
2ronwalf public void removeProperties(OWLIndividual ind, OWLProperty prop) {
2ronwalf Resource subject = (Resource) ind.getImplementation();
2ronwalf Property predicate = (Property) prop.getImplementation();
2ronwalf
2ronwalf ontModel.remove(ontModel.listStatements(subject, predicate, (Resource) null));
2ronwalf kb.refresh();
2ronwalf }
2ronwalf
2ronwalf public void removeProperty(OWLIndividual ind, OWLProperty prop, OWLValue value)
2ronwalf {
2ronwalf Resource subject = (Resource)ind.getImplementation();
2ronwalf Property predicate = (Property)prop.getImplementation();
2ronwalf RDFNode object = (RDFNode)value.getImplementation();
2ronwalf
2ronwalf Statement stmt = ontModel.createStatement(subject,predicate,object);
2ronwalf
2ronwalf ontModel.remove(stmt);
2ronwalf
2ronwalf refresh();
2ronwalf }
2ronwalf
2ronwalf public void addProperty(OWLIndividual ind, OWLObjectProperty prop, OWLIndividual value) {
2ronwalf ontModel.add(
2ronwalf (Resource) ind.getImplementation(),
2ronwalf (Property) prop.getImplementation(),
2ronwalf (Resource) value.getImplementation());
2ronwalf kb.refresh();
2ronwalf }
2ronwalf
2ronwalf public void setProperty(OWLIndividual ind, OWLObjectProperty prop, OWLIndividual value) {
2ronwalf Resource subject = (Resource) ind.getImplementation();
2ronwalf Property predicate = (Property) prop.getImplementation();
2ronwalf Resource object = (Resource) value.getImplementation();
2ronwalf
2ronwalf ontModel.remove(ontModel.listStatements(subject, predicate, (Resource) null));
38daenzerorama ontModel.add(subject, predicate, object);
38daenzerorama kb.refresh();
2ronwalf }
2ronwalf
2ronwalf
2ronwalf public void addType(OWLIndividual ind, OWLClass c) {
2ronwalf ontModel.add(
2ronwalf (Resource) ind.getImplementation(),
2ronwalf RDF.type,
2ronwalf (Resource) c.getImplementation());
2ronwalf kb.refresh();
2ronwalf }
2ronwalf
2ronwalf public void removeTypes(OWLIndividual ind) {
2ronwalf Resource subject = (Resource) ind.getImplementation();
2ronwalf
2ronwalf ontModel.remove(ontModel.listStatements(subject, RDF.type, (Resource) null));
2ronwalf kb.refresh();
2ronwalf }
2ronwalf
2ronwalf public OWLOntology getTranslationSource() {
2ronwalf return sourceOntology;
2ronwalf }
2ronwalf
2ronwalf public void setTranslationSource(OWLOntology ontology) {
2ronwalf sourceOntology = ontology;
2ronwalf }
2ronwalf
2ronwalf public Service getService() {
2ronwalf List list = getServices();
2ronwalf
2ronwalf return list.isEmpty() ? null : (Service) list.get(0);
2ronwalf }
2ronwalf
2ronwalf public OWLIndividual parseLiteral(String literal) {
2ronwalf Reader in = new StringReader( literal );
2ronwalf OWLOntologyImpl ont = (OWLOntologyImpl) kb.read( in, uri );
2ronwalf OWLIndividual res = null;
2ronwalf int outCount = 0;
2ronwalf
2ronwalf OWLIndividualList instances = ont.getIndividuals();
2ronwalf for(int i = 0; i < instances.size(); i++) {
2ronwalf OWLIndividual ind = (OWLIndividual) instances.get( i );
2ronwalf if(ont.getIncomingProperties(ind).isEmpty())
2ronwalf return ind;
2ronwalf if (res == null)
2ronwalf {
2ronwalf res = ind;
2ronwalf outCount = ont.getProperties(ind).size();
2ronwalf }
2ronwalf else
2ronwalf {
2ronwalf int newCount = ont.getProperties(ind).size();
2ronwalf if (newCount > outCount)
2ronwalf {
2ronwalf res = ind;
2ronwalf outCount = newCount;
2ronwalf }
2ronwalf }
2ronwalf }
2ronwalf
2ronwalf return res;
2ronwalf }
2ronwalf
2ronwalf public OWLOntology union( OWLOntology ont ) {
2ronwalf // create empty ont
2ronwalf OWLOntology newOnt = OWLFactory.createOntology();
2ronwalf
2ronwalf // add the contents of both ontologies
2ronwalf newOnt.add( this );
2ronwalf newOnt.add( ont );
2ronwalf
2ronwalf return newOnt;
2ronwalf }
2ronwalf
2ronwalf public void add( OWLOntology ont ) {
2ronwalf Model m1 = ((OntModel) this.getImplementation()).getBaseModel();
2ronwalf Model m2 = ((OntModel) ont.getImplementation()).getBaseModel();
2ronwalf m1.add( m2 );
2ronwalf
2ronwalf kb.refresh();
2ronwalf }
2ronwalf
2ronwalf public List getServices() {
2ronwalf if (kb != null)
2ronwalf return kb.getServices();
2ronwalf
2ronwalf return super.getServices();
2ronwalf }
13daenzerorama
18daenzerorama private void removeResourcesForOneLevel(Resource resource, boolean recursive) {
14daenzerorama if (recursive) {
14daenzerorama StmtIterator propIter = resource.listProperties();
14daenzerorama System.out.println("Processing resource " + resource);
14daenzerorama
14daenzerorama while (propIter.hasNext()) {
14daenzerorama Statement stmt = propIter.nextStatement();
14daenzerorama System.out.println("Processing statement " + stmt);
14daenzerorama if (stmt.getObject().isResource())
14daenzerorama removeResourcesForOneLevel((Resource) stmt.getObject(), recursive);
14daenzerorama }
14daenzerorama }
14daenzerorama
13daenzerorama // removes all statements with the given individual in the subject
13daenzerorama StmtIterator stmtiter = ontModel.listStatements(resource, (Property) null, (RDFNode) null);
13daenzerorama ontModel.remove(stmtiter);
13daenzerorama
13daenzerorama // removes all statements with the given individual in the object
13daenzerorama stmtiter = ontModel.listStatements((Resource) null, (Property) null, (RDFNode) resource);
13daenzerorama ontModel.remove(stmtiter);
14daenzerorama if (recursive)
14daenzerorama resource.removeProperties();
13daenzerorama }
13daenzerorama
14daenzerorama public void removeIndividuals(OWLIndividual ind) {
18daenzerorama if (!ind.getIncomingProperties().isEmpty())
18daenzerorama return;
14daenzerorama Resource resource = (Resource) ind.getImplementation();
14daenzerorama removeResourcesForOneLevel(resource, false);
13daenzerorama }
14daenzerorama
14daenzerorama public void removeIndividuals(OWLIndividual ind, boolean recursive) {
18daenzerorama if (ind.getIncomingProperties().isEmpty())
18daenzerorama return;
14daenzerorama Resource resource = (Resource) ind.getImplementation();
14daenzerorama removeResourcesForOneLevel(resource, true);
14daenzerorama }
22daenzerorama
28daenzerorama public List getNonLanguageIndividuals() {
29daenzerorama List classes = getNonLanguageClasses();
29daenzerorama List inds = new ArrayList();
29daenzerorama for (int i = 0; i < classes.size(); i++)
29daenzerorama inds.addAll(getInstances((OWLClass) classes.get(i)));
29daenzerorama return inds;
28daenzerorama }
28daenzerorama
28daenzerorama public List getNonLanguageClasses() {
28daenzerorama return getNonLanguageItems(getOntModel().listClasses());
28daenzerorama }
22daenzerorama
28daenzerorama public List getNonLanguageDataProperties() {
28daenzerorama return getNonLanguageItems(getOntModel().listDatatypeProperties());
28daenzerorama }
22daenzerorama
28daenzerorama public List getNonLanguageObjectProperties() {
28daenzerorama return getNonLanguageItems(getOntModel().listObjectProperties());
28daenzerorama }
28daenzerorama
28daenzerorama private List getNonLanguageItems(ExtendedIterator iter) {
28daenzerorama List list = new ArrayList();
28daenzerorama while (iter.hasNext()) {
28daenzerorama Resource resource = (Resource) iter.next();
28daenzerorama if (!isInLanguageNamespace(resource))
28daenzerorama list.add(wrapClass(resource, getBaseOntology()));
22daenzerorama }
22daenzerorama
28daenzerorama return list;
28daenzerorama }
28daenzerorama
28daenzerorama private boolean isInLanguageNamespace(Resource resource) {
28daenzerorama String namespace = resource.getNameSpace();
28daenzerorama
28daenzerorama if ((owlsNamespaces == null) || (owlsNamespaces.isEmpty())) {
28daenzerorama owlsNamespaces = new Vector();
28daenzerorama // OWL-S namespaces
28daenzerorama owlsNamespaces.add(OWLS.Service.Service.getNamespace());
28daenzerorama owlsNamespaces.add(OWLS.Process.Process.getNamespace());
28daenzerorama owlsNamespaces.add(OWLS.Profile.Profile.getNamespace());
28daenzerorama owlsNamespaces.add(OWLS.Grounding.WsdlGrounding.getNamespace());
28daenzerorama owlsNamespaces.add(OWLS.Expression.Expression.getNamespace());
28daenzerorama owlsNamespaces.add(OWLS.Actor.Actor.getNamespace());
28daenzerorama // expression language namespaces
28daenzerorama owlsNamespaces.add(org.mindswap.owl.vocabulary.KIF.ns);
28daenzerorama owlsNamespaces.add(org.mindswap.owl.vocabulary.SWRL.AtomList.getNamespace());
28daenzerorama owlsNamespaces.add(org.mindswap.owl.vocabulary.SWRLB.equal.getNamespace());
28daenzerorama owlsNamespaces.add(org.mindswap.owl.vocabulary.DRS.ns);
28daenzerorama // OWL+RDF namespaces
28daenzerorama owlsNamespaces.add(org.mindswap.owl.vocabulary.XSD.ns);
28daenzerorama owlsNamespaces.add(org.mindswap.owl.vocabulary.RDF.ns);
28daenzerorama owlsNamespaces.add(org.mindswap.owl.vocabulary.RDFS.ns);
28daenzerorama owlsNamespaces.add(org.mindswap.owl.vocabulary.OWL.ns);
28daenzerorama // Extensions
28daenzerorama owlsNamespaces.add(MoreGroundings.JavaGrounding.getNamespace());
28daenzerorama owlsNamespaces.add(OWLS_Extensions.Process.hasPerform.getNamespace());
28daenzerorama // helpers
28daenzerorama owlsNamespaces.add(org.mindswap.owl.vocabulary.DC.ns);
28daenzerorama owlsNamespaces.add("http://www.isi.edu/~pan/damltime/time-entry.owl#");
28daenzerorama owlsNamespaces.add("http://www.daml.org/services/owl-s/1.1/generic/swrlx.owl#");
28daenzerorama owlsNamespaces.add("http://www.daml.org/services/owl-s/1.1/generic/ObjectList.owl#");
28daenzerorama }
22daenzerorama
28daenzerorama for (int i = 0; i < owlsNamespaces.size(); i++) {
28daenzerorama if (owlsNamespaces.get(i).equals(namespace))
28daenzerorama return true;
22daenzerorama }
22daenzerorama
28daenzerorama return false;
28daenzerorama }
28daenzerorama
28daenzerorama public Set getClasses() {
28daenzerorama return getAllClasses(ontModel.listClasses(), this);
28daenzerorama }
39daenzerorama
39daenzerorama public BindingList getBindingsFor(Parameter parameter) {
39daenzerorama Property prop = (Property) OWLS.Process.toParam.getImplementation();
39daenzerorama ResIterator iter = getOntModel().listSubjectsWithProperty(prop, parameter.getImplementation());
39daenzerorama BindingList bindings = OWLSFactory.createBindingList();
39daenzerorama while (iter.hasNext()) {
39daenzerorama Resource resource = (Resource) iter.next();
39daenzerorama OWLIndividual ind = new OWLIndividualImpl(this, resource);
39daenzerorama if (ind.isType(OWLS.Process.Binding))
39daenzerorama bindings.add((Binding) ind.castTo(Binding.class));
39daenzerorama }
39daenzerorama
39daenzerorama return bindings;
39daenzerorama }
2ronwalf}