Skip to content

Commit

Permalink
Merge pull request #590 from dgarijo/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dgarijo authored Jun 1, 2023
2 parents 7d125bd + c1fbdeb commit eea5c71
Show file tree
Hide file tree
Showing 20 changed files with 378 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
38 changes: 8 additions & 30 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>es.oeg</groupId>
<artifactId>widoco</artifactId>
<packaging>jar</packaging>
<version>1.4.17</version>
<version>1.4.19</version>
<name>Widoco</name>

<properties>
Expand All @@ -16,6 +16,13 @@

<dependencies>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.9.0</version>
</dependency>


<dependency>
<groupId>com.github.VisualDataWeb</groupId>
<artifactId>OWL2VOWL</artifactId>
Expand Down Expand Up @@ -131,35 +138,6 @@
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>6.0.1</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>list</goal>
</goals>
</execution>
</executions>
<configuration>
<outputFile>pom.lock</outputFile>
</configuration>
</plugin>


</plugins>

Expand Down
52 changes: 35 additions & 17 deletions src/main/java/oops/OOPSevaluation.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<OOPSRequest><OntologyUrl>";
request += "</OntologyUrl><OntologyContent>";
if (content != null && !"".equals(content)) {
request += "<![CDATA[ " + content + " ]]>";
if (ontologyContent != null && !"".equals(ontologyContent)) {
request += "<![CDATA[ " + ontologyContent + " ]]>";
}
request += "</OntologyContent>" + "<Pitfalls></Pitfalls>" + "<OutputFormat>RDF/XML</OutputFormat>"
+ "</OOPSRequest>";
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");
Expand All @@ -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");
}

}


/**
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/widoco/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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
Expand Down Expand Up @@ -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<>();
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/widoco/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -651,15 +651,18 @@ public static String getIndexDocument(String resourcesFolderName, Configuration
/* Style selection */
if (c.isUseW3CStyle()) {
document += " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
+ "/primer.css\" media=\"screen\" /> " + " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
+ "/rec.css\" media=\"screen\" /> " + " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
+ "/extra.css\" media=\"screen\" /> " + " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
+ "/owl.css\" media=\"screen\" /> ";
+ "/primer.css\" media=\"screen\" /> \n" +
" <link rel=\"stylesheet\" href=\"" + resourcesFolderName
+ "/rec.css\" media=\"screen\" /> \n" + " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
+ "/extra.css\" media=\"screen\" /> \n" + " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
+ "/owl.css\" media=\"screen\" /> \n";

} else {
document += " <link rel=\"stylesheet\" href=\"" + resourcesFolderName + "/yeti.css\" media=\"screen\" /> "
+ " <link rel=\"stylesheet\" href=\"" + resourcesFolderName + "/site.css\" media=\"screen\" />";
document += " <link rel=\"stylesheet\" href=\"" + resourcesFolderName + "/yeti.css\" media=\"screen\" /> \n"
+ " <link rel=\"stylesheet\" href=\"" + resourcesFolderName + "/site.css\" media=\"screen\" />\n";
}
// add a favicon (rdf logo)
document += "<link rel=\"icon\" type=\"image/png\" href=\"" + resourcesFolderName + "/rdf.icon\"/>";

// add a title to the document
if (c.getMainOntology().getTitle() != null && !"".equals(c.getMainOntology().getTitle()))
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/widoco/CreateOOPSEvalInThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/widoco/CreateResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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",
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/widoco/gui/GuiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
Binary file modified src/main/resources/lode.zip
Binary file not shown.
1 change: 1 addition & 0 deletions src/main/resources/lode/cs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@
<deprecated>Je zastaralý</deprecated>
<domainIncludes>domain includes</domainIncludes>
<rangeIncludes>range includes</rangeIncludes>
<usesRule>uses rule</usesRule>
</labels>
1 change: 1 addition & 0 deletions src/main/resources/lode/de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@
<reengineeredFrom>weiterentwicklet auf Basis von</reengineeredFrom>
<relatedCPs>ähnliche Inhaltsmuster</relatedCPs>
<scenarios>Szenarien</scenarios>
<usesRule>verwendet die Regel</usesRule>
</labels>
1 change: 1 addition & 0 deletions src/main/resources/lode/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@
<deprecated>Is deprecated</deprecated>
<domainIncludes>domain includes</domainIncludes>
<rangeIncludes>range includes</rangeIncludes>
<usesRule>uses rule</usesRule>
</labels>
1 change: 1 addition & 0 deletions src/main/resources/lode/es.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@
<deprecated>Depecreado</deprecated>
<domainIncludes>el dominio incluye</domainIncludes>
<rangeIncludes>el rango incluye</rangeIncludes>
<usesRule>utiliza regla</usesRule>
</labels>
Loading

0 comments on commit eea5c71

Please sign in to comment.