From: <lor...@us...> - 2013-04-15 20:52:45
|
Revision: 3922 http://sourceforge.net/p/dl-learner/code/3922 Author: lorenz_b Date: 2013-04-15 20:52:41 +0000 (Mon, 15 Apr 2013) Log Message: ----------- Continued pattern learning algorithm. Added classes for remote ontology repositories and local datasets. Modified Paths: -------------- trunk/components-core/pom.xml trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java trunk/components-core/src/test/java/org/dllearner/algorithms/pattern/OWLAxiomRenamerTest.java Added Paths: ----------- trunk/components-core/src/main/java/org/dllearner/kb/dataset/ trunk/components-core/src/main/java/org/dllearner/kb/dataset/AbstractOWLOntologyDataset.java trunk/components-core/src/main/java/org/dllearner/kb/dataset/BioPortalDataset.java trunk/components-core/src/main/java/org/dllearner/kb/dataset/OWLOntologyDataset.java trunk/components-core/src/main/java/org/dllearner/kb/dataset/TONESDataset.java trunk/components-core/src/main/java/org/dllearner/kb/repository/ trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepository.java trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryEntry.java trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryManager.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/ trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/BioPortalRepository.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Data.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyAclEntry.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyBean.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Success.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/UserAcl.java trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/UserEntry.java trunk/components-core/src/main/java/org/dllearner/kb/repository/tones/ trunk/components-core/src/main/java/org/dllearner/kb/repository/tones/TONESRepository.java trunk/components-core/src/test/java/org/dllearner/algorithms/pattern/OWLPatternDetectionTest.java Modified: trunk/components-core/pom.xml =================================================================== --- trunk/components-core/pom.xml 2013-04-12 10:57:03 UTC (rev 3921) +++ trunk/components-core/pom.xml 2013-04-15 20:52:41 UTC (rev 3922) @@ -281,6 +281,26 @@ <artifactId>simmetrics</artifactId> <version>1.6.2</version> </dependency> + <dependency> + <groupId>com.thoughtworks.xstream</groupId> + <artifactId>xstream</artifactId> + <version>1.4.3</version> + </dependency> + <dependency> + <groupId>xpp3</groupId> + <artifactId>xpp3_min</artifactId> + <version>1.1.4c</version> + </dependency> + <dependency> + <groupId>net.sf.kxml</groupId> + <artifactId>kxml2-min</artifactId> + <version>2.3.0</version> + </dependency> + + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> </dependencies> <dependencyManagement> <dependencies> Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java 2013-04-12 10:57:03 UTC (rev 3921) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomPatternFinder.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -1,55 +1,27 @@ package org.dllearner.algorithms.pattern; -import java.util.ArrayList; -import java.util.Arrays; +import java.net.URI; import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; import java.util.Queue; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; +import org.dllearner.kb.dataset.OWLOntologyDataset; +import org.dllearner.kb.repository.OntologyRepository; +import org.dllearner.kb.repository.OntologyRepositoryEntry; import org.semanticweb.owlapi.apibinding.OWLManager; -import org.semanticweb.owlapi.expression.OWLEntityChecker; -import org.semanticweb.owlapi.expression.ParserException; -import org.semanticweb.owlapi.io.ToStringRenderer; -import org.semanticweb.owlapi.model.EntityType; import org.semanticweb.owlapi.model.IRI; -import org.semanticweb.owlapi.model.OWLAnnotationProperty; import org.semanticweb.owlapi.model.OWLAxiom; -import org.semanticweb.owlapi.model.OWLClass; -import org.semanticweb.owlapi.model.OWLClassExpression; import org.semanticweb.owlapi.model.OWLDataFactory; -import org.semanticweb.owlapi.model.OWLDataProperty; -import org.semanticweb.owlapi.model.OWLDatatype; -import org.semanticweb.owlapi.model.OWLEntity; -import org.semanticweb.owlapi.model.OWLNamedIndividual; -import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; -import org.semanticweb.owlapi.model.OWLObjectProperty; -import org.semanticweb.owlapi.model.OWLObjectUnionOf; +import org.semanticweb.owlapi.model.OWLLogicalAxiom; import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyCreationException; import org.semanticweb.owlapi.model.OWLOntologyManager; -import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; -import org.semanticweb.owlapi.reasoner.OWLReasoner; -import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; -import org.semanticweb.owlapi.util.IRIShortFormProvider; -import org.semanticweb.owlapi.util.OWLAxiomVisitorAdapter; -import org.semanticweb.owlapi.util.OWLClassExpressionVisitorAdapter; -import org.semanticweb.owlapi.util.SimpleIRIShortFormProvider; -import uk.ac.manchester.cs.owl.owlapi.OWLDataFactoryImpl; -import uk.ac.manchester.cs.owlapi.dlsyntax.DLSyntaxObjectRenderer; - -import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; +import com.google.common.collect.Multisets; + public class OWLAxiomPatternFinder { private static Queue<String> classVarQueue = new LinkedList<String>(); @@ -69,133 +41,46 @@ } }; + + private OntologyRepository repository; + private OWLOntologyManager manager; + private OWLDataFactory dataFactory; - public OWLAxiomPatternFinder(OWLOntology ontology) { - generalizeAxioms(ontology.getLogicalAxioms()); + public OWLAxiomPatternFinder(OWLOntologyDataset dataset) { + } - private void generalizeAxioms(Collection<? extends OWLAxiom> axioms){ - ManchesterOWLSyntaxOWLObjectRendererImpl renderer = new ManchesterOWLSyntaxOWLObjectRendererImpl(); - String NS = "http://dl-learner.org/pattern/"; - IRIShortFormProvider sfp = new SimpleIRIShortFormProvider(); -// renderer.setShortFormProvider(new FullIRIEntityShortFromProvider()); - for(OWLAxiom axiom : axioms){ - OWLAxiom nnfAxiom = axiom.getNNF(); - String renderedAxiom = renderer.render(nnfAxiom); - final OWLDataFactory dataFactory = new OWLDataFactoryImpl(); - Map<OWLEntity, OWLEntity> map = new HashMap<OWLEntity, OWLEntity>(); - Queue<String> classVarQueue = new LinkedList<String>(this.classVarQueue); - Queue<String> propertyVarQueue = new LinkedList<String>(this.propertyVarQueue); - Queue<String> individualVarQueue = new LinkedList<String>(this.individualVarQueue); - Queue<String> datatypeVarQueue = new LinkedList<String>(this.datatypeVarQueue); - final Set<String> classNames = new HashSet<String>(); - final Set<String> objectPropertyNames = new HashSet<String>(); - final Set<String> dataPropertyNames = new HashSet<String>(); - final Set<String> individualNames = new HashSet<String>(); - final Set<String> datatypeNames = new HashSet<String>(); - for(OWLEntity entity : axiom.getSignature()){ - if(entity.isOWLClass()){ - if(entity.asOWLClass().isBuiltIn()){ - - } else { - OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.CLASS, IRI.create(NS + classVarQueue.poll())); - map.put(entity, newEntity); - classNames.add(newEntity.toStringID()); - } - } else if(entity.isOWLObjectProperty()){ - OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.OBJECT_PROPERTY, IRI.create(NS + propertyVarQueue.poll())); - map.put(entity, newEntity); - objectPropertyNames.add(newEntity.toStringID()); - } else if(entity.isOWLDataProperty()){ - OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.DATA_PROPERTY, IRI.create(NS + propertyVarQueue.poll())); - map.put(entity, newEntity); - dataPropertyNames.add(newEntity.toStringID()); - } else if(entity.isOWLNamedIndividual()){ - OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.NAMED_INDIVIDUAL, IRI.create(NS + individualVarQueue.poll())); - map.put(entity, newEntity); - individualNames.add(newEntity.toStringID()); - } else if(entity.isOWLDatatype()){ -// OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.DATATYPE, IRI.create(datatypeVarQueue.poll())); - OWLEntity newEntity = dataFactory.getOWLEntity(EntityType.DATATYPE, IRI.create(sfp.getShortForm(entity.getIRI()))); -// OWLEntity newEntity = entity; - map.put(entity, newEntity); - datatypeNames.add(newEntity.toStringID()); + public OWLAxiomPatternFinder(OntologyRepository repository) { + this.repository = repository; + manager = OWLManager.createOWLOntologyManager(); + dataFactory = manager.getOWLDataFactory(); + } + + public void start(){ + OWLAxiomRenamer renamer = new OWLAxiomRenamer(dataFactory); + Collection<OntologyRepositoryEntry> entries = repository.getEntries(); + Multiset<OWLAxiom> multiset = HashMultiset.create(); + for (OntologyRepositoryEntry entry : entries) { + try { + URI uri = entry.getPhysicalURI(); + OWLOntology ontology = manager.loadOntology(IRI.create(uri)); + for(OWLLogicalAxiom axiom : ontology.getLogicalAxioms()){ + OWLAxiom renamedAxiom = renamer.rename(axiom); + multiset.add(renamedAxiom); } + } catch (OWLOntologyCreationException e) { + e.printStackTrace(); } -// System.out.println(renderedAxiom); - for (Entry<OWLEntity, OWLEntity> entry : map.entrySet()) { - OWLEntity key = entry.getKey(); - OWLEntity value = entry.getValue(); - renderedAxiom = renderedAxiom.replaceAll("\\b" + sfp.getShortForm(key.getIRI()) + "\\b", value.toStringID()); + for (OWLAxiom owlAxiom : Multisets.copyHighestCountFirst(multiset).elementSet()) { + System.out.println(owlAxiom + ": " + multiset.count(owlAxiom)); } - ManchesterOWLSyntaxEditorParser parser = new ManchesterOWLSyntaxEditorParser(dataFactory, renderedAxiom); - parser.setOWLEntityChecker(new OWLEntityChecker() { - - @Override - public OWLObjectProperty getOWLObjectProperty(String iri) { - return objectPropertyNames.contains(iri) ? dataFactory.getOWLObjectProperty(IRI.create(iri)) : null; - } - - @Override - public OWLNamedIndividual getOWLIndividual(String iri) { - return individualNames.contains(iri) ? dataFactory.getOWLNamedIndividual(IRI.create(iri)) : null; - } - - @Override - public OWLDatatype getOWLDatatype(String iri) { - return datatypeNames.contains(iri) ? dataFactory.getOWLDatatype(IRI.create(iri)) : null; - } - - @Override - public OWLDataProperty getOWLDataProperty(String iri) { - return dataPropertyNames.contains(iri) ? dataFactory.getOWLDataProperty(IRI.create(iri)) : null; - } - - @Override - public OWLClass getOWLClass(String iri) { - if(iri.equals("Thing")){ - return dataFactory.getOWLThing(); - } else if(iri.equals("Nothing")){ - return dataFactory.getOWLNothing(); - } else { - return classNames.contains(iri) ? dataFactory.getOWLClass(IRI.create(iri)) : null; - } - } - - @Override - public OWLAnnotationProperty getOWLAnnotationProperty(String iri) { - return null; - } - }); - try { - OWLAxiom parsedAxiom = parser.parseAxiom(); - System.out.println(parsedAxiom); - } catch (ParserException e) { - e.printStackTrace(); - } } + for (OWLAxiom owlAxiom : Multisets.copyHighestCountFirst(multiset).elementSet()) { + System.out.println(owlAxiom + ": " + multiset.count(owlAxiom)); + } } public static void main(String[] args) throws Exception { - ToStringRenderer.getInstance().setRenderer(new DLSyntaxObjectRenderer()); - String ontologyURL = "http://protege.stanford.edu/plugins/owl/owl-library/koala.owl"; - OWLOntologyManager man = OWLManager.createOWLOntologyManager(); - OWLDataFactory dataFactory = man.getOWLDataFactory(); - OWLOntology ontology = man.loadOntology(IRI.create(ontologyURL)); - OWLAxiomRenamer renamer = new OWLAxiomRenamer(dataFactory); - Multiset<OWLAxiom> multiset = HashMultiset.create(); - for (OWLAxiom axiom : ontology.getLogicalAxioms()) { - OWLAxiom renamedAxiom = renamer.rename(axiom); - multiset.add(renamedAxiom); -// System.out.println(axiom + "-->" + renamedAxiom); - } - for (OWLAxiom owlAxiom : multiset.elementSet()) { - System.out.println(owlAxiom + ": " + multiset.count(owlAxiom)); - } - - -// OWLAxiomPatternFinder pf = new OWLAxiomPatternFinder(ontology); } - } Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java 2013-04-12 10:57:03 UTC (rev 3921) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLAxiomRenamer.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -38,6 +38,7 @@ import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; +import org.semanticweb.owlapi.model.OWLLiteral; import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; @@ -166,6 +167,13 @@ @Override public void visit(OWLObjectPropertyAssertionAxiom axiom) { + OWLObjectPropertyExpression property = axiom.getProperty(); + property = expressionRenamer.rename(property); + OWLIndividual subject = axiom.getSubject(); + subject = expressionRenamer.rename(subject); + OWLIndividual object = axiom.getObject(); + object = expressionRenamer.rename(object); + renamedAxiom = df.getOWLObjectPropertyAssertionAxiom(property, subject, object); } @Override @@ -177,6 +185,11 @@ @Override public void visit(OWLSubObjectPropertyOfAxiom axiom) { + OWLObjectPropertyExpression subProperty = axiom.getSubProperty(); + subProperty = expressionRenamer.rename(subProperty); + OWLObjectPropertyExpression superProperty = axiom.getSuperProperty(); + superProperty = expressionRenamer.rename(superProperty); + renamedAxiom = df.getOWLSubObjectPropertyOfAxiom(subProperty, superProperty); } @Override @@ -231,6 +244,13 @@ @Override public void visit(OWLDataPropertyAssertionAxiom axiom) { + OWLDataPropertyExpression property = axiom.getProperty(); + property = expressionRenamer.rename(property); + OWLIndividual subject = axiom.getSubject(); + subject = expressionRenamer.rename(subject); + OWLLiteral object = axiom.getObject(); + object = expressionRenamer.rename(object); + renamedAxiom = df.getOWLDataPropertyAssertionAxiom(property, subject, object); } @Override @@ -249,6 +269,11 @@ @Override public void visit(OWLSubDataPropertyOfAxiom axiom) { + OWLDataPropertyExpression subProperty = axiom.getSubProperty(); + subProperty = expressionRenamer.rename(subProperty); + OWLDataPropertyExpression superProperty = axiom.getSuperProperty(); + superProperty = expressionRenamer.rename(superProperty); + renamedAxiom = df.getOWLSubDataPropertyOfAxiom(subProperty, superProperty); } @Override Modified: trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java 2013-04-12 10:57:03 UTC (rev 3921) +++ trunk/components-core/src/main/java/org/dllearner/algorithms/pattern/OWLClassExpressionRenamer.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -64,9 +64,9 @@ private static final String NS = "http://dl-learner.org/pattern/"; - private Queue<String> classVarQueue = new LinkedList<String>(Arrays.asList("A", "B", "C" , "D")); - private Queue<String> propertyVarQueue = new LinkedList<String>(Arrays.asList("p", "q", "r" , "s")); - private Queue<String> individualVarQueue = new LinkedList<String>(Arrays.asList("a", "b", "c" , "d")); + private Queue<String> classVarQueue = new LinkedList<String>(Arrays.asList("A", "B", "C" , "D", "E", "F", "G")); + private Queue<String> propertyVarQueue = new LinkedList<String>(Arrays.asList("p", "q", "r" , "s", "t")); + private Queue<String> individualVarQueue = new LinkedList<String>(Arrays.asList("a", "b", "c" , "d", "e", "f", "g")); private OWLDataFactory df; private Map<OWLEntity, OWLEntity> renaming; private OWLObject renamedOWLObject; @@ -101,6 +101,12 @@ return (OWLDataRange) renamedOWLObject; } + public OWLLiteral rename(OWLLiteral lit){ + renamedOWLObject = null; + renamedOWLObject = lit; + return (OWLLiteral) renamedOWLObject; + } + @Override public void visit(OWLObjectIntersectionOf desc) { List<OWLClassExpression> operands = desc.getOperandsAsList(); @@ -325,6 +331,12 @@ @Override public void visit(OWLAnonymousIndividual ind) { + OWLEntity newEntity = renaming.get(ind); + if(newEntity == null){ + newEntity = df.getOWLNamedIndividual(getIRI(individualVarQueue.poll())); +// renaming.put(ind, newEntity); + } + renamedOWLObject = (OWLNamedIndividual)newEntity; } @Override @@ -333,7 +345,13 @@ } @Override - public void visit(OWLDataOneOf arg0) { + public void visit(OWLDataOneOf desc) { + Set<OWLLiteral> literals = desc.getValues(); + Set<OWLLiteral> renamedLiterals = new TreeSet<OWLLiteral>(); + for (OWLLiteral lit : literals) { + renamedLiterals.add(rename(lit)); + } + renamedOWLObject = df.getOWLDataOneOf(renamedLiterals); } @Override Modified: trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java 2013-04-12 10:57:03 UTC (rev 3921) +++ trunk/components-core/src/main/java/org/dllearner/kb/SparqlEndpointKS.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -28,6 +28,7 @@ import org.dllearner.core.KnowledgeSource; import org.dllearner.core.config.ConfigOption; import org.dllearner.core.config.ListStringEditor; +import org.dllearner.kb.sparql.ExtractionDBCache; import org.dllearner.kb.sparql.SPARQLTasks; import org.dllearner.kb.sparql.SparqlEndpoint; import org.springframework.beans.propertyeditors.URLEditor; @@ -44,6 +45,7 @@ public class SparqlEndpointKS implements KnowledgeSource { private SparqlEndpoint endpoint; + private ExtractionDBCache cache; private boolean supportsSPARQL_1_1 = false; private boolean isRemote = true; private boolean initialized = false; @@ -64,9 +66,18 @@ } public SparqlEndpointKS(SparqlEndpoint endpoint) { + this(endpoint, null); + } + + public SparqlEndpointKS(SparqlEndpoint endpoint, ExtractionDBCache cache) { this.endpoint = endpoint; + this.cache = cache; } + public ExtractionDBCache getCache() { + return cache; + } + @Override public void init() throws ComponentInitException { if(!initialized){ Added: trunk/components-core/src/main/java/org/dllearner/kb/dataset/AbstractOWLOntologyDataset.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/dataset/AbstractOWLOntologyDataset.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/dataset/AbstractOWLOntologyDataset.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,342 @@ +package org.dllearner.kb.dataset; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeSet; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.semanticweb.HermiT.Configuration; +import org.semanticweb.HermiT.Reasoner; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLClass; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.semanticweb.owlapi.reasoner.ConsoleProgressMonitor; +import org.semanticweb.owlapi.reasoner.OWLReasoner; +import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; +import org.semanticweb.owlapi.reasoner.SimpleConfiguration; + +import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; +import com.google.common.io.Files; + +public abstract class AbstractOWLOntologyDataset implements OWLOntologyDataset{ + + protected Collection<OWLOntology> ontologies = new TreeSet<OWLOntology>(); + protected Collection<OWLOntology> correctOntologies = new TreeSet<OWLOntology>(); + protected Collection<OWLOntology> incoherentOntologies = new TreeSet<OWLOntology>(); + protected Collection<OWLOntology> inconsistentOntologies = new TreeSet<OWLOntology>(); + + protected String name; + + protected File directory; + protected File correctSubdirectory; + protected File inconsistentSubdirectory; + protected File incoherentSubdirectory; + protected File errorSubdirectory; + protected File tooLargeSubdirectory; + + protected OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance(); + OWLOntologyManager man = OWLManager.createOWLOntologyManager(); + + protected Map<URL, String> ontologyURLs = new HashMap<URL, String>(); + + private final int nrOfThreads = 1; + private boolean analyze = false; + + public AbstractOWLOntologyDataset(String name, boolean analyze) { + this.name = name; + this.analyze = analyze; + //create file structure + directory = new File(datasetDirectory, name); + directory.mkdirs(); + correctSubdirectory = new File(directory, "correct"); + correctSubdirectory.mkdirs(); + incoherentSubdirectory = new File(directory, "incoherent"); + incoherentSubdirectory.mkdirs(); + inconsistentSubdirectory = new File(directory, "inconsistent"); + inconsistentSubdirectory.mkdirs(); + tooLargeSubdirectory = new File(directory, "too_large"); + tooLargeSubdirectory.mkdirs(); + errorSubdirectory = new File(directory, "error"); + errorSubdirectory.mkdirs(); + addOntologyURLs(); + initialize(); + } + + public AbstractOWLOntologyDataset(String name) { + this(name, false); + } + + private boolean analyzed(URL url){ + String filename = getFilename(url); + for(File parent : Arrays.asList(tooLargeSubdirectory, correctSubdirectory, incoherentSubdirectory, inconsistentSubdirectory, errorSubdirectory)){ + File file = new File(parent, filename); + if(file.exists()){ + return true; + } + } + return false; + } + + private Set<String> load403Errors(){ + Set<String> errors = new HashSet<String>(); + try { + if(new File(directory, "403.txt").exists()){ + errors = new HashSet<String>(Files.readLines(new File(directory, "403.txt"), Charset.defaultCharset())); + } + } catch (IOException e) { + e.printStackTrace(); + } + return errors; + } + + private boolean analyzedDataset(){ + return new File(directory + "/" + "analyzed").exists(); + } + + public void initialize(){ + //check if dataset was already analyzed + boolean analyzed = analyzedDataset(); + if(!analyzed){ + Set<String> errors = load403Errors(); + ExecutorService threadPool = Executors.newFixedThreadPool(nrOfThreads); + List<Entry<URL, String>> urlList = new ArrayList<java.util.Map.Entry<URL, String>>(ontologyURLs.entrySet()); + Collections.shuffle(urlList); + for (java.util.Map.Entry<URL, String> entry : urlList) { + URL url = entry.getKey(); + if(!errors.contains(url.toString()) && !analyzed(url)){ + threadPool.submit(new OntologyLoadingTask(url)); + } + } + threadPool.shutdown(); + try { + threadPool.awaitTermination(100, TimeUnit.MINUTES); + } catch (InterruptedException e) { + e.printStackTrace(); + } + try { + new File(directory + "/" + "analyzed").createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + + } + } + + protected abstract void addOntologyURLs(); + + private void analyzeAndCategorizeOntology(OWLOntology ontology, String filename){ + System.out.println("Analyzing ontology " + filename + "..."); + OWLReasoner reasoner; + File from = new File(man.getOntologyDocumentIRI(ontology).toURI()); + try { + Configuration conf = new Configuration(); + conf.reasonerProgressMonitor = new ConsoleProgressMonitor(); + conf.ignoreUnsupportedDatatypes = true; + reasoner = new Reasoner(conf, ontology); + int logicalAxiomCount = ontology.getLogicalAxiomCount(); + boolean consistent = reasoner.isConsistent(); + Set<OWLClass> unsatisfiableClasses = null; + + if(consistent){ + unsatisfiableClasses = reasoner.getUnsatisfiableClasses().getEntitiesMinusBottom(); + if(!unsatisfiableClasses.isEmpty()){ + File to = new File(incoherentSubdirectory, filename); + Files.move(from, to); + } else { + File to = new File(correctSubdirectory, filename); + Files.move(from, to); + } + } else { + File to = new File(inconsistentSubdirectory, filename); + Files.move(from, to); + } + System.out.println(consistent + "\t" + logicalAxiomCount + "\t" + ((unsatisfiableClasses != null) ? unsatisfiableClasses.size() : "n/a")); + reasoner.dispose(); + } catch (Exception e){ + e.printStackTrace(); + try { + reasoner = reasonerFactory.createNonBufferingReasoner(ontology, new SimpleConfiguration(new ConsoleProgressMonitor())); + int logicalAxiomCount = ontology.getLogicalAxiomCount(); + boolean consistent = reasoner.isConsistent(); + Set<OWLClass> unsatisfiableClasses = null; + if(consistent){ + unsatisfiableClasses = reasoner.getUnsatisfiableClasses().getEntitiesMinusBottom(); + if(!unsatisfiableClasses.isEmpty()){ + File to = new File(incoherentSubdirectory, filename); + Files.move(from, to); + } else { + File to = new File(correctSubdirectory, filename); + Files.move(from, to); + } + } else { + File to = new File(inconsistentSubdirectory, filename); + Files.move(from, to); + } + System.out.println(consistent + "\t" + logicalAxiomCount + "\t" + ((unsatisfiableClasses != null) ? unsatisfiableClasses.size() : "n/a")); + reasoner.dispose(); + } catch (Exception e1){ + File to = new File(errorSubdirectory, filename); + try { + Files.move(from, to); + } catch (IOException e2) { + e2.printStackTrace(); + } + } + } + } + + protected OWLOntology loadOWLOntology(URL url) { + OWLOntology ontology = loadFromLocal(url); + if(ontology == null){ + File file = null; + try { + file = downloadFile(url); + if(file != null){ + ontology = man.loadOntologyFromOntologyDocument(file); + } + } catch (Exception e) { + e.printStackTrace(); + String filename = getFilename(url); + File to = new File(errorSubdirectory, filename); + try { + Files.move(file, to); + } catch (IOException e2) { + e2.printStackTrace(); + } + } + } + return ontology; + } + + private OWLOntology loadFromLocal(URL url){ + String filename = getFilename(url); + for(File parent : Arrays.asList(directory)){ + File file = new File(parent, filename); + if(file.exists()){ + try { + OWLOntology ontology = man.loadOntologyFromOntologyDocument(file); + return ontology; + } catch(Exception e){ + e.printStackTrace(); + File to = new File(errorSubdirectory, filename); + try { + Files.move(file, to); + } catch (IOException e2) { + e2.printStackTrace(); + } + } + } + } + return null; + } + + private String getFilename(URL url){ + return ontologyURLs.get(url); +// String filename = url.toString().substring(url.toString().lastIndexOf("/")); +// return filename; + } + + /** + * Download the file such that later on we can load it from the local file system. + */ + protected File downloadFile(URL url){ + + String filename = getFilename(url); + File file = new File(directory + "/" + filename); + if(!file.exists()){ + System.out.print("Downloading file..."); + try { + InputStream is = url.openConnection().getInputStream(); + OutputStream out = new FileOutputStream(file); + int read = 0; + byte[] bytes = new byte[1024]; + + while ((read = is.read(bytes)) != -1) { + out.write(bytes, 0, read); + } + + is.close(); + out.flush(); + out.close(); + System.out.println("done."); + return file; + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + add403Error(url); + } + } + return null; + } + + private void add403Error(URL url){ + try { + Files.append(url.toString() + "\n", new File(directory, "403.txt"), Charset.defaultCharset()); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public Collection<OWLOntology> loadOntologies() { + return ontologies; + } + + @Override + public Collection<OWLOntology> loadIncoherentOntologies() { + return incoherentOntologies; + } + + @Override + public Collection<OWLOntology> loadInconsistentOntologies() { + return inconsistentOntologies; + } + + class OntologyLoadingTask implements Runnable{ + + private URL url; + + public OntologyLoadingTask(URL url) { + this.url = url; + } + + @Override + public void run() { + System.out.println("Processing " + ontologyURLs.get(url)); + OWLOntology ontology = loadOWLOntology(url); + if(ontology != null){ + if(analyze){ + analyzeAndCategorizeOntology(ontology, getFilename(url)); + } else { + ontologies.add(ontology); + } + } + } + + } + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/dataset/BioPortalDataset.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/dataset/BioPortalDataset.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/dataset/BioPortalDataset.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,34 @@ +package org.dllearner.kb.dataset; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URLEncoder; + +import org.dllearner.kb.repository.OntologyRepositoryEntry; +import org.dllearner.kb.repository.bioportal.BioPortalRepository; + +public class BioPortalDataset extends AbstractOWLOntologyDataset{ + + private static final String name = "BioPortal"; + + public BioPortalDataset() { + super(name); + } + + @Override + protected void addOntologyURLs() { + BioPortalRepository bioportal = new BioPortalRepository(); + bioportal.initialize(); + for (OntologyRepositoryEntry entry : bioportal.getEntries()) { + try { + String name = URLEncoder.encode(entry.getOntologyShortName(), "UTF-8"); + super.ontologyURLs.put(entry.getPhysicalURI().toURL(), name); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + } + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/dataset/OWLOntologyDataset.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/dataset/OWLOntologyDataset.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/dataset/OWLOntologyDataset.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,16 @@ +package org.dllearner.kb.dataset; + +import java.io.File; +import java.util.Collection; + +import org.semanticweb.owlapi.model.OWLOntology; + +public interface OWLOntologyDataset { + + static File datasetDirectory = new File("dataset"); + + Collection<OWLOntology> loadOntologies(); + Collection<OWLOntology> loadIncoherentOntologies(); + Collection<OWLOntology> loadInconsistentOntologies(); + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/dataset/TONESDataset.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/dataset/TONESDataset.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/dataset/TONESDataset.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,36 @@ +package org.dllearner.kb.dataset; + +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URLEncoder; + +import org.dllearner.kb.repository.OntologyRepositoryEntry; +import org.dllearner.kb.repository.tones.TONESRepository; + +public class TONESDataset extends AbstractOWLOntologyDataset{ + + private static final String name = "TONES"; + + public TONESDataset() { + super(name); + } + + @Override + protected void addOntologyURLs() { + TONESRepository tones = new TONESRepository(); + tones.initialize(); + for (OntologyRepositoryEntry entry : tones.getEntries()) { + try { + String name = URLEncoder.encode(entry.getOntologyShortName(), "UTF-8"); + ontologyURLs.put(entry.getPhysicalURI().toURL(), name); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + } + + + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepository.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepository.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepository.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,32 @@ +package org.dllearner.kb.repository; + +import java.util.Collection; +import java.util.List; + +public interface OntologyRepository { + + /** + * Gets the name of the repository + * @return A short name for the repository + */ + String getName(); + + /** + * Gets a description of the location of the repository + * @return A human readable description of the repository location + */ + String getLocation(); + + + /** + * Ensures the repository is up to date + */ + void refresh(); + + void initialize(); + + Collection<OntologyRepositoryEntry> getEntries(); + + List<Object> getMetaDataKeys(); + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryEntry.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryEntry.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryEntry.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,33 @@ +package org.dllearner.kb.repository; + +import java.net.URI; + +public interface OntologyRepositoryEntry { + /** + * Gets a short human readable name for this entry + * @return A short human readable name + */ + String getOntologyShortName(); + + + /** + * Gets the URI of the ontology that is described by this entry. + * @return The ontology URI. + */ + URI getOntologyURI(); + + + /** + * Gets the physical URI of the ontology that is described by this entry. + * @return The physical URI. + */ + URI getPhysicalURI(); + + + /** + * Gets associated metadata. + * @param key The key that describes the metadata + * @return The metadata or <code>null</code> if there is no metadata associated with this key. + */ + String getMetaData(Object key); +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryManager.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryManager.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/OntologyRepositoryManager.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,32 @@ +package org.dllearner.kb.repository; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +public class OntologyRepositoryManager { + private static OntologyRepositoryManager instance; + + private List<OntologyRepository> repositories; + + private OntologyRepositoryManager() { + repositories = new ArrayList<OntologyRepository>(); + } + + public static synchronized OntologyRepositoryManager getManager() { + if(instance == null) { + instance = new OntologyRepositoryManager(); + } + return instance; + } + + + public void addRepository(OntologyRepository repository) { + repositories.add(repository); + } + + public Collection<OntologyRepository> getOntologyRepositories() { + return Collections.unmodifiableList(repositories); + } +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/BioPortalRepository.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/BioPortalRepository.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/BioPortalRepository.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,166 @@ +package org.dllearner.kb.repository.bioportal; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.apache.log4j.Logger; +import org.dllearner.kb.repository.OntologyRepository; +import org.dllearner.kb.repository.OntologyRepositoryEntry; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.IRI; +import org.semanticweb.owlapi.model.OWLOntology; + +import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.io.xml.KXml2Driver; + +public class BioPortalRepository implements OntologyRepository { + + private static final Logger log = Logger.getLogger(BioPortalRepository.class); + + private String apiKey = "8fadfa2c-47de-4487-a1f5-b7af7378d693"; + private String serviceURL = "http://rest.bioontology.org/bioportal/ontologies"; + + private List<OntologyRepositoryEntry> entries = new ArrayList<OntologyRepositoryEntry>(); + + @Override + public String getName() { + return "BioPortal"; + } + + @Override + public String getLocation() { + return "http://www.bioontology.org/"; + } + + @Override + public void initialize() { + refresh(); + } + + @Override + public void refresh() { + fillRepository(); + } + + private void fillRepository(){ + XStream xstream = new XStream(new KXml2Driver()); + xstream.alias("success", Success.class); + xstream.alias("data", Data.class); + xstream.alias("ontologyBean", OntologyBean.class); +// xstream.alias("userAcl", UserAcl.class); + xstream.alias("userEntry", UserEntry.class); + + InputStream is = null; + try { + is = getInputStream(new URL(withAPIKey(serviceURL))); + } catch (IOException e) { + e.printStackTrace(); + } + if (is == null) { + return; + } + Success success = (Success) xstream.fromXML(is); + if (success == null) { + return; + } + List<OntologyBean> beans = success.getData().getOntologyBeans(); + entries = new ArrayList<OntologyRepositoryEntry>(); + for(OntologyBean bean : beans){ + URI physicalURI = URI.create(withAPIKey(serviceURL + "/download/" + bean.getId())); + String shortName = bean.getDisplayLabel(); + boolean add = false; + for(String filename : bean.getFilenames()){ + if(filename.endsWith(".owl") || filename.endsWith("rdf") || filename.endsWith(".obo") || filename.endsWith(".nt") || filename.endsWith("*.ttl")){ + add = true; + break; + } + } + if(add){ + entries.add(new RepositoryEntry(physicalURI, physicalURI, shortName)); + } + } + log.info("Loaded " + entries.size() + " ontology entries from BioPortal."); + } + + @Override + public Collection<OntologyRepositoryEntry> getEntries() { + return entries; + } + + @Override + public List<Object> getMetaDataKeys() { + // TODO Auto-generated method stub + return null; + } + + private InputStream getInputStream(URL url) throws IOException { + if (url.getProtocol().equals("http")) { + URLConnection conn; + conn = url.openConnection(); + conn.setRequestProperty("Accept", "application/rdf+xml"); + conn.addRequestProperty("Accept", "text/xml"); + conn.addRequestProperty("Accept", "*/*"); + return conn.getInputStream(); + } else { + return url.openStream(); + } + } + + private String withAPIKey(String url){ + return url + "?apikey=" + apiKey; + } + + public static void main(String[] args) throws Exception{ + Collection<OntologyRepositoryEntry> entries = new BioPortalRepository().getEntries(); + for(OntologyRepositoryEntry entry : entries){ + System.out.println("Loading " + entry.getOntologyShortName()); + System.out.println("From " + entry.getPhysicalURI()); + OWLOntology ont = OWLManager.createOWLOntologyManager().loadOntology(IRI.create(entry.getPhysicalURI())); + System.out.println(ont.getAxiomCount()); + } + + } + + private class RepositoryEntry implements OntologyRepositoryEntry { + + private String shortName; + + private URI ontologyURI; + + private URI physicalURI; + + public RepositoryEntry(URI ontologyURI, URI physicalURI, String shortName) { + this.ontologyURI = ontologyURI; + this.physicalURI = physicalURI; + this.shortName = shortName; + } + + + public String getOntologyShortName() { + return shortName; + } + + + public URI getOntologyURI() { + return ontologyURI; + } + + + public URI getPhysicalURI() { + return physicalURI; + } + + + public String getMetaData(Object key) { + return null; + } + + } + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Data.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Data.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Data.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,16 @@ +package org.dllearner.kb.repository.bioportal; + +import java.util.ArrayList; +import java.util.List; + +public class Data { + List<OntologyBean> list = new ArrayList<OntologyBean>(); + + public void setOntologyBeans(List<OntologyBean> list) { + this.list = list; + } + + public List<OntologyBean> getOntologyBeans() { + return list; + } +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyAclEntry.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyAclEntry.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyAclEntry.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,45 @@ +package org.dllearner.kb.repository.bioportal; + +public class OntologyAclEntry { + private String ontologyId; + private String isOwner; + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "OntologyAclEntry [isOwner=" + isOwner + ", ontologyId=" + + ontologyId + "]"; + } + + /** + * @return the ontologyId + */ + public String getOntologyId() { + return ontologyId; + } + + /** + * @param ontologyId + * the ontologyId to set + */ + public void setOntologyId(String ontologyId) { + this.ontologyId = ontologyId; + } + + /** + * @return the isOwner + */ + public String getIsOwner() { + return isOwner; + } + + /** + * @param isOwner + * the isOwner to set + */ + public void setIsOwner(String isOwner) { + this.isOwner = isOwner; + } +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyBean.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyBean.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/OntologyBean.java 2013-04-15 20:52:41 UTC (rev 3922) @@ -0,0 +1,564 @@ +package org.dllearner.kb.repository.bioportal; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * Simplified version of the + * <code>org.ncbo.stanford.bean.concept.OntologyBean</code> class used to decode + * the "ontologyBean" element from a successful REST call to a BioPortal + * ontology service + * + * @author csnyulas + * + */ +public class OntologyBean implements Comparable<OntologyBean> { + + public static final String DEFAULT_SYNONYM_SLOT = "http://www.w3.org/2004/02/skos/core#altLabel"; + public static final String DEFAULT_PREFERRED_NAME_SLOT = "http://www.w3.org/2004/02/skos/core#prefLabel"; + public static final String DEFAULT_DEFINITION_SLOT = "http://www.w3.org/2004/02/skos/core#definition"; + public static final String DEFAULT_AUTHOR_SLOT = "http://purl.org/dc/elements/1.1/creator"; + + private Integer id; + private Integer ontologyId; + // virtual view id(s) on the virtual ontology + private List<Integer> virtualViewIds = new ArrayList<Integer>(0); + private Integer internalVersionNumber; + private List<Integer> userIds; + private String versionNumber; + private String versionStatus; + private Byte isRemote; + private Byte isReviewed; + private Integer statusId; + private Date dateCreated; + private Date dateReleased; + private String oboFoundryId; + private Byte isManual; + private String displayLabel; + private String description; + private String abbreviation; + private String format; + private String contactName; + private String contactEmail; + private String homepage; + private String documentation; + private String publication; + private String urn; + private String codingScheme; + private String targetTerminologies; + private Byte isFlat; + private Byte isFoundry; + private Byte isMetadataOnly; + private String synonymSlot; + private String preferredNameSlot; + private String documentationSlot; + private String authorSlot; + private String slotWithUniqueValue; + private Integer preferredMaximumSubclassLimit; + private String obsoleteParent; + private String naturalLanguage; + private String obsoleteProperty; + private String licenseInformation; + + private String viewingRestriction; + + private List<UserEntry> userAcl = new ArrayList<UserEntry>(0); + + private boolean isView = false; + + // category id(s) + private List<Integer> categoryIds = new ArrayList<Integer>(0); + + // group id(s) + private List<Integer> groupIds = new ArrayList<Integer>(0); + + // file name(s) + private List<String> filenames = new ArrayList<String>(0); + + // source fileItem + // private FileItem fileItem; + + // destination directory + private String filePath; + + // Download location of ontology + private String downloadLocation; + + // views on this ontology version + private List<Integer> hasViews = new ArrayList<Integer>(0); + + // view specific properties + private List<Integer> viewOnOntologyVersionId = new ArrayList<Integer>(0); + private String viewDefinition; + private String viewDefinitionLanguage; + private String viewGenerationEngine; + + @Override + public String toString() { + final int max = 80; + String viewDef = this.getViewDefinition(); + + if (viewDef != null && viewDef.length() > max) { + viewDef = viewDef.substring(0, max) + "..."; + } + + String name = isView ? "OntologyView " : "Ontology "; + + return name + "{Id: " + this.getId() + ", Ontology Id: " + this.getOntologyId() + ", Virtual View Ids: " + + this.getVirtualViewIds() + ", Remote: " + this.getIsRemote() + ", Obo Foundry Id: " + + this.getOboFoundryId() + ", Internal Version Number: " + this.getInternalVersionNumber() + + ", Date Created: " + this.getDateCreated() + ", User Ids: " + this.getUserIds() + + ", Version Number: " + this.getVersionNumber() + ", Version Status: " + this.getVersionStatus() + + ", Display Label: " + this.getDisplayLabel() + ", Description: " + this.getDescription() + + ", Abbreviation: " + this.getAbbreviation() + ", Format: " + this.getFormat() + ", Contact Name: " + + this.getContactName() + ", Contact Email: " + this.getContactEmail() + ", Foundry: " + + this.getIsFoundry() + " Coding Scheme: " + this.getCodingScheme() + ", Target Terminologies: " + + this.getTargetTerminologies() + ", Synonym Slot: " + this.getSynonymSlot() + + ", Preferred Name Slot: " + this.getPreferredNameSlot() + ", View Definition: " + viewDef + + ", View Definition Language: " + this.getViewDefinitionLanguage() + ", View Generation Engine: " + + this.getViewGenerationEngine() + ", View on Ontology Versions: " + this.getViewOnOntologyVersionId() + + "}"; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getOntologyId() { + return ontologyId; + } + + public void setOntologyId(Integer ontologyId) { + this.ontologyId = ontologyId; + } + + public List<Integer> getVirtualViewIds() { + return virtualViewIds; + } + + public void setVirtualViewIds(List<Integer> virtualViewIds) { + this.virtualViewIds = virtualViewIds; + } + + public Integer getInternalVersionNumber() { + return internalVersionNumber; + } + + public void setInternalVersionNumber(Integer internalVersionNumber) { + this.internalVersionNumber = internalVersionNumber; + } + + public List<Integer> getUserIds() { + return userIds; + } + + public void setUserIds(List<Integer> userIds) { + this.userIds = userIds; + } + + public String getVersionNumber() { + return versionNumber; + } + + public void setVersionNumber(String versionNumber) { + this.versionNumber = versionNumber; + } + + public String getVersionStatus() { + return versionStatus; + } + + public void setVersionStatus(String versionStatus) { + this.versionStatus = versionStatus; + } + + public Byte getIsRemote() { + return isRemote; + } + + public void setIsRemote(Byte isRemote) { + this.isRemote = isRemote; + } + + public Byte getIsReviewed() { + return isReviewed; + } + + public void setIsReviewed(Byte isReviewed) { + this.isReviewed = isReviewed; + } + + public Integer getStatusId() { + return statusId; + } + + public void setStatusId(Integer statusId) { + this.statusId = statusId; + } + + public Date getDateCreated() { + return dateCreated; + } + + public void setDateCreated(Date dateCreated) { + this.dateCreated = dateCreated; + } + + public Date getDateReleased() { + return dateReleased; + } + + public void setDateReleased(Date dateReleased) { + this.dateReleased = dateReleased; + } + + public String getOboFoundryId() { + return oboFoundryId; + } + + public void setOboFoundryId(String oboFoundryId) { + this.oboFoundryId = oboFoundryId; + } + + public Byte getIsManual() { + return isManual; + } + + public void setIsManual(Byte isManual) { + this.isManual = isManual; + } + + public String getDisplayLabel() { + return displayLabel; + } + + public void setDisplayLabel(String displayLabel) { + this.displayLabel = displayLabel; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getAbbreviation() { + return abbreviation; + } + + public void setAbbreviation(String abbreviation) { + this.abbreviation = abbreviation; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getContactName() { + return contactName; + } + + public void setContactName(String contactName) { + this.contactName = contactName; + } + + public String getContactEmail() { + return contactEmail; + } + + public void setContactEmail(String contactEmail) { + this.contactEmail = contactEmail; + } + + public String getHomepage() { + return homepage; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } + + public String getDocumentation() { + return documentation; + } + + public void setDocumentation(String documentation) { + this.documentation = documentation; + } + + public String getPublication() { + return publication; + } + + public void setPublication(String publication) { + this.publication = publication; + } + + public String getUrn() { + return urn; + } + + public void setUrn(String urn) { + this.urn = urn; + } + + public String getCodingScheme() { + return codingScheme; + } + + public void setCodingScheme(String codingScheme) { + this.codingScheme = codingScheme; + } + + public String getTargetTerminologies() { + return targetTerminologies; + } + + public void setTargetTerminologies(String targetTerminologies) { + this.targetTerminologies = targetTerminologies; + } + + public Byte getIsFlat() { + return isFlat; + } + + public void setIsFlat(Byte isFlat) { + this.isFlat = isFlat; + } + + public Byte getIsFoundry() { + return isFoundry; + } + + public void setIsFoundry(Byte isFoundry) { + this.isFoundry = isFoundry; + } + + public Byte getIsMetadataOnly() { + return isMetadataOnly; + } + + public void setIsMetadataOnly(Byte isMetadataOnly) { + this.isMetadataOnly = isMetadataOnly; + } + + public String getSynonymSlot() { + return synonymSlot; + } + + public void setSynonymSlot(String synonymSlot) { + this.synonymSlot = synonymSlot; + } + + public String getPreferredNameSlot() { + return preferredNameSlot; + } + + public void setPreferredNameSlot(String preferredNameSlot) { + this.preferredNameSlot = preferredNameSlot; + } + + public String getDocumentationSlot() { + return documentationSlot; + } + + public void setDocumentationSlot(String documentationSlot) { + this.documentationSlot = documentationSlot; + } + + public String getAuthorSlot() { + return authorSlot; + } + + public void setAuthorSlot(String authorSlot) { + this.authorSlot = authorSlot; + } + + public String getSlotWithUniqueValue() { + return slotWithUniqueValue; + } + + public void setSlotWithUniqueValue(String slotWithUniqueValue) { + this.slotWithUniqueValue = slotWithUniqueValue; + } + + public Integer getPreferredMaximumSubclassLimit() { + return preferredMaximumSubclassLimit; + } + + public void setPreferredMaximumSubclassLimit(Integer preferredMaximumSubclassLimit) { + this.preferredMaximumSubclassLimit = preferredMaximumSubclassLimit; + } + + public boolean isView() { + return isView; + } + + public void setView(boolean isView) { + this.isView = isView; + } + + public List<Integer> getCategoryIds() { + return categoryIds; + } + + public void setCategoryIds(List<Integer> categoryIds) { + this.categoryIds = categoryIds; + } + + public List<Integer> getGroupIds() { + return groupIds; + } + + public void setGroupIds(List<Integer> groupIds) { + this.groupIds = groupIds; + } + + public List<String> getFilenames() { + return filenames; + } + + public void setFilenames(List<String> filenames) { + this.filenames = filenames; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public List<Integer> getHasViews() { + return hasViews; + } + + public void setHasViews(List<Integer> hasViews) { + this.hasViews = hasViews; + } + + public List<Integer> getViewOnOntologyVersionId() { + return viewOnOntologyVersionId; + } + + public void setViewOnOntologyVersionId(List<Integer> viewOnOntologyVersionId) { + this.viewOnOntologyVersionId = viewOnOntologyVersionId; + } + + public String getViewDefinition() { + return viewDefinition; + } + + public void setViewDefinition(String viewDefinition) { + this.viewDefinition = viewDefinition; + } + + public String getViewDefinitionLanguage() { + return viewDefinitionLanguage; + } + + public void setViewDefinitionLanguage(String viewDefinitionLanguage) { + this.viewDefinitionLanguage = viewDefinitionLanguage; + } + + public String getViewGenerationEngine() { + return viewGenerationEngine; + } + + public void setViewGenerationEngine(String viewGenerationEngine) { + this.viewGenerationEngine = viewGenerationEngine; + } + + public static String getDefaultPreferredNameSlot() { + return DEFAULT_PREFERRED_NAME_SLOT; + } + + public static String getDefaultDefinitionSlot() { + return DEFAULT_DEFINITION_SLOT; + } + + public static String getDefaultAuthorSlot() { + return DEFAULT_AUTHOR_SLOT; + } + + public String getDownloadLocation() { + return downloadLocation; + } + + public void setDownloadLocation(String downloadLocation) { + this.downloadLocation = downloadLocation; + } + + /** + * @return the userAcl + */ + public List<UserEntry> getUserAcl() { + return userAcl; + } + + /** + * @param userAcl + * the userAcl to set + */ + public void setUserAcl(List<UserEntry> userAcl) { + this.userAcl = userAcl; + } + + public String getViewingRestriction() { + return viewingRestriction; + } + + public void setViewingRestriction(String viewingRestriction) { + this.viewingRestriction = viewingRestriction; + } + + public String getObsoleteParent() { + return obsoleteParent; + } + + public void setObsoleteParent(String obsoleteParent) { + this.obsoleteParent = obsoleteParent; + } + + public String getNaturalLanguage() { + return naturalLanguage; + } + + public void setNaturalLanguage(String naturalLanguage) { + this.naturalLanguage = naturalLanguage; + } + + public String getObsoleteProperty() { + return obsoleteProperty; + } + + public void setObsoleteProperty(String obsoleteProperty) { + this.obsoleteProperty = obsoleteProperty; + } + + public String getLicenseInformation() { + return licenseInformation; + } + + public void setLicenseInformation(String licenseInformation) { + this.licenseInformation = licenseInformation; + } + + @Override + public int compareTo(OntologyBean o) { + return this.displayLabel.compareTo(o.getDisplayLabel()); + } + +} Added: trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Success.java =================================================================== --- trunk/components-core/src/main/java/org/dllearner/kb/repository/bioportal/Success.java (rev 0) +++ trunk/components-core/src/main/java/org/dllearner/kb/repository/biopo... [truncated message content] |