Skip to content

Commit

Permalink
Several fixes and additional metadata
Browse files Browse the repository at this point in the history
Fix #164, Fix #211, Fix #198, Fix #203, Fix #34, Fix #147, Fix #118, Fix
#210
  • Loading branch information
dgarijo committed Apr 3, 2017
1 parent b9a3af6 commit 2b4854c
Show file tree
Hide file tree
Showing 28 changed files with 38,218 additions and 58 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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] [-crossRef] [-saveConfig configOutFile] [-useCustomStyle] [-lang lang1-lang2] [-includeImportedOntologies] [-htaccess] [-webVowl] [-licensius]
java -jar widoco.jar [-ontFile file] or [-ontURI uri] [-outFolder folderName] [-confFile propertiesFile] or [-getOntologyMetadata] [-oops] [-rewriteAll] [-crossRef] [-saveConfig configOutFile] [-useCustomStyle] [-lang lang1-lang2] [-includeImportedOntologies] [-htaccess] [-webVowl] [-licensius] [-ignoreIndividuals]

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

Expand Down Expand Up @@ -89,6 +89,8 @@ The -webVowl flag provides a link to a visualization based on WebVowl (http://vo

The -licensius flag uses the Licensius web services (http://licensius.com/apidoc/index.html) to retrieve license metadata. Only works if the -getOntologyMetadata flag is enabled.

The -ignoreIndividuals allows you to ignore the named individuals in the ontology.

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 Safari (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
18 changes: 12 additions & 6 deletions src/main/java/lode/LODEGeneration.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.io.FileDocumentSource;
import org.semanticweb.owlapi.io.OWLOntologyDocumentSource;
import org.semanticweb.owlapi.io.OWLOntologyDocumentTarget;
import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
import org.semanticweb.owlapi.io.StringDocumentSource;
import org.semanticweb.owlapi.io.StringDocumentTarget;
import org.semanticweb.owlapi.model.MissingImportEvent;
import org.semanticweb.owlapi.model.MissingImportHandlingStrategy;
import org.semanticweb.owlapi.model.MissingImportListener;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration;
import org.semanticweb.owlapi.model.OWLOntologyStorageException;
import org.semanticweb.owlapi.model.OWLOntologyManager;
import widoco.Configuration;
Expand Down Expand Up @@ -76,13 +83,12 @@ private static String parseWithOWLAPI(
boolean considerImportedOntologies)
throws OWLOntologyCreationException, OWLOntologyStorageException, URISyntaxException {
String result = "";
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntologyLoaderConfiguration loadingConfig = new OWLOntologyLoaderConfiguration();
loadingConfig = loadingConfig.setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT);
OWLOntology ontology;
ontology= manager.loadOntologyFromOntologyDocument(new File(ontologyURL));
//
// else{
// ontology = manager.loadOntology(IRI.create(ontologyURL));
// }
// ontology = manager.loadOntologyFromOntologyDocument(new OWLOntologyDocumentSource, config)
ontology= manager.loadOntologyFromOntologyDocument(new FileDocumentSource(new File(ontologyURL)),loadingConfig);
if (considerImportedOntologies) {
//considerImportedClosure || //<- removed for the moment
Set<OWLOntology> setOfImportedOntologies = new HashSet<OWLOntology>();
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/oops/OOPSevaluation.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public String printEvaluation (){

ExtendedIterator<Individual> p = model.listIndividuals(pitfallClass);
List<Individual> plist = p.toList();
System.out.println("Numero de pitfalls: " + plist.size() );
System.out.println("Pitfall number: " + plist.size() );

if (plist.size() > 0){

Expand Down Expand Up @@ -460,6 +460,8 @@ else if (nextNode.isURIResource()){
}
}
evaluationOutput = evaluationOutput + "</div>\n"; //close div accordion
}else{
evaluationOutput = "<h2>Congratulations! OOPS did not find a single pitfall</h2>";
}


Expand Down
30 changes: 30 additions & 0 deletions src/main/java/widoco/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ public class Configuration {
private boolean createWebVowlVisualization;
private boolean useLicensius;//optional usage of Licensius service.

/**
* Variable to keep track of possible errors in the changelog. If there are errors, the
* section will not be produced. True by default.
*/
private boolean changeLogSuccessfullyCreated = true;

public Configuration() {
initializeConfig();
try {
Expand Down Expand Up @@ -198,6 +204,7 @@ private void initializeOntology(){
mainOntologyMetadata.setCiteAs("");
mainOntologyMetadata.setDoi("");
mainOntologyMetadata.setStatus("");
mainOntologyMetadata.setBackwardsCompatibleWith("");
}

private void loadPropertyFile(String path){
Expand Down Expand Up @@ -321,6 +328,7 @@ private void loadPropertyFile(String path){
mainOntologyMetadata.setStatus(propertyFile.getProperty(Constants.STATUS,"Specification Draft"));
mainOntologyMetadata.setCiteAs(propertyFile.getProperty(Constants.CITE_AS, ""));
mainOntologyMetadata.setDoi(propertyFile.getProperty(Constants.DOI, ""));
mainOntologyMetadata.setBackwardsCompatibleWith(propertyFile.getProperty(Constants.COMPATIBLE, ""));
//vocabLoadedSerialization = propertyFile.getProperty(TextConstants.deafultSerialization, "RDF/XML");
String serializationRDFXML = propertyFile.getProperty(Constants.RDF,"");
if(!"".equals(serializationRDFXML)){
Expand Down Expand Up @@ -431,6 +439,18 @@ public void loadPropertiesFromOntology(OntModel m){
if(propertyName.equals("modified")){
mainOntologyMetadata.setReleaseDate(value);
}else
if(propertyName.equals("bibliographicCitation")){
mainOntologyMetadata.setCiteAs(value);
}else
if(propertyName.equals("doi")||propertyName.equals("hasDOI")){
mainOntologyMetadata.setDoi(value);
}else
if(propertyName.equals("backwardsCompatibleWith")){
mainOntologyMetadata.setBackwardsCompatibleWith(value);
}else
if(propertyName.equals("status")){
mainOntologyMetadata.setStatus(value);
}else
if(propertyName.equals("imports")){
Ontology o = new Ontology();
if(isURL(value)){
Expand Down Expand Up @@ -518,6 +538,16 @@ public String getOntologyURI() {
public boolean isPublishProvenance() {
return publishProvenance;
}

public boolean isChangeLogSuccessfullyCreated() {
return changeLogSuccessfullyCreated;
}

public void setChangeLogSuccessfullyCreated(boolean changeLogSuccessfullyCreated) {
this.changeLogSuccessfullyCreated = changeLogSuccessfullyCreated;
}




public void setDocumentationURI(String documentationURI) {
Expand Down
25 changes: 23 additions & 2 deletions src/main/java/widoco/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class Constants {

/*Property that will retrieve the status of the document from the property file*/
public static final String STATUS="status";
public static final String COMPATIBLE="backwardsCompatibleWith";


//Constants for language tags. These are the names used in the property file
Expand Down Expand Up @@ -136,6 +137,10 @@ public class Constants {
public static final String LANG_DATA_PROP = "dataProp";
public static final String LANG_ANN_PROP = "annProp";
public static final String LANG_NAMED_INDIV = "namedIndiv";
public static final String LANG_TABLE_OF_CONTENTS = "tableOfContents";
public static final String LANG_COMPATIBLE = "compatible";
public static final String LANG_LEGEND = "legend";

//labels for the changelog
public static final String LANG_CHANGELOG_HEAD = "changelogHead";
public static final String LANG_ADDED_CLASS = "addedClass";
Expand Down Expand Up @@ -445,7 +450,7 @@ public static String getIndexDocument(String resourcesFolderName,Configuration c
"}\n"
+ "function loadTOC(){\n" +
" //process toc dynamically\n" +
" var t='<h2>Table of contents</h2><ul>';i = 1;j=0;\n" +
" var t='<h2>"+lang.getProperty(LANG_TABLE_OF_CONTENTS)+"</h2><ul>';i = 1;j=0;\n" +
" jQuery(\".list\").each(function(){\n" +
" if(jQuery(this).is('h2')){\n" +
" if(j>0){\n" +
Expand Down Expand Up @@ -475,7 +480,7 @@ public static String getIndexDocument(String resourcesFolderName,Configuration c
if(c.isIncludeDescription()) document += " $(\"#description\").load(\"sections/description-"+c.getCurrentLanguage()+".html\"); \n";
if(c.isIncludeReferences()) document += " $(\"#references\").load(\"sections/references-"+c.getCurrentLanguage()+".html\"); \n";
if(c.isIncludeChangeLog()){
if(c.getMainOntology().getPreviousVersion()!=null &&!"".equals(c.getMainOntology().getPreviousVersion())){
if(c.getMainOntology().getPreviousVersion()!=null &&!"".equals(c.getMainOntology().getPreviousVersion()) && c.isChangeLogSuccessfullyCreated()){
document += " $(\"#changelog\").load(\"sections/changelog-"+c.getCurrentLanguage()+".html\"); \n";
}
}
Expand Down Expand Up @@ -584,6 +589,10 @@ public static String getHeadSection(Configuration c, Properties l){
//doi is common for all languages
head+="<dl><dt>DOI:</dt>\n<dd><a href=\"http://dx.doi.org/"+c.getMainOntology().getDoi()+"\"><img src =\"https://img.shields.io/badge/DOI-"+c.getMainOntology().getDoi()+"-blue.svg\" alt=\""+c.getMainOntology().getDoi()+"\"></img></a></dd>\n</dl>\n";
}
if(!"".equals(c.getMainOntology().getBackwardsCompatibleWith()) && c.getMainOntology().getBackwardsCompatibleWith()!=null){
//doi is common for all languages
head+="<dl><dt>"+l.getProperty(LANG_COMPATIBLE)+":</dt>\n<dd>"+c.getMainOntology().getBackwardsCompatibleWith()+"</dd>\n</dl>\n";
}
if(c.isPublishProvenance()){
head+="<dl><a href=\"provenance/provenance-"+c.getCurrentLanguage()+".html\" target=\"_blank\">"+l.getProperty(LANG_PRPOV_HEAD)+"</a></dl>";
}
Expand Down Expand Up @@ -946,4 +955,16 @@ public static String get406(Configuration c, Properties lang) {
return page406;
}

public static String getLegend(Properties lang){
return "<div id=\"legend\">\n" +
"<h2>"+lang.getProperty(Constants.LANG_LEGEND)+" <span class=\"backlink\"> "+lang.getProperty(Constants.LANG_BACK)+" <a href=\"#toc\">ToC</a></span></h2>\n" +
"<div class=\"entity\">\n" +
"<sup class=\"type-c\" title=\""+lang.getProperty(Constants.LANG_CLASSES)+"\">c</sup>: "+lang.getProperty(Constants.LANG_CLASSES)+" <br/>\n" +
"<sup class=\"type-op\" title=\""+lang.getProperty(Constants.LANG_OBJ_PROP)+"\">op</sup>: "+lang.getProperty(Constants.LANG_OBJ_PROP)+" <br/>\n" +
"<sup class=\"type-dp\" title=\""+lang.getProperty(Constants.LANG_DATA_PROP)+"\">dp</sup>: "+lang.getProperty(Constants.LANG_DATA_PROP)+" <br/>\n" +
"<sup class=\"type-ni\" title=\""+lang.getProperty(Constants.LANG_NAMED_INDIV)+"\">ni</sup>: "+lang.getProperty(Constants.LANG_NAMED_INDIV)+"\n" +
"</div>\n" +
"</div>";
}

}
41 changes: 22 additions & 19 deletions src/main/java/widoco/CreateOOPSEvalInThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,13 @@ public void run() {
this.pointerToMain.switchState("sendingRequest");
}
System.out.println("Sending request to OOPS server...");
File evalFolder = new File(c.getDocumentationURI()+File.separator+"OOPSevaluation");
File evalResourcesFolder = new File(evalFolder.getAbsolutePath()+File.separator+"evaluation");//for the css etc.
try{
if(!evalFolder.exists())evalFolder.mkdir();
evalResourcesFolder.mkdir();
//CreateResources.copyResourceFolder(TextConstants.oopsResources, evalResourcesFolder.getAbsolutePath());
WidocoUtils.unZipIt(Constants.oopsResources, evalResourcesFolder.getAbsolutePath());
//do POST petition with evaluation.
String evaluation;
OOPSevaluation eval;

//read file
String content;
String content=null;
BufferedReader br = new BufferedReader(new FileReader(c.getOntologyPath()));
try {
StringBuilder sb = new StringBuilder();
Expand All @@ -70,18 +64,27 @@ public void run() {
} finally {
br.close();
}
eval = new OOPSevaluation("",content);
//eval = new OOPSevaluation(c.getMainOntology().getNamespaceURI(),"");

evaluation = eval.printEvaluation();
//SAVE File
if(showGui){
this.pointerToMain.switchState("savingResponse");
}
System.out.println("Saving response...");
CreateResources.saveDocument(evalFolder.getAbsolutePath()+File.separator+"oopsEval.html", Constants.getEvaluationText(evaluation, c),c);
if(showGui){
pointerToMain.openBrowser(new File(evalFolder.getAbsolutePath()+File.separator+"oopsEval.html").toURI());
if(content!=null && !content.equals("")){
File evalFolder = new File(c.getDocumentationURI()+File.separator+"OOPSevaluation");
File evalResourcesFolder = new File(evalFolder.getAbsolutePath()+File.separator+"evaluation");//for the css etc.
if(!evalFolder.exists())evalFolder.mkdir();
evalResourcesFolder.mkdir();
//CreateResources.copyResourceFolder(TextConstants.oopsResources, evalResourcesFolder.getAbsolutePath());
WidocoUtils.unZipIt(Constants.oopsResources, evalResourcesFolder.getAbsolutePath());
eval = new OOPSevaluation("",content);
//eval = new OOPSevaluation(c.getMainOntology().getNamespaceURI(),"");
evaluation = eval.printEvaluation();
//SAVE File
if(showGui){
this.pointerToMain.switchState("savingResponse");
}
System.out.println("Saving response...");
CreateResources.saveDocument(evalFolder.getAbsolutePath()+File.separator+"oopsEval.html", Constants.getEvaluationText(evaluation, c),c);
if(showGui){
pointerToMain.openBrowser(new File(evalFolder.getAbsolutePath()+File.separator+"oopsEval.html").toURI());
}
}else{
throw new Exception("OOPS server did not return an evaluation report");
}
}catch(Exception e){
System.err.println("Error while saving OOPS evaluation: "+e.getMessage());
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 @@ -176,9 +176,9 @@ private static void createChangeLog(String path, Configuration c, Properties lan
saveDocument(path+File.separator+"changelog-"+c.getCurrentLanguage()+".html", Constants.getChangeLogSection(c, comparison, lang),c);
System.out.println("Changelog successfully created");
}catch(Exception e){
c.setChangeLogSuccessfullyCreated(false);
System.out.println("Could not generate changelog: "+e.getMessage());
}

}

/**
Expand Down Expand Up @@ -267,6 +267,8 @@ private static void createCrossReferenceSection(String path,LODEParser lodeParse
if(c.isIncludeNamedIndividuals() && namedIndividualList!=null && !"".equals(namedIndividualList)){
crossRef += lodeParser.getNamedIndividuals();
}
//add legend
crossRef+=Constants.getLegend(lang);
saveDocument(path+File.separator+"crossref-"+c.getCurrentLanguage()+".html", crossRef,c);
}

Expand Down Expand Up @@ -375,6 +377,7 @@ public static void saveConfigFile(String path, Configuration conf)throws IOExcep
textProperties+=Constants.CITE_AS+"="+conf.getMainOntology().getCiteAs()+"\n";
textProperties+=Constants.DOI+"="+conf.getMainOntology().getDoi()+"\n";
textProperties+=Constants.STATUS+"="+conf.getMainOntology().getStatus()+"\n";
textProperties+=Constants.COMPATIBLE+"="+conf.getMainOntology().getBackwardsCompatibleWith()+"\n";
if(conf.getMainOntology().getPublisher()!=null){
textProperties+=Constants.PUBLISHER+"="+conf.getMainOntology().getPublisher().getName()+"\n";
textProperties+=Constants.PUBLISHER_URI+"="+conf.getMainOntology().getPublisher().getURL()+"\n";
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/widoco/entities/Ontology.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ public class Ontology {
* DOI of the ontology, if available
*/
private String doi;

/**
* Compatible with
*/
private String backwardsCompatibleWith;

public Ontology() {
}
Expand Down Expand Up @@ -291,4 +296,14 @@ public Agent getPublisher() {
public void setPublisher(Agent publisher) {
this.publisher = publisher;
}

public String getBackwardsCompatibleWith() {
return backwardsCompatibleWith;
}

public void setBackwardsCompatibleWith(String backwardsCompatibleWith) {
this.backwardsCompatibleWith = backwardsCompatibleWith;
}


}
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 @@ -72,7 +72,7 @@ public GuiController(String[] args){
String outFolder="myDocumentation"+(new Date().getTime()), ontology="", configOutFile=null;
boolean isFromFile=false, oops = false, rewriteAll=false, getOntoMetadata = false, useW3Cstyle = true,
includeImportedOntologies = false, htAccess = false, webVowl=false, errors = false, licensius = false,
generateOnlyCrossRef = false;
generateOnlyCrossRef = false, includeNamedIndividuals=true;
String[] languages = null;
int i=0;
while(i< args.length){
Expand Down Expand Up @@ -135,9 +135,13 @@ else if(s.equals("-webVowl")){
else if (s.equals("-licensius")){
licensius = true;
}
else if(s.equals("-ignoreIndividuals")){
includeNamedIndividuals=false;
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] [-crossRef] [-saveConfig configOutFile] [-lang lang1-lang2] [-includeImportedOntologies] [-htaccess] [-licensius]\n");
System.out.println("Usage: java -jar widoco.jar [-ontFile file] or [-ontURI uri] [-outFolder folderName] [-confFile propertiesFile] [-getOntologyMetadata] [-oops] [-rewriteAll] [-crossRef] [-saveConfig configOutFile] [-lang lang1-lang2] [-includeImportedOntologies] [-htaccess] [-licensius] [-ignoreIndividuals]\n");
return;
}
i++;
Expand Down Expand Up @@ -169,6 +173,7 @@ else if (s.equals("-licensius")){
this.config.setCreateHTACCESS(htAccess);
this.config.setCreateWebVowlVisualization(webVowl);
this.config.setUseLicensius(licensius);
this.config.setIncludeNamedIndividuals(includeNamedIndividuals);
if(languages!=null){
config.removeLanguageToGenerate("en");//default
for (String language : languages) {
Expand Down
Loading

0 comments on commit 2b4854c

Please sign in to comment.