Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarijo committed Apr 3, 2017
2 parents 4aa22e0 + 2b4854c commit 2b30b4b
Show file tree
Hide file tree
Showing 31 changed files with 38,613 additions and 157 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ Download the executable

To download Widoco JAR, check the latest release (https://github.com/dgarijo/Widoco/releases/latest).

Citing Widoco
===================

Please cite the latest version of Widoco as follows:

Daniel Garijo, Almudena Ruiz-Iniesta, Oscar Corcho & Miguel Angel Garcia. (2017). dgarijo/Widoco: Widoco 1.3.0. Zenodo. http://doi.org/10.5281/zenodo.360175

Description
==========
Widoco helps you to create a complete documentation of your ontology, by following a series of steps in a wizard. We reuse the LODE framework by Silvio Peroni to describe the classes, properties and data properties of the ontology, the OOPS! webservice by María Poveda to print an evaluation and the Licensius service by Victor Rodriguez Doncel to determine the license URI and title being used.
Expand Down Expand Up @@ -54,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 @@ -82,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
118 changes: 83 additions & 35 deletions src/main/java/diff/OntologyDifferencesRenderer.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package diff;

import com.sun.corba.se.impl.orbutil.closure.Constant;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLClassExpression;
import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom;
import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom;
import org.semanticweb.owlapi.model.OWLObjectIntersectionOf;
import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom;
import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLObjectUnionOf;
import org.semanticweb.owlapi.model.OWLPropertyExpression;
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom;
import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom;
import org.semanticweb.owlapi.model.OWLSubPropertyAxiom;
import uk.ac.manchester.cs.owl.owlapi.OWLDataPropertyImpl;
import uk.ac.manchester.cs.owl.owlapi.OWLObjectPropertyImpl;
import widoco.Constants;

Expand Down Expand Up @@ -145,19 +148,19 @@ private static String axiomInfoSetToHTML(ArrayList<OWLAxiomInfo>set, String ns,
String v = "";
Iterator<OWLAxiomInfo> i = set.iterator();
while (i.hasNext()) {
OWLAxiomInfo classAxiomSet = i.next();
OWLAxiomInfo axiomSet = i.next();
//we print the whole url of the new property and link to the document reference.
v+="<li><a href=\"#"+classAxiomSet.getIRIAsString().replace(ns, "")+"\">"+classAxiomSet.getIRIAsString()+"</a>\n";
v+="<li><a href=\"#"+axiomSet.getIRIAsString().replace(ns, "")+"\">"+axiomSet.getIRIAsString()+"</a>\n";
if(showAdditions &&
classAxiomSet.getNewAxioms()!=null && !classAxiomSet.getNewAxioms().isEmpty()){
axiomSet.getNewAxioms()!=null && !axiomSet.getNewAxioms().isEmpty()){
v+="<ul>\n";
v+=axiomSetToHTML(classAxiomSet.getNewAxioms(), true, lang);
v+=axiomSetToHTML(axiomSet.getNewAxioms(), true, lang);
v+="</ul>\n";
}
if(showDeletions &&
classAxiomSet.getDeletedAxioms()!=null && !classAxiomSet.getDeletedAxioms().isEmpty()){
axiomSet.getDeletedAxioms()!=null && !axiomSet.getDeletedAxioms().isEmpty()){
v+="<ul>\n";
v+=axiomSetToHTML(classAxiomSet.getDeletedAxioms(), false, lang);
v+=axiomSetToHTML(axiomSet.getDeletedAxioms(), false, lang);
v+="</ul>\n";
}
v+="</li>\n";
Expand All @@ -174,36 +177,81 @@ private static String axiomSetToHTML(Set<OWLAxiom> set, boolean isAddition, Prop
message=lang.getProperty(Constants.LANG_DELETED)+": ";
}
for(OWLAxiom f:set){
v+="<li>";
if(f instanceof OWLSubClassOfAxiom){
v+=message+lang.getProperty(Constants.LANG_SUBCLASS_OF) +" "+ ((OWLSubClassOfAxiom)f).getSuperClass().asOWLClass().getIRI();
}else if(f instanceof OWLSubPropertyAxiom){
v+=message+lang.getProperty(Constants.LANG_SUBPROP_OF) +" "+ ((OWLObjectPropertyImpl)((OWLSubPropertyAxiom)f).getSuperProperty()).getIRI();
}else if(f instanceof OWLObjectPropertyDomainAxiom){
v+=message+Constants.LANG_DOMAIN+" "+((OWLObjectPropertyDomainAxiom)f).getDomain().asOWLClass().getIRI();
}else if(f instanceof OWLDataPropertyDomainAxiom){
v+=message+Constants.LANG_DOMAIN+" "+((OWLDataPropertyDomainAxiom)f).getDomain().asOWLClass().getIRI();
}else if(f instanceof OWLObjectPropertyRangeAxiom){
v+=message+Constants.LANG_RANGE+" "+((OWLObjectPropertyRangeAxiom)f).getRange().asOWLClass().getIRI();
}else if(f instanceof OWLDataPropertyRangeAxiom){
v+=message+Constants.LANG_RANGE+" "+((OWLDataPropertyRangeAxiom)f).getRange().asOWLDatatype().getIRI();
}else if(f instanceof OWLAnnotationAssertionAxiom){
v+= message+((OWLAnnotationAssertionAxiom)f).getProperty().toString() +" "+ ((OWLAnnotationAssertionAxiom)f).getValue().toString();
}else{
//other less typical axioms
v+=message+f.getAxiomType().getName()+" "+f.toString().replace("<", "&lt;").replace(">", "&gt;");
}
/**
* To add if we want to refine
* OWLDisjointClassesAxiom, OWLDisjointDataPropertiesAxiom, OWLDisjointObjectPropertiesAxiom,
* OWLEquivalentClassesAxiom, OWLEquivalentDataPropertiesAxiom, OWLEquivalentObjectPropertiesAxiom,
* OWLFunctionalDataPropertyAxiom, OWLFunctionalObjectPropertyAxiom,
*/
v+="</li>\n";
try{
v+="<li>";
if(f instanceof OWLSubClassOfAxiom){
v+=message+lang.getProperty(Constants.LANG_SUBCLASS_OF) +" "+ ((OWLSubClassOfAxiom)f).getSuperClass().asOWLClass().getIRI();
}else if(f instanceof OWLSubPropertyAxiom){
OWLPropertyExpression prop = ((OWLSubPropertyAxiom)f).getSuperProperty();
if(prop instanceof OWLObjectPropertyImpl){
v+=message+lang.getProperty(Constants.LANG_SUBPROP_OF) +" "+ ((OWLObjectPropertyImpl)prop).getIRI();
}else if(prop instanceof OWLDataPropertyImpl){
v+=message+lang.getProperty(Constants.LANG_SUBPROP_OF) +" "+ ((OWLDataPropertyImpl)prop).getIRI();
}
}else if(f instanceof OWLObjectPropertyDomainAxiom){
v+=message+Constants.LANG_DOMAIN+" "+expressionToHTML(((OWLObjectPropertyDomainAxiom)f).getDomain(), lang);
}else if(f instanceof OWLDataPropertyDomainAxiom){
v+=message+lang.getProperty(Constants.LANG_DOMAIN)+" "+expressionToHTML(((OWLDataPropertyDomainAxiom)f).getDomain(), lang);
}else if(f instanceof OWLObjectPropertyRangeAxiom){
v+=message+lang.getProperty(Constants.LANG_RANGE)+" "+expressionToHTML(((OWLObjectPropertyRangeAxiom)f).getRange(), lang);
}else if(f instanceof OWLDataPropertyRangeAxiom){
v+=message+lang.getProperty(Constants.LANG_RANGE)+" "+((OWLDataPropertyRangeAxiom)f).getRange().asOWLDatatype().getIRI();
}else if(f instanceof OWLAnnotationAssertionAxiom){
v+= message+((OWLAnnotationAssertionAxiom)f).getProperty().toString() +" "+ ((OWLAnnotationAssertionAxiom)f).getValue().toString();
}else{
//other less typical axioms
v+=message+f.getAxiomType().getName()+" "+f.toString().replace("<", "&lt;").replace(">", "&gt;");
}
/**
* To add if we want to refine
* OWLDisjointClassesAxiom, OWLDisjointDataPropertiesAxiom, OWLDisjointObjectPropertiesAxiom,
* OWLEquivalentClassesAxiom, OWLEquivalentDataPropertiesAxiom, OWLEquivalentObjectPropertiesAxiom,
* OWLFunctionalDataPropertyAxiom, OWLFunctionalObjectPropertyAxiom,
*/
v+="</li>\n";
}catch (Exception e){
System.out.println("Error while transforming "+f.toString() +" "+e.getMessage());
}

}

return v;
}

/**
* Method to translate expressions to html. It is recursive as an expression
* could be the union of intersections or viceversa.
* @param expr
* @param lang
* @return
*/
private static String expressionToHTML(OWLClassExpression expr, Properties lang){
String v ="";
if(expr instanceof OWLClass){
v+=expr.asOWLClass().getIRI();
}else{
if(expr instanceof OWLObjectUnionOf || expr instanceof OWLObjectIntersectionOf){
if(expr instanceof OWLObjectUnionOf){
v+=lang.getProperty(Constants.LANG_UNION)+" (";
for(OWLClassExpression e:expr.asDisjunctSet()){
v+= expressionToHTML(e, lang)+", ";
}
}else{
v+=lang.getProperty(Constants.LANG_INTERSECTION)+" (";
for(OWLClassExpression e:expr.asConjunctSet()){
v+= expressionToHTML(e, lang)+", ";
}
}

if(v.length()>2){
v = v.substring(0, v.length()-2);//remove last comma
}
v+=")";
}
}
return v;
}

/**
* Method that renders the current differences as HTML.
* @param c the comparison object with all the differences to render
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
33 changes: 32 additions & 1 deletion src/main/java/widoco/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,19 @@ 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 {
//create a temporal folder with all LODE resources
tmpFolder = new File("tmp"+new Date().getTime());
tmpFolder.mkdir();
WidocoUtils.unZipIt(Constants.lodeResources, tmpFolder.getName());
} catch (Exception ex) {
System.err.println("Error while creating the temporal file for storing the intermediate Widoco files.");
}
Expand All @@ -141,7 +148,7 @@ public File getTmpFile() {



public void initializeConfig(){
public final void initializeConfig(){
//initialization of variables (in case something fails)
abstractSection = "";
publishProvenance = true;
Expand Down Expand Up @@ -197,6 +204,7 @@ private void initializeOntology(){
mainOntologyMetadata.setCiteAs("");
mainOntologyMetadata.setDoi("");
mainOntologyMetadata.setStatus("");
mainOntologyMetadata.setBackwardsCompatibleWith("");
}

private void loadPropertyFile(String path){
Expand Down Expand Up @@ -320,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 @@ -430,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 @@ -517,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
Loading

0 comments on commit 2b30b4b

Please sign in to comment.