Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
And also i fixed a small typo when creating the ids of the terms.
  • Loading branch information
dgarijo committed Jan 14, 2016
1 parent 153c0e0 commit 6965637
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 140 deletions.
Binary file modified JAR/widoco-0.0.1-jar-with-dependencies.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The character ";" is used for lists (for instance first author; second author; t

Now you can execute Widoco through the console. Usage:

java -jar widoco.jar [-ontFile file] or [-ontURI uri] [-outFolder folderName] [-confFile propertiesFile] or [-getOntologyMetadata] [-oops] [-rewriteAll] [-saveConfig configOutFile] [-useCustomStyle] [-lang lang1;lang2]
java -jar widoco.jar [-ontFile file] or [-ontURI uri] [-outFolder folderName] [-confFile propertiesFile] or [-getOntologyMetadata] [-oops] [-rewriteAll] [-saveConfig configOutFile] [-useCustomStyle] [-lang lang1;lang2] [-includeImportedOntologies]

The ontFile and ontURI options allow you to choose the ontology file or ontology URI of your ontology.

Expand All @@ -67,6 +67,8 @@ The -useCustomStyle option allows exporting the documentation using alternate cs

The -lang option allows showing the languages in which the documentation will be published (separated by ";"). Note that if the language is not supported, the system will load the labels in english. For example: en;pt;es

The -includeImportedOntologies flag indicates whether the terms of the imported ontologies of the current ontology should be documented as well or not.

Browser problems
==========
The result of executing Widoco is an html file. We have tested it in Mozilla, IE and Chrome, and when the page is stored in a server all the browsers work correctly. If you view the file locally, we recommend you to use Mozilla Firefox (or Internet Explorer, if you must). Google Chrome will not show the contents correctly, as it doesn't allow XMLHttpRequest without HTTP. If you want to view the page locally with Google Chrome you have two possibilities:
Expand Down
30 changes: 16 additions & 14 deletions src/main/java/lode/LODEGeneration.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.util.HashSet;
import java.util.Set;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
Expand Down Expand Up @@ -60,7 +62,7 @@ public static String getLODEhtml(Configuration c, File lodeResources) throws Exc
lang = "en";
}
//load with jena in rdf xml
content = parseWithOWLAPI(c.getOntologyPath(), c.isFromFile());
content = parseWithOWLAPI(c.getOntologyPath(), c.isFromFile(), c.isUseImported());
content = applyXSLTTransformation(content, c.getOntologyURI(), lang, lodeResources);
return(content);
}
Expand All @@ -73,7 +75,8 @@ public static String getLODEhtml(Configuration c, File lodeResources) throws Exc

private static String parseWithOWLAPI(
String ontologyURL,
boolean loadFromFile)
boolean loadFromFile,
boolean considerImportedOntologies)
throws OWLOntologyCreationException, OWLOntologyStorageException, URISyntaxException {
String result = "";
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
Expand All @@ -84,18 +87,17 @@ private static String parseWithOWLAPI(
else{
ontology = manager.loadOntology(IRI.create(ontologyURL));
}
//this adds extra complexity that I don't want to include yet in the tool
// if (considerImportedClosure || considerImportedOntologies) {
// Set<OWLOntology> setOfImportedOntologies = new HashSet<OWLOntology>();
// if (considerImportedOntologies) {
// setOfImportedOntologies.addAll(ontology.getDirectImports());
// } else {
// setOfImportedOntologies.addAll(ontology.getImportsClosure());
// }
// for (OWLOntology importedOntology : setOfImportedOntologies) {
// manager.addAxioms(ontology, importedOntology.getAxioms());
// }
// }
if (considerImportedOntologies) {
//considerImportedClosure || //<- removed for the moment
Set<OWLOntology> setOfImportedOntologies = new HashSet<OWLOntology>();
setOfImportedOntologies.addAll(ontology.getDirectImports());
// else {
// setOfImportedOntologies.addAll(ontology.getImportsClosure());
// }
for (OWLOntology importedOntology : setOfImportedOntologies) {
manager.addAxioms(ontology, importedOntology.getAxioms());
}
}

OWLOntologyDocumentTarget parsedOntology = new StringDocumentTarget();
manager.saveOntology(ontology, new RDFXMLOntologyFormat(), parsedOntology);
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/widoco/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public class Configuration {

private String error;//Latest error to show to user via interface.

//add imported ontologies in the doc as well
private boolean addImportedOntologies;

//model everything as a singleton object. No need: only the controller accesses this file.
public Configuration() {
propertyFile = new Properties();
Expand Down Expand Up @@ -159,6 +162,7 @@ private void cleanConfig(){
}
useW3CStyle = true;//by default
error = "";
addImportedOntologies = false;
}

private void loadConfigPropertyFile(String path){
Expand Down Expand Up @@ -815,6 +819,15 @@ public void setError(String error) {
public String getError() {
return error;
}

public boolean isAddImportedOntologies() {
return addImportedOntologies;
}

public void setAddImportedOntologies(boolean addImportedOntologies) {
this.addImportedOntologies = addImportedOntologies;
}



}
13 changes: 11 additions & 2 deletions src/main/java/widoco/LODEParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -253,6 +254,13 @@ private Node fixAnchor(Node nodeToFix) {
Node secondAnchor = firstAnchor.getNextSibling();
String newID = firstAnchor.getAttributes().getNamedItem("name").getNodeValue();
newID = newID.replace(c.getMainOntology().getNamespaceURI(), "");

try{
//if the URI contains special characters, we must decode them for referencing them properly.
newID = URLDecoder.decode(newID, "UTF-8");
}catch(Exception e){
System.err.println("Error when encoding node.");
}
if (newID.startsWith("#")){
newID = newID.replace("#", "");
}//fix in case the author insert the NS URI without "#"
Expand All @@ -261,9 +269,10 @@ private Node fixAnchor(Node nodeToFix) {
}
//we save the the id for derreferencing properly the resource. Note that
//if a property has the same name as a Class this could lead to problems
replacements.put(currentNode.getAttributes().getNamedItem("id").getNodeValue(), newID);
replacements.put(currentNode.getAttributes().getNamedItem("id").getNodeValue()+"\"", newID+"\"");
//I include the comma at the end so smaller ids don't replace larger ids. (quick fix)

//we remove the anchor, which make an error in the visualization
//we remove the anchor, which makes an error in the visualization
currentNode.removeChild(firstAnchor);
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/widoco/gui/GuiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public GuiController(String[] args){
config = new Configuration();
//get the arguments
String outFolder="myDocumentation"+(new Date().getTime()), ontology="", configOutFile=null;
boolean isFromFile=false, oops = false, rewriteAll=false, getOntoMetadata = false, useW3Cstyle = true;
boolean isFromFile=false, oops = false, rewriteAll=false, getOntoMetadata = false, useW3Cstyle = true,
includeImportedOntologies = false;
String[] languages = null;
int i=0;
while(i< args.length){
Expand Down Expand Up @@ -123,13 +124,16 @@ else if(s.equals("-saveConfig")){
else if(s.equals("-useCustomStyle")){
useW3Cstyle = false;
}
else if(s.equals("-includeImportedOntologies")){
includeImportedOntologies = true;
}
else if(s.equals("-lang")){
languages = args[i+1].replace(" ","").split(";");
i++;
}
else{
System.out.println("Command"+s+" not recognized.");
System.out.println("Usage: java -jar widoco.jar [-ontFile file] or [-ontURI uri] [-outFolder folderName] [-confFile propertiesFile] [-getOntologyMetadata] [-oops] [-rewriteAll] [-saveConfig configOutFile]\n");
System.out.println("Usage: java -jar widoco.jar [-ontFile file] or [-ontURI uri] [-outFolder folderName] [-confFile propertiesFile] [-getOntologyMetadata] [-oops] [-rewriteAll] [-saveConfig configOutFile] [-lang lang1;lang2] [-includeImportedOntologies]\n");
return;
}
i++;
Expand All @@ -148,6 +152,7 @@ else if(s.equals("-lang")){
this.config.setOntologyPath(ontology);
this.config.setOverwriteAll(rewriteAll);
this.config.setUseW3CStyle(useW3Cstyle);
this.config.setUseImported(includeImportedOntologies);
if(languages!=null){
config.removeLanguageToGenerate("en");//default
for (String language : languages) {
Expand Down
Loading

0 comments on commit 6965637

Please sign in to comment.