diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e25152..cebc48f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: # https://github.com/docker/metadata-action (lower cases image name, etc.) - name: Extract Docker metadata id: meta - uses: docker/metadata-action@v4.3.0 + uses: docker/metadata-action@v4.4.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push diff --git a/README.md b/README.md index 920ebd9..76da114 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ WIDOCO helps you to publish and create an enriched and customized documentation **Author**: Daniel Garijo Verdejo (@dgarijo) -**Contributors**: María Poveda, Idafen Santana, Almudena Ruiz, Miguel Angel García, Oscar Corcho, Daniel Vila, Sergio Barrio, Martin Scharm, Maxime Lefrancois, Alfredo Serafini, @kartgk, Pat Mc Bennett, Christophe Camel, Jacobus Geluk, Martin Scharm, @rpietzsch, Jonathan Leitschuh, Jodi Schneider, Giacomo Lanza, Alejandra Gonzalez-Beltran, Mario Scrocca, Miguel Angel García, Flores Bakker, @JohnnyMoonlight and René Fritze. +**Contributors**: María Poveda, Idafen Santana, Almudena Ruiz, Miguel Angel García, Oscar Corcho, Daniel Vila, Sergio Barrio, Martin Scharm, Maxime Lefrancois, Alfredo Serafini, @kartgk, Pat Mc Bennett, Christophe Camel, Jacobus Geluk, Martin Scharm, @rpietzsch, Jonathan Leitschuh, Jodi Schneider, Giacomo Lanza, Alejandra Gonzalez-Beltran, Mario Scrocca, Miguel Angel García, Flores Bakker, @JohnnyMoonlight, René Fritze, @telecsur, Jan Vlug, Han Kruiger, Johannes Theissen-Lipp and Roberto Polli. **Citing WIDOCO**: If you used WIDOCO in your work, please cite the ISWC 2017 paper: https://iswc2017.semanticweb.org/paper-138 @@ -75,7 +75,7 @@ Examples of the features of WIDOCO can be seen on [the gallery](https://dgarijo. A tutorial explaining the main features of the GUI can be found [here](https://dgarijo.github.io/Widoco/doc/tutorial/) ## Metadata usage -To see how WIDOCO recognizes metadata annotations in your ontology to create the documentation files, see [the Widoco metadata documentation](doc/metadataGuide/guide.md). To learn which metadata properties we recommend adding to your ontology for producing a nice-looking documentation, have a look at our [best practices guide](https://dgarijo.github.io/Widoco/doc/bestPractices/index-en.html). +To see how WIDOCO recognizes metadata annotations in your ontology to create the documentation files, see [the Widoco metadata documentation](doc/metadataGuide/guide.md). To learn which metadata properties we recommend adding to your ontology for producing a nice-looking documentation, have a look at our [best practices guide](doc/bestPractices/index-en.html). ## How to use WIDOCO @@ -164,6 +164,8 @@ docker run -ti --rm \ `--help`: Shows a help message and exits. +`--version`: Shows the version of WIDOCO. + ## How can I make WIDOCO automatically recognize my vocabulary annotations? There are two alternative ways for making WIDOCO get your vocabulary metadata annotations and use them automatically to document the ontology. diff --git a/pom.xml b/pom.xml index 71fd8f3..6ef7be8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ es.oeg widoco jar - 1.4.17 + 1.4.19 Widoco @@ -16,6 +16,13 @@ + + org.apache.maven + maven-model + 3.9.0 + + + com.github.VisualDataWeb OWL2VOWL @@ -131,35 +138,6 @@ 11 - - org.owasp - dependency-check-maven - 6.0.1 - - - - check - - - - - - org.apache.maven.plugins - maven-dependency-plugin - 3.2.0 - - - validate - - list - - - - - pom.lock - - - diff --git a/src/main/java/oops/OOPSevaluation.java b/src/main/java/oops/OOPSevaluation.java index b3aa2cc..fad0073 100644 --- a/src/main/java/oops/OOPSevaluation.java +++ b/src/main/java/oops/OOPSevaluation.java @@ -15,9 +15,7 @@ */ package oops; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStreamWriter; +import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; @@ -57,21 +55,26 @@ public class OOPSevaluation { public boolean error = false; private OWLOntology model = null; private int pitfallNumber; - - - public OOPSevaluation(String content) throws IOException { + + + /** + * Main constructor: given an ontology file, a request will be issue to the OOPS! server + * @param ontologyContent + * @throws IOException + */ + public OOPSevaluation(String ontologyContent) throws IOException { //always query by content pitfallNumber = 0; String request = "" + ""; request += ""; - if (content != null && !"".equals(content)) { - request += ""; + if (ontologyContent != null && !"".equals(ontologyContent)) { + request += ""; } request += "" + "" + "RDF/XML" + ""; String uri = Constants.OOPS_SERVICE_URL; URL url = new URL(uri); - System.out.println(request); + //System.out.println(request); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setConnectTimeout(Constants.OOPS_TIME_OUT); connection.setRequestMethod("POST"); @@ -82,19 +85,34 @@ public OOPSevaluation(String content) throws IOException { wr.write(request); wr.flush(); InputStream in = (InputStream) connection.getInputStream(); - try{ - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - model = manager.loadOntologyFromOntologyDocument(in); - OWLClass pitfall = model.getOWLOntologyManager().getOWLDataFactory().getOWLClass(Constants.OOPS_NS + "pitfall"); - this.pitfallNumber = EntitySearcher.getIndividuals(pitfall, model).collect(Collectors.toSet()).size(); - }catch(OWLOntologyCreationException e){ - logger.warn("Could not extract the number of pitfalls from response"); - } + initializeEvaluation(in); in.close(); wr.close(); connection.disconnect(); } + + /** + * Auxiliary constructor in case the response from OOPS! is downloaded elsewhere + * @param OOPSResponse + * @throws IOException + */ + public OOPSevaluation(InputStream OOPSResponse){ + initializeEvaluation(OOPSResponse); + } + + + private void initializeEvaluation(InputStream OOPSResponse){ + try{ + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + model = manager.loadOntologyFromOntologyDocument(OOPSResponse); + OWLClass pitfall = model.getOWLOntologyManager().getOWLDataFactory().getOWLClass(Constants.OOPS_NS + "pitfall"); + this.pitfallNumber = EntitySearcher.getIndividuals(pitfall, model).collect(Collectors.toSet()).size(); + }catch(OWLOntologyCreationException e){ + logger.warn("Could not extract the number of pitfalls from response"); + } + + } /** diff --git a/src/main/java/widoco/Configuration.java b/src/main/java/widoco/Configuration.java index db50573..442943c 100644 --- a/src/main/java/widoco/Configuration.java +++ b/src/main/java/widoco/Configuration.java @@ -210,7 +210,7 @@ private void initializeOntology() { mainOntologyMetadata.setLicense(l); mainOntologyMetadata.setSerializations(new HashMap<>()); // add default serializations: rdf/xml, n3, turtle and json-ld - mainOntologyMetadata.addSerialization("RDF/XML", "ontology.rdf"); + mainOntologyMetadata.addSerialization("RDF/XML", "ontology.owl"); mainOntologyMetadata.addSerialization("TTL", "ontology.ttl"); mainOntologyMetadata.addSerialization("N-Triples", "ontology.nt"); mainOntologyMetadata.addSerialization("JSON-LD", "ontology.jsonld"); @@ -226,7 +226,6 @@ private void initializeOntology() { } private void loadPropertyFile(String path) throws IOException { - // try { try { initializeOntology(); // this forces the property file to be in UTF 8 instead of the ISO @@ -438,21 +437,21 @@ public void loadPropertiesFromOntology(OWLOntology o) { } // default citation if none is given if (mainOntologyMetadata.getCiteAs() == null || mainOntologyMetadata.getCiteAs().isEmpty()) { - String cite = ""; + StringBuilder cite = new StringBuilder(); for (Agent a : mainOntologyMetadata.getCreators()) { - cite += a.getName() + ", "; + cite.append(a.getName()).append(", "); } if (cite.length() > 1) { // remove the last "," - cite = cite.substring(0, cite.length() - 2); - cite += "."; + cite = new StringBuilder(cite.substring(0, cite.length() - 2)); + cite.append("."); } - cite += appendDetails(mainOntologyMetadata.getTitle(), " ", true); - cite += appendDetails(mainOntologyMetadata.getRevision(), " Revision: ", true); - cite += appendDetails(mainOntologyMetadata.getThisVersion(), " Retrieved from: ", false); + cite.append(appendDetails(mainOntologyMetadata.getTitle(), " ", true)); + cite.append(appendDetails(mainOntologyMetadata.getRevision(), " Revision: ", true)); + cite.append(appendDetails(mainOntologyMetadata.getThisVersion(), " Retrieved from: ", false)); - mainOntologyMetadata.setCiteAs(cite); + mainOntologyMetadata.setCiteAs(cite.toString()); } //load all namespaces in the ontology document. this.namespaceDeclarations = new HashMap<>(); diff --git a/src/main/java/widoco/Constants.java b/src/main/java/widoco/Constants.java index 7567010..5ad88c3 100644 --- a/src/main/java/widoco/Constants.java +++ b/src/main/java/widoco/Constants.java @@ -156,8 +156,8 @@ public class Constants { public static final String PROP_VCARD_EMAIL_OLD = NS_VCARD_OLD + "EMAIL"; public static final String PROP_FOAF_NAME = NS_FOAF + "name"; - public static final String PROP_FOAF_GIVEN_NAME = NS_FOAF + "givenName"; - public static final String PROP_FOAF_FAMILY_NAME = NS_FOAF + "familyName"; + public static final String PROP_FOAF_GIVEN_NAME = NS_FOAF + "givenname"; + public static final String PROP_FOAF_FAMILY_NAME = NS_FOAF + "family_name"; public static final String PROP_FOAF_MBOX = NS_FOAF + "mbox"; public static final String PROP_FOAF_HOME_PAGE = NS_FOAF + "homepage"; public static final String PROP_FOAF_IMAGE = NS_FOAF + "img"; @@ -651,15 +651,18 @@ public static String getIndexDocument(String resourcesFolderName, Configuration /* Style selection */ if (c.isUseW3CStyle()) { document += " " + " " + " " + " "; + + "/primer.css\" media=\"screen\" /> \n" + + " \n" + " \n" + " \n"; } else { - document += " " - + " "; + document += " \n" + + " \n"; } + // add a favicon (rdf logo) + document += ""; // add a title to the document if (c.getMainOntology().getTitle() != null && !"".equals(c.getMainOntology().getTitle())) diff --git a/src/main/java/widoco/CreateOOPSEvalInThread.java b/src/main/java/widoco/CreateOOPSEvalInThread.java index ffddf8e..261d35e 100644 --- a/src/main/java/widoco/CreateOOPSEvalInThread.java +++ b/src/main/java/widoco/CreateOOPSEvalInThread.java @@ -65,7 +65,7 @@ public void run() { if (!c.getMainOntology().isHashOntology()) { ontologyXMLPath += File.separator + "doc"; } - ontologyXMLPath += File.separator + "ontology.rdf"; + ontologyXMLPath += File.separator + "ontology.owl"; // read file String content = null; diff --git a/src/main/java/widoco/CreateResources.java b/src/main/java/widoco/CreateResources.java index e4da0ea..e996466 100644 --- a/src/main/java/widoco/CreateResources.java +++ b/src/main/java/widoco/CreateResources.java @@ -125,7 +125,7 @@ public static void generateDocumentation(String outFolder, Configuration c, File // serialize the model in different serializations. OWLOntologyManager om = c.getMainOntology().getOWLAPIOntologyManager(); OWLOntology o = c.getMainOntology().getOWLAPIModel(); - WidocoUtils.writeModel(om, o, new RDFXMLDocumentFormat(), folderOut + File.separator + "ontology.rdf"); + WidocoUtils.writeModel(om, o, new RDFXMLDocumentFormat(), folderOut + File.separator + "ontology.owl"); WidocoUtils.writeModel(om, o, new TurtleDocumentFormat(), folderOut + File.separator + "ontology.ttl"); WidocoUtils.writeModel(om, o, new NTriplesDocumentFormat(), folderOut + File.separator + "ontology.nt"); WidocoUtils.writeModel(om, o, new RDFJsonLDDocumentFormat(), folderOut + File.separator + "ontology.jsonld"); @@ -442,6 +442,9 @@ private static void createFolderStructure(String s, Configuration c, Properties new File(resources.getAbsolutePath() + File.separator + "jquery.js")); WidocoUtils.copyLocalResource("/lode/marked.min.js", new File(resources.getAbsolutePath() + File.separator + "marked.min.js")); + // icon + WidocoUtils.copyLocalResource("/widoco/images/rdf.icon", + new File(resources.getAbsolutePath() + File.separator + "rdf.icon")); // copy css if (c.isUseW3CStyle()) { WidocoUtils.copyLocalResource("/lode/lodeprimer.css", diff --git a/src/main/java/widoco/gui/GuiController.java b/src/main/java/widoco/gui/GuiController.java index 7319b26..8b9fe29 100644 --- a/src/main/java/widoco/gui/GuiController.java +++ b/src/main/java/widoco/gui/GuiController.java @@ -17,7 +17,9 @@ package widoco.gui; import java.awt.Desktop; +import java.io.FileReader; import java.io.IOException; +import java.io.InputStream; import java.net.URI; import java.util.Date; import java.util.Properties; @@ -35,6 +37,9 @@ import widoco.LoadOntologyInThread; import widoco.WidocoUtils; +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; + /** * * @author Daniel Garijo @@ -77,6 +82,23 @@ public GuiController() { public GuiController(String[] args) { logger.info("\n\n--WIzard for DOCumenting Ontologies (WIDOCO).\n https://w3id.org/widoco/\n"); + String version = ""; + try { + MavenXpp3Reader reader = new MavenXpp3Reader(); + Model model = reader.read(new FileReader("pom.xml")); + version = model.getVersion(); + } catch (Exception e) { + try{ + InputStream inputStream = GuiController.class.getResourceAsStream("/META-INF/maven/es.oeg/widoco/pom.xml"); + MavenXpp3Reader reader = new MavenXpp3Reader(); + Model model = reader.read(inputStream); + version = model.getVersion(); + }catch (Exception e2) { + logger.error("Could not read the project version from pom"); + } + + } + // get the arguments String outFolder = "myDocumentation" + (new Date().getTime()), ontology = "", rb = null, configOutFile = null; boolean isFromFile = false, oops = false, rewriteAll = false, getOntoMetadata = true, useW3Cstyle = true, @@ -176,6 +198,11 @@ public GuiController(String[] args) { case "--help": System.out.println(Constants.HELP_TEXT); return; + case "--version": + if (!version.isEmpty()) { + System.out.println("Version: "+version); + } + return; default: System.out.println("Command" + s + " not recognized."); System.out.println(Constants.HELP_TEXT); diff --git a/src/main/resources/lode.zip b/src/main/resources/lode.zip index be6aa22..59b3729 100644 Binary files a/src/main/resources/lode.zip and b/src/main/resources/lode.zip differ diff --git a/src/main/resources/lode/cs.xml b/src/main/resources/lode/cs.xml index 0002045..4e3eda9 100644 --- a/src/main/resources/lode/cs.xml +++ b/src/main/resources/lode/cs.xml @@ -85,4 +85,5 @@ Je zastaralý domain includes range includes + uses rule diff --git a/src/main/resources/lode/de.xml b/src/main/resources/lode/de.xml index 30ded1c..c10cdd4 100644 --- a/src/main/resources/lode/de.xml +++ b/src/main/resources/lode/de.xml @@ -86,4 +86,5 @@ weiterentwicklet auf Basis von ähnliche Inhaltsmuster Szenarien + verwendet die Regel \ No newline at end of file diff --git a/src/main/resources/lode/en.xml b/src/main/resources/lode/en.xml index 9a41ea3..84bd8bd 100644 --- a/src/main/resources/lode/en.xml +++ b/src/main/resources/lode/en.xml @@ -85,4 +85,5 @@ Is deprecated domain includes range includes + uses rule \ No newline at end of file diff --git a/src/main/resources/lode/es.xml b/src/main/resources/lode/es.xml index 6cf658e..c749609 100644 --- a/src/main/resources/lode/es.xml +++ b/src/main/resources/lode/es.xml @@ -85,4 +85,5 @@ Depecreado el dominio incluye el rango incluye + utiliza regla \ No newline at end of file diff --git a/src/main/resources/lode/extraction.xsl b/src/main/resources/lode/extraction.xsl index 498f747..3ac4c2d 100644 --- a/src/main/resources/lode/extraction.xsl +++ b/src/main/resources/lode/extraction.xsl @@ -38,6 +38,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. xmlns:obo="http://purl.obolibrary.org/obo/" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:sw="http://www.w3.org/2003/06/sw-vocab-status/ns#" + xmlns:extra="https://w3id.org/extra#" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oxygenxml.com/ns/doc/xsl http://www.oxygenxml.com/ns/doc/xsl "> @@ -987,6 +988,7 @@ http://www.oxygenxml.com/ns/doc/xsl "> + @@ -2211,4 +2213,29 @@ http://www.oxygenxml.com/ns/doc/xsl "> + + + + +
+
+ +
+ +
+ + + + + + + + + + +
+
+
+
+
diff --git a/src/main/resources/lode/fr.xml b/src/main/resources/lode/fr.xml index ecdf1db..58403b7 100644 --- a/src/main/resources/lode/fr.xml +++ b/src/main/resources/lode/fr.xml @@ -86,4 +86,5 @@ Obsolète domaine comprend cible comprend + utilise la règle \ No newline at end of file diff --git a/src/main/resources/lode/it.xml b/src/main/resources/lode/it.xml index 7432b9b..ad80bc0 100644 --- a/src/main/resources/lode/it.xml +++ b/src/main/resources/lode/it.xml @@ -85,4 +85,5 @@ Deprecato dominio include codominio include + usa la regola diff --git a/src/main/resources/lode/nl.xml b/src/main/resources/lode/nl.xml index 9e0984f..bc8d96c 100644 --- a/src/main/resources/lode/nl.xml +++ b/src/main/resources/lode/nl.xml @@ -85,4 +85,5 @@ Is vervallen domein bevat bereik bevat + gebruikt regel \ No newline at end of file diff --git a/src/main/resources/widoco/images/rdf.icon b/src/main/resources/widoco/images/rdf.icon new file mode 100644 index 0000000..d54310f Binary files /dev/null and b/src/main/resources/widoco/images/rdf.icon differ diff --git a/src/test/java/oops/OOPSevaluationTest.java b/src/test/java/oops/OOPSevaluationTest.java index 97acdc9..345010b 100644 --- a/src/test/java/oops/OOPSevaluationTest.java +++ b/src/test/java/oops/OOPSevaluationTest.java @@ -1,11 +1,22 @@ /* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. + * Copyright 2012-2022 Ontology Engineering Group, Universidad Politecnica de Madrid, Spain + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package oops; import java.io.BufferedReader; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; import org.junit.Test; @@ -21,62 +32,248 @@ public OOPSevaluationTest() { } /** - * Test of printEvaluation method, of class OOPSevaluation. + * Test of printEvaluation method, from OOPSevaluation. The method copies the response from the server in case + * it's down */ - @Test //(Commented out because OOPS! WS seems to be down + @Test public void testPrintEvaluation() { + String aloResponse = " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 1\n" + + " Important\n" + + " The ontology lacks disjoint axioms between classes or between properties that should be defined as disjoint. This pitfall is related with the guidelines provided in [6], [2] and [7].\t\n" + + " Missing disjointness\n" + + " P10\n" + + " \n" + + " \n" + + " \n" + + " Minor\n" + + " http://idi.fundacionctic.org/cruzar/turismo#Alojamiento\n" + + " http://schema.org/LodgingBusiness\n" + + " http://geonames.org/ontology#Feature\n" + + " 3\n" + + " Ontology elements (classes, object properties and datatype properties) are created isolated, with no relation to the rest of the ontology.\t\n" + + " Creating unconnected ontology elements\n" + + " P04\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " http://geonames.org/ontology#featureClass\n" + + " http://geonames.org/ontology#featureCode\n" + + " http://purl.org/dc/terms/type\n" + + " http://vocab.linkeddata.es/datosabiertos/def/turismo/alojamiento#categoria\n" + + " \n" + + " \n" + + " \n" + + " 11\n" + + " http://geonames.org/ontology#featureClass\n" + + " http://www.w3.org/2004/02/skos/core#Concept\n" + + " P08\n" + + " Minor\n" + + " http://schema.org/Hostel\n" + + " http://schema.org/Motel\n" + + " http://schema.org/Hotel\n" + + " http://geonames.org/ontology#featureCode\n" + + " http://geonames.org/ontology#Feature\n" + + " This pitfall consists in creating an ontology element and failing to provide human readable annotations attached to it. Consequently, ontology elements lack annotation properties that label them (e.g. rdfs:label, lemon:LexicalEntry, skos:prefLabel or skos:altLabel) or that define them (e.g. rdfs:comment or dc:description). This pitfall is related to the guidelines provided in [5].\t\n" + + " http://idi.fundacionctic.org/cruzar/turismo#Alojamiento\n" + + " http://schema.org/LodgingBusiness\n" + + " http://schema.org/BedAndBreakfast\n" + + " http://purl.org/dc/terms/type\n" + + " Missing annotations\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " Minor\n" + + " \n" + + " 4\n" + + " This pitfall appears when any relationship (except for those that are defined as symmetric properties using owl:SymmetricProperty) does not have an inverse relationship (owl:inverseOf) defined within the ontology.\t\n" + + " Inverse relationships not explicitly declared\n" + + " P13\n" + + " \n" + + " \n" + + " \n" + + " P20\n" + + " http://vocab.linkeddata.es/datosabiertos/def/turismo/alojamiento#Albergue\n" + + " 4\n" + + " The contents of some annotation properties are swapped or misused. This pitfall might affect annotation properties related to natural language information (for example, annotations for naming such as rdfs:label or for providing descriptions such as rdfs:comment). Other types of annotation could also be affected as temporal, versioning information, among others.\t\n" + + " \n" + + " http://vocab.linkeddata.es/datosabiertos/def/turismo/alojamiento#Apartahotel\n" + + " Misusing ontology annotations\n" + + " http://vocab.linkeddata.es/datosabiertos/def/turismo/alojamiento#Hotel\n" + + " Minor\n" + + " http://vocab.linkeddata.es/datosabiertos/def/turismo/alojamiento#Hostal\n" + + " \n" + + " \n" + + " Important\n" + + " http://purl.org/dc/terms/type\n" + + " http://geonames.org/ontology#featureCode\n" + + " http://geonames.org/ontology#featureClass\n" + + " 3\n" + + " Object and/or datatype properties without domain or range (or none of them) are included in the ontology. \t\n" + + " Missing domain or range in properties\n" + + " P11\n" + + " \n" + + " \n" + + ""; try{ - System.out.println("printEvaluation with alo"); - String content = null; - BufferedReader br = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("/alo.owl"))); - try { - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - - while (line != null) { - sb.append(line); - sb.append(System.lineSeparator()); - line = br.readLine(); - } - content = sb.toString(); - } finally { - br.close(); - } // The ontology has 6 pitfalls - OOPSevaluation instance = new OOPSevaluation(content); - instance.printEvaluation(); - assertEquals(6, instance.getPitfallNumber()); - }catch(IOException e){ + OOPSevaluation instance = new OOPSevaluation(new ByteArrayInputStream(aloResponse.getBytes())); + //instance.printEvaluation(); + assertEquals(6, instance.getPitfallNumber()); + }catch(Exception e){ fail("Error in test "+e.getMessage()); } } - + + /** + * Test of printEvaluation method, from OOPSevaluation. The method copies the response from the server in case + * it's down + */ @Test public void testPrintEvaluation2() { + String oopsResponse = " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " http://purl.org/net/p-plan#isPrecededBy\n" + + " http://purl.org/net/p-plan#correspondsToVariable\n" + + " http://purl.org/net/p-plan#isDecomposedAsPlan\n" + + " http://purl.org/net/p-plan#isVariableOfPlan\n" + + " http://purl.org/net/p-plan#isSubPlanOfPlan\n" + + " http://purl.org/net/p-plan#isStepOfPlan\n" + + " http://purl.org/net/p-plan#correspondsToStep\n" + + " http://www.w3.org/ns/prov#wasDerivedFrom\n" + + " \n" + + " \n" + + " \n" + + " http://www.w3.org/ns/prov#wasGeneratedBy\n" + + " http://www.w3.org/ns/prov#used\n" + + " \n" + + " \n" + + " \n" + + " Minor\n" + + " \n" + + " \n" + + " 10\n" + + " This pitfall appears when any relationship (except for those that are defined as symmetric properties using owl:SymmetricProperty) does not have an inverse relationship (owl:inverseOf) defined within the ontology.\t\n" + + " Inverse relationships not explicitly declared\n" + + " P13\n" + + " \n" + + " \n" + + " \n" + + " 1\n" + + " Important\n" + + " The ontology lacks disjoint axioms between classes or between properties that should be defined as disjoint. This pitfall is related with the guidelines provided in [6], [2] and [7].\t\n" + + " Missing disjointness\n" + + " P10\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " Minor\n" + + " http://www.w3.org/ns/prov#wasDerivedFrom\n" + + " Missing annotations\n" + + " \n" + + " http://www.w3.org/ns/prov#Activity\n" + + " This pitfall consists in creating an ontology element and failing to provide human readable annotations attached to it. Consequently, ontology elements lack annotation properties that label them (e.g. rdfs:label, lemon:LexicalEntry, skos:prefLabel or skos:altLabel) or that define them (e.g. rdfs:comment or dc:description). This pitfall is related to the guidelines provided in [5].\t\n" + + " http://www.w3.org/ns/prov#Plan\n" + + " http://www.w3.org/ns/prov#Bundle\n" + + " http://www.w3.org/ns/prov#used\n" + + " 7\n" + + " http://www.w3.org/ns/prov#wasGeneratedBy\n" + + " http://www.w3.org/ns/prov#Entity\n" + + " P08\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " http://purl.org/net/p-plan#isSubPlanOfPlan\n" + + " http://www.w3.org/ns/prov#wasDerivedFrom\n" + + " 2\n" + + " The domain and range axioms are equal for each of the following object properties. Could they be symmetric or transitive?\n" + + " SUGGESTION: symmetric or transitive object properties.\n" + + " \n" + + " \n" + + ""; try{ - System.out.println("printEvaluation with p-plan"); - String content = null; - BufferedReader br = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("/p-plan.owl"))); - try { - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - - while (line != null) { - sb.append(line); - sb.append(System.lineSeparator()); - line = br.readLine(); - } - content = sb.toString(); - } finally { - br.close(); - } - // The ontology has 6 pitfalls - OOPSevaluation instance = new OOPSevaluation(content); - instance.printEvaluation(); - assertEquals(3, instance.getPitfallNumber()); - }catch(IOException e){ + // The ontology has 3 pitfalls + OOPSevaluation instance = new OOPSevaluation(new ByteArrayInputStream(oopsResponse.getBytes())); + instance.printEvaluation(); + assertEquals(3, instance.getPitfallNumber()); + }catch(Exception e){ fail("Error in test "+e.getMessage()); } } + + /** + * Test of printEvaluation method, from OOPSEvaluation. Commented in case the server is down + */ +// @Test +// public void testPrintEvaluationWebServer() { +// try{ +// System.out.println("printEvaluation with p-plan"); +// String content = null; +// BufferedReader br = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("/p-plan.owl"))); +// try { +// StringBuilder sb = new StringBuilder(); +// String line = br.readLine(); +// +// while (line != null) { +// sb.append(line); +// sb.append(System.lineSeparator()); +// line = br.readLine(); +// } +// content = sb.toString(); +// } finally { +// br.close(); +// } +// // The ontology has 6 pitfalls +// OOPSevaluation instance = new OOPSevaluation(content); +// instance.printEvaluation(); +// assertEquals(3, instance.getPitfallNumber()); +// }catch(Exception e){ +// fail("Error in test "+e.getMessage()); +// } +// } }