Modified: incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ScopeResource.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ScopeResource.java?rev=1205966&r1=1205965&r2=1205966&view=diff ============================================================================== --- incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ScopeResource.java (original) +++ incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ScopeResource.java Thu Nov 24 19:50:39 2011 @@ -52,7 +52,6 @@ import org.apache.stanbol.commons.web.ba import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource; import org.apache.stanbol.ontologymanager.ontonet.api.DuplicateIDException; import org.apache.stanbol.ontologymanager.ontonet.api.ONManager; -import org.apache.stanbol.ontologymanager.ontonet.api.io.BlankOntologySource; import org.apache.stanbol.ontologymanager.ontonet.api.io.GraphContentInputSource; import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource; import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologySetInputSource; @@ -155,7 +154,7 @@ public class ScopeResource extends BaseS try { scope.getCustomSpace().addOntology(new GraphContentInputSource(content) // new OntologyContentInputSource(content) - ); + ); } catch (UnmodifiableOntologyCollectorException e) { throw new WebApplicationException(e, FORBIDDEN); } catch (UnloadableImportException e) { @@ -207,10 +206,10 @@ public class ScopeResource extends BaseS ScopeRegistry reg = onm.getScopeRegistry(); - IRI scopeiri = null; + // IRI scopeiri = null; IRI ontoiri = null; try { - scopeiri = IRI.create(uriInfo.getAbsolutePath()); + // scopeiri = IRI.create(uriInfo.getAbsolutePath()); ontoiri = IRI.create(physIri); } catch (Exception ex) { // Malformed IRI, throw bad request. @@ -219,7 +218,7 @@ public class ScopeResource extends BaseS if (reg.containsScope(scopeid)) { OntologyScope scope = reg.getScope(scopeid); try { - OntologyInputSource src = new RootOntologyIRISource(ontoiri); + OntologyInputSource<?> src = new RootOntologyIRISource(ontoiri); OntologySpace space = scope.getCustomSpace(); if (space == null) { space = onm.getOntologySpaceFactory().createCustomOntologySpace(scopeid, src); @@ -270,45 +269,42 @@ public class ScopeResource extends BaseS log.debug("Request URI {}", uriInfo.getRequestUri()); OntologyScope scope; - OntologyInputSource coreSrc = null, custSrc = null; - - if (coreOntology == null && coreRegistry == null) { - coreSrc = new BlankOntologySource(); - } + OntologyInputSource<?> coreSrc = null, custSrc = null; // First thing, check the core source. - try { + if (coreRegistry != null && !coreRegistry.isEmpty()) try { coreSrc = new LibrarySource(IRI.create(coreRegistry.replace("%23", "#")), regMgr); } catch (Exception e1) { + throw new WebApplicationException(e1, BAD_REQUEST); // Bad or not supplied core registry, try the ontology. - try { - coreSrc = new RootOntologyIRISource(IRI.create(coreOntology)); - } catch (Exception e2) { - // If this fails too, throw a bad request. - throw new WebApplicationException(e2, BAD_REQUEST); - } + } + else if (coreOntology != null && !coreOntology.isEmpty()) try { + coreSrc = new RootOntologyIRISource(IRI.create(coreOntology)); + } catch (Exception e2) { + // If this fails too, throw a bad request. + throw new WebApplicationException(e2, BAD_REQUEST); } // Don't bother if no custom was supplied at all... - if (customOntology != null || customRegistry != null) { - // ...but if it was, be prepared to throw exceptions. - try { - coreSrc = new LibrarySource(IRI.create(customRegistry.replace("%23", "#")), regMgr); - } catch (Exception e1) { - // Bad or not supplied custom registry, try the ontology. - try { - custSrc = new RootOntologyIRISource(IRI.create(customOntology)); - } catch (Exception e2) { - // If this fails too, throw a bad request. - throw new WebApplicationException(e2, BAD_REQUEST); - } - } + if (customRegistry != null && !customRegistry.isEmpty()) + // ...but if it was, be prepared to throw exceptions. + try { + coreSrc = new LibrarySource(IRI.create(customRegistry.replace("%23", "#")), regMgr); + } catch (Exception e1) { + throw new WebApplicationException(e1, BAD_REQUEST); + // Bad or not supplied custom registry, try the ontology. + } + if (customOntology != null && !customOntology.isEmpty()) try { + custSrc = new RootOntologyIRISource(IRI.create(customOntology)); + } catch (Exception e2) { + // If this fails too, throw a bad request. + throw new WebApplicationException(e2, BAD_REQUEST); } // Now the creation. try { // Expand core sources - List<OntologyInputSource> expanded = new ArrayList<OntologyInputSource>(); + List<OntologyInputSource<?>> expanded = new ArrayList<OntologyInputSource<?>>(); if (coreSrc != null) { if (coreSrc instanceof OntologySetInputSource) { for (OWLOntology o : ((OntologySetInputSource) coreSrc).getOntologies()) { @@ -322,7 +318,6 @@ public class ScopeResource extends BaseS expanded.add(new RootOntologySource(o)); else expanded.add(custSrc); } - // Invoke the appropriate factory method depending on the // availability of a custom source. // scope = (custSrc != null) ? f.createOntologyScope(scopeid, coreSrc, custSrc) : f
Modified: incubator/stanbol/trunk/owl/src/main/java/org/apache/stanbol/owl/util/OWLUtils.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/owl/src/main/java/org/apache/stanbol/owl/util/OWLUtils.java?rev=1205966&r1=1205965&r2=1205966&view=diff ============================================================================== --- incubator/stanbol/trunk/owl/src/main/java/org/apache/stanbol/owl/util/OWLUtils.java (original) +++ incubator/stanbol/trunk/owl/src/main/java/org/apache/stanbol/owl/util/OWLUtils.java Thu Nov 24 19:50:39 2011 @@ -22,6 +22,7 @@ import org.apache.clerezza.rdf.core.NonL import org.apache.clerezza.rdf.core.Triple; import org.apache.clerezza.rdf.core.TripleCollection; import org.apache.clerezza.rdf.core.UriRef; +import org.apache.clerezza.rdf.core.access.TcProvider; import org.apache.clerezza.rdf.ontologies.OWL; import org.apache.clerezza.rdf.ontologies.RDF; import org.semanticweb.owlapi.model.IRI; @@ -36,6 +37,8 @@ public class OWLUtils { private static Logger log = LoggerFactory.getLogger(OWLUtils.class); + public static final String NS_STANBOL = "http://stanbol.apache.org/"; + public static UriRef guessOntologyIdentifier(Object g) { if (g instanceof TripleCollection) return guessOntologyIdentifier((TripleCollection) g); else if (g instanceof OWLOntology) return URIUtils @@ -72,8 +75,6 @@ public class OWLUtils { return IRI.create(iri); } - public static final String NS_STANBOL = "http://stanbol.apache.org/"; - public static UriRef guessOntologyIdentifier(TripleCollection g) { Iterator<Triple> it = g.filter(null, RDF.type, OWL.Ontology); if (it.hasNext()) { @@ -84,4 +85,8 @@ public class OWLUtils { } return new UriRef(NS_STANBOL + System.currentTimeMillis()); } + + public static IRI guessOntologyIdentifier(UriRef key, TcProvider store) { + return IRI.create(guessOntologyIdentifier(store.getTriples(key)).getUnicodeString()); + } } Modified: incubator/stanbol/trunk/reengineer/xml/src/test/java/org/apache/stanbol/reengineer/xml/XMLReengineerTest.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/reengineer/xml/src/test/java/org/apache/stanbol/reengineer/xml/XMLReengineerTest.java?rev=1205966&r1=1205965&r2=1205966&view=diff ============================================================================== --- incubator/stanbol/trunk/reengineer/xml/src/test/java/org/apache/stanbol/reengineer/xml/XMLReengineerTest.java (original) +++ incubator/stanbol/trunk/reengineer/xml/src/test/java/org/apache/stanbol/reengineer/xml/XMLReengineerTest.java Thu Nov 24 19:50:39 2011 @@ -123,8 +123,8 @@ public class XMLReengineerTest { TcManager tcm = new SpecialTcManager(qe, wtcp); // Two different ontology storages, the same sparql engine and tcprovider - ONManager onManager = new ONManagerImpl(new ClerezzaOntologyProvider(tcm, offline, new Parser(), - new Serializer()), offline, emptyConf); + ONManager onManager = new ONManagerImpl(new ClerezzaOntologyProvider(tcm, offline, new Parser()), + offline, emptyConf); xmlExtractor = new XMLExtractor(new ReengineerManagerImpl(emptyConf), onManager, emptyConf); } Modified: incubator/stanbol/trunk/rules/refactor/src/main/java/org/apache/stanbol/rules/refactor/impl/RefactorerImpl.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/refactor/src/main/java/org/apache/stanbol/rules/refactor/impl/RefactorerImpl.java?rev=1205966&r1=1205965&r2=1205966&view=diff ============================================================================== --- incubator/stanbol/trunk/rules/refactor/src/main/java/org/apache/stanbol/rules/refactor/impl/RefactorerImpl.java (original) +++ incubator/stanbol/trunk/rules/refactor/src/main/java/org/apache/stanbol/rules/refactor/impl/RefactorerImpl.java Thu Nov 24 19:50:39 2011 @@ -41,10 +41,8 @@ import org.apache.felix.scr.annotations. import org.apache.felix.scr.annotations.Service; import org.apache.stanbol.ontologymanager.ontonet.api.DuplicateIDException; import org.apache.stanbol.ontologymanager.ontonet.api.ONManager; -import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource; import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyScope; import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyScopeFactory; -import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpaceFactory; import org.apache.stanbol.ontologymanager.ontonet.api.ontology.ScopeRegistry; import org.apache.stanbol.ontologymanager.ontonet.api.session.DuplicateSessionIDException; import org.apache.stanbol.ontologymanager.ontonet.api.session.Session; @@ -259,11 +257,11 @@ public class RefactorerImpl implements R ScopeRegistry scopeRegistry = onManager.getScopeRegistry(); - OntologySpaceFactory ontologySpaceFactory = onManager.getOntologySpaceFactory(); + // OntologySpaceFactory ontologySpaceFactory = onManager.getOntologySpaceFactory(); scope = null; try { - scope = ontologyScopeFactory.createOntologyScope(refactoringScopeID, (OntologyInputSource) null); + scope = ontologyScopeFactory.createOntologyScope(refactoringScopeID); log.info("Created scope with IRI " + REFACTORING_SCOPE); scopeRegistry.registerScope(scope); } catch (DuplicateIDException e) {
