Skip to content

Commit eea5c71

Browse files
authored
Merge pull request #590 from dgarijo/develop
Develop
2 parents 7d125bd + c1fbdeb commit eea5c71

File tree

20 files changed

+378
-117
lines changed

20 files changed

+378
-117
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
# https://github.com/docker/metadata-action (lower cases image name, etc.)
5555
- name: Extract Docker metadata
5656
id: meta
57-
uses: docker/metadata-action@v4.3.0
57+
uses: docker/metadata-action@v4.4.0
5858
with:
5959
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
6060
- name: Build and push

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ WIDOCO helps you to publish and create an enriched and customized documentation
77

88
**Author**: Daniel Garijo Verdejo (@dgarijo)
99

10-
**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.
10+
**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.
1111

1212
**Citing WIDOCO**: If you used WIDOCO in your work, please cite the ISWC 2017 paper: https://iswc2017.semanticweb.org/paper-138
1313

@@ -75,7 +75,7 @@ Examples of the features of WIDOCO can be seen on [the gallery](https://dgarijo.
7575
A tutorial explaining the main features of the GUI can be found [here](https://dgarijo.github.io/Widoco/doc/tutorial/)
7676

7777
## Metadata usage
78-
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).
78+
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).
7979

8080
## How to use WIDOCO
8181

@@ -164,6 +164,8 @@ docker run -ti --rm \
164164

165165
`--help`: Shows a help message and exits.
166166

167+
`--version`: Shows the version of WIDOCO.
168+
167169

168170
## How can I make WIDOCO automatically recognize my vocabulary annotations?
169171
There are two alternative ways for making WIDOCO get your vocabulary metadata annotations and use them automatically to document the ontology.

pom.xml

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>es.oeg</groupId>
55
<artifactId>widoco</artifactId>
66
<packaging>jar</packaging>
7-
<version>1.4.17</version>
7+
<version>1.4.19</version>
88
<name>Widoco</name>
99

1010
<properties>
@@ -16,6 +16,13 @@
1616

1717
<dependencies>
1818

19+
<dependency>
20+
<groupId>org.apache.maven</groupId>
21+
<artifactId>maven-model</artifactId>
22+
<version>3.9.0</version>
23+
</dependency>
24+
25+
1926
<dependency>
2027
<groupId>com.github.VisualDataWeb</groupId>
2128
<artifactId>OWL2VOWL</artifactId>
@@ -131,35 +138,6 @@
131138
<target>11</target>
132139
</configuration>
133140
</plugin>
134-
<plugin>
135-
<groupId>org.owasp</groupId>
136-
<artifactId>dependency-check-maven</artifactId>
137-
<version>6.0.1</version>
138-
<executions>
139-
<execution>
140-
<goals>
141-
<goal>check</goal>
142-
</goals>
143-
</execution>
144-
</executions>
145-
</plugin>
146-
<plugin>
147-
<groupId>org.apache.maven.plugins</groupId>
148-
<artifactId>maven-dependency-plugin</artifactId>
149-
<version>3.2.0</version>
150-
<executions>
151-
<execution>
152-
<phase>validate</phase>
153-
<goals>
154-
<goal>list</goal>
155-
</goals>
156-
</execution>
157-
</executions>
158-
<configuration>
159-
<outputFile>pom.lock</outputFile>
160-
</configuration>
161-
</plugin>
162-
163141

164142
</plugins>
165143

src/main/java/oops/OOPSevaluation.java

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
*/
1616
package oops;
1717

18-
import java.io.IOException;
19-
import java.io.InputStream;
20-
import java.io.OutputStreamWriter;
18+
import java.io.*;
2119
import java.net.HttpURLConnection;
2220
import java.net.URL;
2321
import java.util.ArrayList;
@@ -57,21 +55,26 @@ public class OOPSevaluation {
5755
public boolean error = false;
5856
private OWLOntology model = null;
5957
private int pitfallNumber;
60-
61-
62-
public OOPSevaluation(String content) throws IOException {
58+
59+
60+
/**
61+
* Main constructor: given an ontology file, a request will be issue to the OOPS! server
62+
* @param ontologyContent
63+
* @throws IOException
64+
*/
65+
public OOPSevaluation(String ontologyContent) throws IOException {
6366
//always query by content
6467
pitfallNumber = 0;
6568
String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<OOPSRequest><OntologyUrl>";
6669
request += "</OntologyUrl><OntologyContent>";
67-
if (content != null && !"".equals(content)) {
68-
request += "<![CDATA[ " + content + " ]]>";
70+
if (ontologyContent != null && !"".equals(ontologyContent)) {
71+
request += "<![CDATA[ " + ontologyContent + " ]]>";
6972
}
7073
request += "</OntologyContent>" + "<Pitfalls></Pitfalls>" + "<OutputFormat>RDF/XML</OutputFormat>"
7174
+ "</OOPSRequest>";
7275
String uri = Constants.OOPS_SERVICE_URL;
7376
URL url = new URL(uri);
74-
System.out.println(request);
77+
//System.out.println(request);
7578
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
7679
connection.setConnectTimeout(Constants.OOPS_TIME_OUT);
7780
connection.setRequestMethod("POST");
@@ -82,19 +85,34 @@ public OOPSevaluation(String content) throws IOException {
8285
wr.write(request);
8386
wr.flush();
8487
InputStream in = (InputStream) connection.getInputStream();
85-
try{
86-
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
87-
model = manager.loadOntologyFromOntologyDocument(in);
88-
OWLClass pitfall = model.getOWLOntologyManager().getOWLDataFactory().getOWLClass(Constants.OOPS_NS + "pitfall");
89-
this.pitfallNumber = EntitySearcher.getIndividuals(pitfall, model).collect(Collectors.toSet()).size();
90-
}catch(OWLOntologyCreationException e){
91-
logger.warn("Could not extract the number of pitfalls from response");
92-
}
88+
initializeEvaluation(in);
9389
in.close();
9490
wr.close();
9591
connection.disconnect();
9692

9793
}
94+
95+
/**
96+
* Auxiliary constructor in case the response from OOPS! is downloaded elsewhere
97+
* @param OOPSResponse
98+
* @throws IOException
99+
*/
100+
public OOPSevaluation(InputStream OOPSResponse){
101+
initializeEvaluation(OOPSResponse);
102+
}
103+
104+
105+
private void initializeEvaluation(InputStream OOPSResponse){
106+
try{
107+
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
108+
model = manager.loadOntologyFromOntologyDocument(OOPSResponse);
109+
OWLClass pitfall = model.getOWLOntologyManager().getOWLDataFactory().getOWLClass(Constants.OOPS_NS + "pitfall");
110+
this.pitfallNumber = EntitySearcher.getIndividuals(pitfall, model).collect(Collectors.toSet()).size();
111+
}catch(OWLOntologyCreationException e){
112+
logger.warn("Could not extract the number of pitfalls from response");
113+
}
114+
115+
}
98116

99117

100118
/**

src/main/java/widoco/Configuration.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private void initializeOntology() {
210210
mainOntologyMetadata.setLicense(l);
211211
mainOntologyMetadata.setSerializations(new HashMap<>());
212212
// add default serializations: rdf/xml, n3, turtle and json-ld
213-
mainOntologyMetadata.addSerialization("RDF/XML", "ontology.rdf");
213+
mainOntologyMetadata.addSerialization("RDF/XML", "ontology.owl");
214214
mainOntologyMetadata.addSerialization("TTL", "ontology.ttl");
215215
mainOntologyMetadata.addSerialization("N-Triples", "ontology.nt");
216216
mainOntologyMetadata.addSerialization("JSON-LD", "ontology.jsonld");
@@ -226,7 +226,6 @@ private void initializeOntology() {
226226
}
227227

228228
private void loadPropertyFile(String path) throws IOException {
229-
// try {
230229
try {
231230
initializeOntology();
232231
// this forces the property file to be in UTF 8 instead of the ISO
@@ -438,21 +437,21 @@ public void loadPropertiesFromOntology(OWLOntology o) {
438437
}
439438
// default citation if none is given
440439
if (mainOntologyMetadata.getCiteAs() == null || mainOntologyMetadata.getCiteAs().isEmpty()) {
441-
String cite = "";
440+
StringBuilder cite = new StringBuilder();
442441
for (Agent a : mainOntologyMetadata.getCreators()) {
443-
cite += a.getName() + ", ";
442+
cite.append(a.getName()).append(", ");
444443
}
445444
if (cite.length() > 1) {
446445
// remove the last ","
447-
cite = cite.substring(0, cite.length() - 2);
448-
cite += ".";
446+
cite = new StringBuilder(cite.substring(0, cite.length() - 2));
447+
cite.append(".");
449448
}
450449

451-
cite += appendDetails(mainOntologyMetadata.getTitle(), " ", true);
452-
cite += appendDetails(mainOntologyMetadata.getRevision(), " Revision: ", true);
453-
cite += appendDetails(mainOntologyMetadata.getThisVersion(), " Retrieved from: ", false);
450+
cite.append(appendDetails(mainOntologyMetadata.getTitle(), " ", true));
451+
cite.append(appendDetails(mainOntologyMetadata.getRevision(), " Revision: ", true));
452+
cite.append(appendDetails(mainOntologyMetadata.getThisVersion(), " Retrieved from: ", false));
454453

455-
mainOntologyMetadata.setCiteAs(cite);
454+
mainOntologyMetadata.setCiteAs(cite.toString());
456455
}
457456
//load all namespaces in the ontology document.
458457
this.namespaceDeclarations = new HashMap<>();

src/main/java/widoco/Constants.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ public class Constants {
156156
public static final String PROP_VCARD_EMAIL_OLD = NS_VCARD_OLD + "EMAIL";
157157

158158
public static final String PROP_FOAF_NAME = NS_FOAF + "name";
159-
public static final String PROP_FOAF_GIVEN_NAME = NS_FOAF + "givenName";
160-
public static final String PROP_FOAF_FAMILY_NAME = NS_FOAF + "familyName";
159+
public static final String PROP_FOAF_GIVEN_NAME = NS_FOAF + "givenname";
160+
public static final String PROP_FOAF_FAMILY_NAME = NS_FOAF + "family_name";
161161
public static final String PROP_FOAF_MBOX = NS_FOAF + "mbox";
162162
public static final String PROP_FOAF_HOME_PAGE = NS_FOAF + "homepage";
163163
public static final String PROP_FOAF_IMAGE = NS_FOAF + "img";
@@ -651,15 +651,18 @@ public static String getIndexDocument(String resourcesFolderName, Configuration
651651
/* Style selection */
652652
if (c.isUseW3CStyle()) {
653653
document += " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
654-
+ "/primer.css\" media=\"screen\" /> " + " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
655-
+ "/rec.css\" media=\"screen\" /> " + " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
656-
+ "/extra.css\" media=\"screen\" /> " + " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
657-
+ "/owl.css\" media=\"screen\" /> ";
654+
+ "/primer.css\" media=\"screen\" /> \n" +
655+
" <link rel=\"stylesheet\" href=\"" + resourcesFolderName
656+
+ "/rec.css\" media=\"screen\" /> \n" + " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
657+
+ "/extra.css\" media=\"screen\" /> \n" + " <link rel=\"stylesheet\" href=\"" + resourcesFolderName
658+
+ "/owl.css\" media=\"screen\" /> \n";
658659

659660
} else {
660-
document += " <link rel=\"stylesheet\" href=\"" + resourcesFolderName + "/yeti.css\" media=\"screen\" /> "
661-
+ " <link rel=\"stylesheet\" href=\"" + resourcesFolderName + "/site.css\" media=\"screen\" />";
661+
document += " <link rel=\"stylesheet\" href=\"" + resourcesFolderName + "/yeti.css\" media=\"screen\" /> \n"
662+
+ " <link rel=\"stylesheet\" href=\"" + resourcesFolderName + "/site.css\" media=\"screen\" />\n";
662663
}
664+
// add a favicon (rdf logo)
665+
document += "<link rel=\"icon\" type=\"image/png\" href=\"" + resourcesFolderName + "/rdf.icon\"/>";
663666

664667
// add a title to the document
665668
if (c.getMainOntology().getTitle() != null && !"".equals(c.getMainOntology().getTitle()))

src/main/java/widoco/CreateOOPSEvalInThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void run() {
6565
if (!c.getMainOntology().isHashOntology()) {
6666
ontologyXMLPath += File.separator + "doc";
6767
}
68-
ontologyXMLPath += File.separator + "ontology.rdf";
68+
ontologyXMLPath += File.separator + "ontology.owl";
6969

7070
// read file
7171
String content = null;

src/main/java/widoco/CreateResources.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static void generateDocumentation(String outFolder, Configuration c, File
125125
// serialize the model in different serializations.
126126
OWLOntologyManager om = c.getMainOntology().getOWLAPIOntologyManager();
127127
OWLOntology o = c.getMainOntology().getOWLAPIModel();
128-
WidocoUtils.writeModel(om, o, new RDFXMLDocumentFormat(), folderOut + File.separator + "ontology.rdf");
128+
WidocoUtils.writeModel(om, o, new RDFXMLDocumentFormat(), folderOut + File.separator + "ontology.owl");
129129
WidocoUtils.writeModel(om, o, new TurtleDocumentFormat(), folderOut + File.separator + "ontology.ttl");
130130
WidocoUtils.writeModel(om, o, new NTriplesDocumentFormat(), folderOut + File.separator + "ontology.nt");
131131
WidocoUtils.writeModel(om, o, new RDFJsonLDDocumentFormat(), folderOut + File.separator + "ontology.jsonld");
@@ -442,6 +442,9 @@ private static void createFolderStructure(String s, Configuration c, Properties
442442
new File(resources.getAbsolutePath() + File.separator + "jquery.js"));
443443
WidocoUtils.copyLocalResource("/lode/marked.min.js",
444444
new File(resources.getAbsolutePath() + File.separator + "marked.min.js"));
445+
// icon
446+
WidocoUtils.copyLocalResource("/widoco/images/rdf.icon",
447+
new File(resources.getAbsolutePath() + File.separator + "rdf.icon"));
445448
// copy css
446449
if (c.isUseW3CStyle()) {
447450
WidocoUtils.copyLocalResource("/lode/lodeprimer.css",

src/main/java/widoco/gui/GuiController.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
package widoco.gui;
1818

1919
import java.awt.Desktop;
20+
import java.io.FileReader;
2021
import java.io.IOException;
22+
import java.io.InputStream;
2123
import java.net.URI;
2224
import java.util.Date;
2325
import java.util.Properties;
@@ -35,6 +37,9 @@
3537
import widoco.LoadOntologyInThread;
3638
import widoco.WidocoUtils;
3739

40+
import org.apache.maven.model.Model;
41+
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
42+
3843
/**
3944
*
4045
* @author Daniel Garijo
@@ -77,6 +82,23 @@ public GuiController() {
7782
public GuiController(String[] args) {
7883

7984
logger.info("\n\n--WIzard for DOCumenting Ontologies (WIDOCO).\n https://w3id.org/widoco/\n");
85+
String version = "";
86+
try {
87+
MavenXpp3Reader reader = new MavenXpp3Reader();
88+
Model model = reader.read(new FileReader("pom.xml"));
89+
version = model.getVersion();
90+
} catch (Exception e) {
91+
try{
92+
InputStream inputStream = GuiController.class.getResourceAsStream("/META-INF/maven/es.oeg/widoco/pom.xml");
93+
MavenXpp3Reader reader = new MavenXpp3Reader();
94+
Model model = reader.read(inputStream);
95+
version = model.getVersion();
96+
}catch (Exception e2) {
97+
logger.error("Could not read the project version from pom");
98+
}
99+
100+
}
101+
80102
// get the arguments
81103
String outFolder = "myDocumentation" + (new Date().getTime()), ontology = "", rb = null, configOutFile = null;
82104
boolean isFromFile = false, oops = false, rewriteAll = false, getOntoMetadata = true, useW3Cstyle = true,
@@ -176,6 +198,11 @@ public GuiController(String[] args) {
176198
case "--help":
177199
System.out.println(Constants.HELP_TEXT);
178200
return;
201+
case "--version":
202+
if (!version.isEmpty()) {
203+
System.out.println("Version: "+version);
204+
}
205+
return;
179206
default:
180207
System.out.println("Command" + s + " not recognized.");
181208
System.out.println(Constants.HELP_TEXT);

src/main/resources/lode.zip

208 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)