You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by ci...@apache.org on 2011/04/08 09:14:27 UTC
svn commit: r1090147 - in /incubator/stanbol/trunk/ontologymanager/store:
api/src/main/java/org/apache/stanbol/ontologymanager/store/api/
api/src/main/java/org/apache/stanbol/ontologymanager/store/model/
api/src/main/resources/model/ jena/ jena/src/mai...
Author: cihan
Date: Fri Apr 8 07:14:27 2011
New Revision: 1090147
URL: http://svn.apache.org/viewvc?rev=1090147&view=rev
Log:
STANBOL-157: Added support for addition/removal of imported ontologies.
Added:
incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/ImportsForOntology.java
incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/OntologyImport.java
Modified:
incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/api/PersistenceStore.java
incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/ObjectFactory.java
incubator/stanbol/trunk/ontologymanager/store/api/src/main/resources/model/PersistenceStoreRESTfulInterface.xsd
incubator/stanbol/trunk/ontologymanager/store/jena/pom.xml
incubator/stanbol/trunk/ontologymanager/store/jena/src/main/java/org/apache/stanbol/ontologymanager/store/jena/JenaPersistenceStore.java
Modified: incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/api/PersistenceStore.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/api/PersistenceStore.java?rev=1090147&r1=1090146&r2=1090147&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/api/PersistenceStore.java (original)
+++ incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/api/PersistenceStore.java Fri Apr 8 07:14:27 2011
@@ -10,11 +10,13 @@ import org.apache.stanbol.ontologymanage
import org.apache.stanbol.ontologymanager.store.model.ClassesForOntology;
import org.apache.stanbol.ontologymanager.store.model.DatatypePropertiesForOntology;
import org.apache.stanbol.ontologymanager.store.model.DatatypePropertyContext;
+import org.apache.stanbol.ontologymanager.store.model.ImportsForOntology;
import org.apache.stanbol.ontologymanager.store.model.IndividualContext;
import org.apache.stanbol.ontologymanager.store.model.IndividualMetaInformation;
import org.apache.stanbol.ontologymanager.store.model.IndividualsForOntology;
import org.apache.stanbol.ontologymanager.store.model.ObjectPropertiesForOntology;
import org.apache.stanbol.ontologymanager.store.model.ObjectPropertyContext;
+import org.apache.stanbol.ontologymanager.store.model.OntologyImport;
import org.apache.stanbol.ontologymanager.store.model.OntologyMetaInformation;
import org.apache.stanbol.ontologymanager.store.model.PropertyMetaInformation;
import org.apache.stanbol.ontologymanager.store.model.ResourceMetaInformationType;
@@ -723,6 +725,37 @@ public interface PersistenceStore {
*/
boolean deleteResource(String resourceURI) throws Exception;
+ /**
+ * Interface method to *list* ontology imports of an ontology
+ * @param ontologyURI
+ * the URI of the ontology
+ * @return
+ * A {@link ImportsForOntology} objects.
+ * @throws Exception
+ */
+ ImportsForOntology retrieveOntologyImports(String ontologyURI) throws Exception;
+
+ /**
+ * Interface method to *add* an import to an existing ontology
+ * @param ontologyURI
+ * the URI of the ontology.
+ * @param importURI
+ * the URI of the ontology to be imported.
+ * @throws Exception
+ */
+ void addOntologyImport(String ontologyURI, String importURI) throws Exception;
+
+ /**
+ * Interface method to *delete* an import from an existing ontology.
+ * If the ontology does not import the specified one, then nothing happens.
+ * @param ontologyURI
+ * the URI of the ontology.
+ * @param importURI
+ * the URI of the imported ontology
+ * @throws Exception
+ */
+ void removeOntologyImport(String ontologyURI, String importURI) throws Exception;
+
/**
* Interface method to *delete* all registered ontologies together with
* their resources
Added: incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/ImportsForOntology.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/ImportsForOntology.java?rev=1090147&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/ImportsForOntology.java (added)
+++ incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/ImportsForOntology.java Fri Apr 8 07:14:27 2011
@@ -0,0 +1,108 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0-b52-fcs
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.04.08 at 07:09:04 AM EEST
+//
+
+
+package org.apache.stanbol.ontologymanager.store.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for ImportsForOntology element declaration.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <element name="ImportsForOntology">
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{model.rest.persistence.iks.srdc.com.tr}OntologyMetaInformation"/>
+ * <element ref="{model.rest.persistence.iks.srdc.com.tr}OntologyImport" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </element>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "ontologyMetaInformation",
+ "ontologyImport"
+})
+@XmlRootElement(name = "ImportsForOntology")
+public class ImportsForOntology {
+
+ @XmlElement(name = "OntologyMetaInformation", namespace = "model.rest.persistence.iks.srdc.com.tr", required = true)
+ protected OntologyMetaInformation ontologyMetaInformation;
+ @XmlElement(name = "OntologyImport", namespace = "model.rest.persistence.iks.srdc.com.tr", required = true)
+ protected List<OntologyImport> ontologyImport;
+
+ /**
+ * Gets the value of the ontologyMetaInformation property.
+ *
+ * @return
+ * possible object is
+ * {@link OntologyMetaInformation }
+ *
+ */
+ public OntologyMetaInformation getOntologyMetaInformation() {
+ return ontologyMetaInformation;
+ }
+
+ /**
+ * Sets the value of the ontologyMetaInformation property.
+ *
+ * @param value
+ * allowed object is
+ * {@link OntologyMetaInformation }
+ *
+ */
+ public void setOntologyMetaInformation(OntologyMetaInformation value) {
+ this.ontologyMetaInformation = value;
+ }
+
+ /**
+ * Gets the value of the ontologyImport property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the ontologyImport property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getOntologyImport().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link OntologyImport }
+ *
+ *
+ */
+ public List<OntologyImport> getOntologyImport() {
+ if (ontologyImport == null) {
+ ontologyImport = new ArrayList<OntologyImport>();
+ }
+ return this.ontologyImport;
+ }
+
+}
Modified: incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/ObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/ObjectFactory.java?rev=1090147&r1=1090146&r2=1090147&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/ObjectFactory.java (original)
+++ incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/ObjectFactory.java Fri Apr 8 07:14:27 2011
@@ -12,6 +12,7 @@ import javax.xml.bind.annotation.XmlElem
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
+
/**
* This object contains factory methods for each Java content interface and Java element interface generated
* in the eu.iksproject.fise.stores.persistencestore.rest.model package.
@@ -67,6 +68,13 @@ public class ObjectFactory {
public DatatypePropertyContext createDatatypePropertyContext() {
return new DatatypePropertyContext();
}
+
+ /**
+ * Create an instance of {@link ImportsForOntology}
+ */
+ public ImportsForOntology createImportsForOntology(){
+ return new ImportsForOntology();
+ }
/**
* Create an instance of {@link IndividualsForOntology }
@@ -123,6 +131,14 @@ public class ObjectFactory {
public ObjectPropertiesForOntology createObjectPropertiesForOntology() {
return new ObjectPropertiesForOntology();
}
+
+ /**
+ * Create an instance of {@link OntologyImport }
+ *
+ */
+ public OntologyImport createOntologyImport() {
+ return new OntologyImport();
+ }
/**
* Create an instance of {@link Range }
Added: incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/OntologyImport.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/OntologyImport.java?rev=1090147&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/OntologyImport.java (added)
+++ incubator/stanbol/trunk/ontologymanager/store/api/src/main/java/org/apache/stanbol/ontologymanager/store/model/OntologyImport.java Fri Apr 8 07:14:27 2011
@@ -0,0 +1,129 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.0-b52-fcs
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.04.07 at 03:38:43 PM EEST
+//
+
+
+package org.apache.stanbol.ontologymanager.store.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for OntologyImport element declaration.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <element name="OntologyImport">
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element ref="{model.rest.persistence.iks.srdc.com.tr}URI"/>
+ * <element ref="{model.rest.persistence.iks.srdc.com.tr}Description" minOccurs="0"/>
+ * </sequence>
+ * <attribute ref="{http://www.w3.org/1999/xlink}href use="required""/>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </element>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "uri",
+ "description"
+})
+@XmlRootElement(name = "OntologyImport")
+public class OntologyImport {
+
+ @XmlElement(name = "URI", namespace = "model.rest.persistence.iks.srdc.com.tr", required = true)
+ protected String uri;
+ @XmlElement(name = "Description", namespace = "model.rest.persistence.iks.srdc.com.tr")
+ protected String description;
+ @XmlAttribute(namespace = "http://www.w3.org/1999/xlink", required = true)
+ protected String href;
+
+ /**
+ * Gets the value of the uri property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * Sets the value of the uri property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setURI(String value) {
+ this.uri = value;
+ }
+
+ /**
+ * Gets the value of the description property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Sets the value of the description property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setDescription(String value) {
+ this.description = value;
+ }
+
+ /**
+ * Gets the value of the href property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getHref() {
+ return href;
+ }
+
+ /**
+ * Sets the value of the href property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setHref(String value) {
+ this.href = value;
+ }
+
+}
Modified: incubator/stanbol/trunk/ontologymanager/store/api/src/main/resources/model/PersistenceStoreRESTfulInterface.xsd
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/api/src/main/resources/model/PersistenceStoreRESTfulInterface.xsd?rev=1090147&r1=1090146&r2=1090147&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/api/src/main/resources/model/PersistenceStoreRESTfulInterface.xsd (original)
+++ incubator/stanbol/trunk/ontologymanager/store/api/src/main/resources/model/PersistenceStoreRESTfulInterface.xsd Fri Apr 8 07:14:27 2011
@@ -251,4 +251,23 @@
<xsd:enumeration value="has_value"/>
</xsd:restriction>
</xsd:simpleType>
+
+ <xsd:element name="OntologyImport">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="tns:URI"/>
+ <xsd:element ref="tns:Description" minOccurs="0"/>
+ </xsd:sequence>
+ <xsd:attribute ref="xlink:href" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="ImportsForOntology">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="tns:OntologyMetaInformation"/>
+ <xsd:element ref="tns:OntologyImport" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
</xsd:schema>
Modified: incubator/stanbol/trunk/ontologymanager/store/jena/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/jena/pom.xml?rev=1090147&r1=1090146&r2=1090147&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/jena/pom.xml (original)
+++ incubator/stanbol/trunk/ontologymanager/store/jena/pom.xml Fri Apr 8 07:14:27 2011
@@ -113,5 +113,23 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.installer.core</artifactId>
+ <version>3.1.2</version>
+ <type>bundle</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.stanboltools.datafileprovider</artifactId>
+ <version>0.9-SNAPSHOT</version>
+ <type>bundle</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
</dependencies>
</project>
Modified: incubator/stanbol/trunk/ontologymanager/store/jena/src/main/java/org/apache/stanbol/ontologymanager/store/jena/JenaPersistenceStore.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/jena/src/main/java/org/apache/stanbol/ontologymanager/store/jena/JenaPersistenceStore.java?rev=1090147&r1=1090146&r2=1090147&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/jena/src/main/java/org/apache/stanbol/ontologymanager/store/jena/JenaPersistenceStore.java (original)
+++ incubator/stanbol/trunk/ontologymanager/store/jena/src/main/java/org/apache/stanbol/ontologymanager/store/jena/JenaPersistenceStore.java Fri Apr 8 07:14:27 2011
@@ -9,7 +9,6 @@ import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.SQLException;
-import java.sql.Savepoint;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Dictionary;
@@ -46,20 +45,22 @@ import org.apache.stanbol.ontologymanage
import org.apache.stanbol.ontologymanager.store.model.Domain;
import org.apache.stanbol.ontologymanager.store.model.EquivalentClasses;
import org.apache.stanbol.ontologymanager.store.model.EquivalentProperties;
+import org.apache.stanbol.ontologymanager.store.model.ImportsForOntology;
import org.apache.stanbol.ontologymanager.store.model.IndividualContext;
import org.apache.stanbol.ontologymanager.store.model.IndividualMetaInformation;
import org.apache.stanbol.ontologymanager.store.model.IndividualsForOntology;
import org.apache.stanbol.ontologymanager.store.model.ObjectFactory;
import org.apache.stanbol.ontologymanager.store.model.ObjectPropertiesForOntology;
import org.apache.stanbol.ontologymanager.store.model.ObjectPropertyContext;
+import org.apache.stanbol.ontologymanager.store.model.OntologyImport;
import org.apache.stanbol.ontologymanager.store.model.OntologyMetaInformation;
import org.apache.stanbol.ontologymanager.store.model.PropertyAssertions;
+import org.apache.stanbol.ontologymanager.store.model.PropertyAssertions.PropertyAssertion;
import org.apache.stanbol.ontologymanager.store.model.PropertyMetaInformation;
import org.apache.stanbol.ontologymanager.store.model.Range;
import org.apache.stanbol.ontologymanager.store.model.ResourceMetaInformationType;
import org.apache.stanbol.ontologymanager.store.model.SuperProperties;
import org.apache.stanbol.ontologymanager.store.model.Superclasses;
-import org.apache.stanbol.ontologymanager.store.model.PropertyAssertions.PropertyAssertion;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.ComponentFactory;
import org.osgi.service.component.ComponentInstance;
@@ -104,7 +105,6 @@ import org.semanticweb.owlapi.util.Infer
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import com.hp.hpl.jena.ontology.AllValuesFromRestriction;
import com.hp.hpl.jena.ontology.ComplementClass;
import com.hp.hpl.jena.ontology.ConversionException;
@@ -139,6 +139,7 @@ import com.hp.hpl.jena.rdf.model.RDFList
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.RDFWriter;
import com.hp.hpl.jena.rdf.model.Resource;
+import com.hp.hpl.jena.rdf.model.ResourceFactory;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.shared.ReificationStyle;
@@ -233,8 +234,8 @@ public class JenaPersistenceStore implem
final Dictionary props = new Hashtable();
props.put(ResourceManager.class.getName(), resourceManager);
ComponentInstance componentInstance = this.componentFactory.newInstance(props);
- StoreSynchronizer storeSynchronizer = (StoreSynchronizer) componentInstance.getInstance();
-
+ StoreSynchronizer storeSynchronizer = (StoreSynchronizer) componentInstance.getInstance();
+
this.synchronizerThread = new SynchronizerThread(storeSynchronizer, componentInstance);
synchronizerThread.start();
} else {
@@ -356,13 +357,13 @@ public class JenaPersistenceStore implem
}
return administeredOntologies;
}
-
+
@Override
public OntologyMetaInformation saveOntology(String ontologyContent, String ontologyURI, String encoding) throws Exception {
InputStream is = new ByteArrayInputStream(ontologyContent.getBytes(encoding));
return saveOntology(is, ontologyURI, encoding);
}
-
+
@Override
public OntologyMetaInformation saveOntology(URL ontologyContent, String ontologyURI, String encoding) throws Exception {
InputStream is = ontologyContent.openStream();
@@ -381,7 +382,7 @@ public class JenaPersistenceStore implem
}
long st1 = System.currentTimeMillis();
logger.info("Creating a new ontology store for: " + ontologyURI);
-// InputStream is = new ByteArrayInputStream(ontologyContent.getBytes(encoding));
+ // InputStream is = new ByteArrayInputStream(ontologyContent.getBytes(encoding));
long st2 = System.currentTimeMillis();
// ModelMaker modelMaker = getModelMaker();
OntModelSpec oms = getOntModelSpec(true);
@@ -471,51 +472,57 @@ public class JenaPersistenceStore implem
Iterator importsItr = imports.iterator();
while (importsItr.hasNext()) {
String importedOntologyURI = (String) importsItr.next();
- resourceManager.registerOntology(importedOntologyURI);
- Model baseModel = persistenceProvider.createModel(importedOntologyURI);
+ try {
+
+ resourceManager.registerOntology(importedOntologyURI);
+ Model baseModel = persistenceProvider.createModel(importedOntologyURI);
- // Model baseModel =
- // modelMaker.getModel(importedOntologyURI);
- OntModel imported_om = ModelFactory
- .createOntologyModel(getOntModelSpec(false), baseModel);
- // FIXME Test this case
- imported_om.read(importedOntologyURI);
- ExtendedIterator importedOntClassesItr = imported_om.listClasses();
- while (importedOntClassesItr.hasNext()) {
- OntClass curOntClass = (OntClass) importedOntClassesItr.next();
- String curOntClassURI = curOntClass.getURI();
- if (curOntClassURI != null) {
- resourceManager.registerClass(importedOntologyURI, curOntClassURI);
+ // Model baseModel =
+ // modelMaker.getModel(importedOntologyURI);
+ OntModel imported_om = ModelFactory.createOntologyModel(getOntModelSpec(false),
+ baseModel);
+ // FIXME Test this case
+ imported_om.read(importedOntologyURI);
+ ExtendedIterator importedOntClassesItr = imported_om.listClasses();
+ while (importedOntClassesItr.hasNext()) {
+ OntClass curOntClass = (OntClass) importedOntClassesItr.next();
+ String curOntClassURI = curOntClass.getURI();
+ if (curOntClassURI != null) {
+ resourceManager.registerClass(importedOntologyURI, curOntClassURI);
+ }
}
- }
- ExtendedIterator importedDatatypePropertiesItr = imported_om.listDatatypeProperties();
- while (importedDatatypePropertiesItr.hasNext()) {
- DatatypeProperty curDatatypeProperty = (DatatypeProperty) importedDatatypePropertiesItr
- .next();
- String curDatatypePropertyURI = curDatatypeProperty.getURI();
- if (curDatatypePropertyURI != null) {
- resourceManager.registerDatatypeProperty(importedOntologyURI,
- curDatatypePropertyURI);
+ ExtendedIterator importedDatatypePropertiesItr = imported_om.listDatatypeProperties();
+ while (importedDatatypePropertiesItr.hasNext()) {
+ DatatypeProperty curDatatypeProperty = (DatatypeProperty) importedDatatypePropertiesItr
+ .next();
+ String curDatatypePropertyURI = curDatatypeProperty.getURI();
+ if (curDatatypePropertyURI != null) {
+ resourceManager.registerDatatypeProperty(importedOntologyURI,
+ curDatatypePropertyURI);
+ }
}
- }
- ExtendedIterator importedObjectPropertiesItr = imported_om.listObjectProperties();
- while (importedObjectPropertiesItr.hasNext()) {
- ObjectProperty curObjectProperty = (ObjectProperty) importedObjectPropertiesItr
- .next();
- String curObjectPropertyURI = curObjectProperty.getURI();
- if (curObjectPropertyURI != null) {
- resourceManager.registerObjectProperty(importedOntologyURI, curObjectPropertyURI);
+ ExtendedIterator importedObjectPropertiesItr = imported_om.listObjectProperties();
+ while (importedObjectPropertiesItr.hasNext()) {
+ ObjectProperty curObjectProperty = (ObjectProperty) importedObjectPropertiesItr
+ .next();
+ String curObjectPropertyURI = curObjectProperty.getURI();
+ if (curObjectPropertyURI != null) {
+ resourceManager.registerObjectProperty(importedOntologyURI,
+ curObjectPropertyURI);
+ }
}
- }
- ExtendedIterator importedOntIndividualsItr = imported_om.listIndividuals();
- while (importedOntIndividualsItr.hasNext()) {
- Individual curIndividual = (Individual) importedOntIndividualsItr.next();
- String curIndividualURI = curIndividual.getURI();
- if (curIndividualURI != null) {
- resourceManager.registerIndividual(importedOntologyURI, curIndividualURI);
+ ExtendedIterator importedOntIndividualsItr = imported_om.listIndividuals();
+ while (importedOntIndividualsItr.hasNext()) {
+ Individual curIndividual = (Individual) importedOntIndividualsItr.next();
+ String curIndividualURI = curIndividual.getURI();
+ if (curIndividualURI != null) {
+ resourceManager.registerIndividual(importedOntologyURI, curIndividualURI);
+ }
}
+ persistenceProvider.commit(imported_om);
+ } catch (Exception e) {
+ logger.warn("Error at importing ontology: " + importedOntologyURI, e);
}
- persistenceProvider.commit(imported_om);
}
long t9 = System.currentTimeMillis();
ontMetaInformation = retrieveOntologyMetaInformation(ontologyURI);
@@ -3004,7 +3011,8 @@ public class JenaPersistenceStore implem
OWLlinkReasonerConfiguration config = new OWLlinkReasonerConfiguration(progressMonitor, REASONER_URL,
IndividualNodeSetPolicy.BY_NAME);
- OWLlinkHTTPXMLReasoner reasoner = (OWLlinkHTTPXMLReasoner) factory.createNonBufferingReasoner(ontology, config);
+ OWLlinkHTTPXMLReasoner reasoner = (OWLlinkHTTPXMLReasoner) factory.createNonBufferingReasoner(
+ ontology, config);
reasoner.flush();
return reasoner;
}
@@ -3114,4 +3122,44 @@ public class JenaPersistenceStore implem
this.synchronizerThread.done();
this.resourceManager = null;
}
+
+ @Override
+ public ImportsForOntology retrieveOntologyImports(String ontologyURI) throws Exception {
+ ObjectFactory of = new ObjectFactory();
+ Model model = persistenceProvider.getModel(ontologyURI);
+ OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM, model);
+ ImportsForOntology imports = of.createImportsForOntology();
+ imports.setOntologyMetaInformation(retrieveOntologyMetaInformation(ontologyURI));
+ for (String importedOntologyURI : ontModel.listImportedOntologyURIs()) {
+ OntologyImport ontImport = new OntologyImport();
+ ontImport.setURI(importedOntologyURI);
+ ontImport.setHref(resourceManager.getOntologyFullPath(importedOntologyURI));
+ imports.getOntologyImport().add(ontImport);
+ }
+ return imports;
+ }
+
+ @Override
+ public void addOntologyImport(String ontologyURI, String importURI) throws Exception {
+ Model model = persistenceProvider.getModel(ontologyURI);
+ OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM, model);
+ ontModel.add(ResourceFactory.createResource(ontologyURI), OWL.imports,
+ ResourceFactory.createResource(importURI));
+ if (!persistenceProvider.hasModel(importURI)) {
+ saveOntology(new URL(importURI), importURI, "UTF-8");
+ }
+
+ }
+
+ @Override
+ public void removeOntologyImport(String ontologyURI, String importURI) throws Exception {
+ Model model = persistenceProvider.getModel(ontologyURI);
+ OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM, model);
+ ontModel.remove(ResourceFactory.createResource(ontologyURI), OWL.imports,
+ ResourceFactory.createResource(importURI));
+ List<Statement> toDelete = ontModel.listStatements(null, OWL.imports,
+ ResourceFactory.createResource(importURI)).toList();
+ ontModel.remove(toDelete);
+
+ }
}