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 Aug 7, 2016
2 parents 45d7790 + 7dd5648 commit 5b10a41
Show file tree
Hide file tree
Showing 26 changed files with 7,605 additions and 552 deletions.
5 changes: 2 additions & 3 deletions 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] [-includeImportedOntologies] [-htaccess] [-webVowl]
java -jar widoco.jar [-ontFile file] or [-ontURI uri] [-outFolder folderName] [-confFile propertiesFile] or [-getOntologyMetadata] [-oops] [-rewriteAll] [-saveConfig configOutFile] [-useCustomStyle] [-lang lang1-lang2] [-includeImportedOntologies] [-htaccess] [-webVowl]

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

Expand All @@ -65,7 +65,7 @@ The -saveConfig option allows you to save a configuration file on the "configOut

The -useCustomStyle option allows exporting the documentation using alternate css files (thanks to Daniel Vila).

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 -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.

Expand All @@ -91,7 +91,6 @@ Current improvements
==========
We are working on the following features:
* Integration with diagram creators to include a diagram of your ontology when generating the documentation
* Possibility of generating the documentation in several languages (now supported: en, es, pt).
* Means to add examples to your ontology terms.
* Previsualization of the terms that will be generated.

Expand Down
37 changes: 37 additions & 0 deletions config/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

abstract=The abstract of your ontology goes here.
ontologyTitle=The Test Ontology
ontologyName=Test
ontologyPrefix=test
ontologyNamespaceURI=http://purl.org/net/p-plan#
dateOfRelease= Insert the release date here. E.g.: 11 July 2013
thisVersionURI=http://purl.org/net/p-plan
latestVersionURI=http://example.org/latestVersion
previousVersionURI=http://example.org/previousVersion
ontologyRevisionNumber=1.0.0
authors=First Author;Second Author
authorsURI=http://example.org/author1;http://example.org/author2
authorsInstitution=First author institution;Second author institution
authorsInstitutionURI=http://firstAuthorinstitution.org; http://secondAuthorinstitution.org
contributors=First contributor;Second contributor
contributorsURI=http://example.org/contributor1;http://example.org/contributor2
contributorsInstitution=First contributor institution;Second contributor institution
contributorsInstitutionURI=http://firstConstributorinstitution.org;
publisher=publisherName
publisherURI=http://example.com/publisher1
publisherInstitution=OEG
publisherInstitutionURI=http://oeg-upm.es
importedOntologyNames=Imported Ontology 1; Imported Ontology 2
importedOntologyURIs=http://example.org/test11; http://example.org/test22
extendedOntologyNames=test1; test2
extendedOntologyURIs=http://example.org/test1; http://example.org/test2
licenseName=License name. E.g.: Creative Commons Attribution-NonCommercial-ShareAlike 2.0 Generic License
licenseURI=http://creativecommons.org/licenses/by-nc-sa/2.0/
licenseIconURL=http://i.creativecommons.org/l/by-nc-sa/2.0/88x31.png
citeAs=Insert here how you want to cite your ontology.
DOI=DOI of for your ontology publication goes here.
status=Ontology Draft
RDFXMLSerialization=http://vocab.linkeddata.es/p-plan/p-plan.owl
TurtleSerialization=
N3Serialization=
JSONLDSerialization=
File renamed without changes.
310 changes: 90 additions & 220 deletions src/main/java/widoco/Configuration.java

Large diffs are not rendered by default.

320 changes: 145 additions & 175 deletions src/main/java/widoco/Constants.java

Large diffs are not rendered by default.

97 changes: 46 additions & 51 deletions src/main/java/widoco/CreateResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@

package widoco;

import com.hp.hpl.jena.ontology.OntModel;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.AbstractMap;
import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Properties;
Expand All @@ -44,8 +41,6 @@ public class CreateResources {
//to do: analyze if this is the right name for the class. Maybe "generate" is better
public static void generateDocumentation(String outFolder, Configuration c, File lodeResources) throws Exception{
String lodeContent;
lodeContent = LODEGeneration.getLODEhtml(c, lodeResources);
LODEParser lode = new LODEParser(lodeContent,c);
String folderOut = outFolder;
Properties languageFile = new Properties();
try{
Expand All @@ -60,6 +55,8 @@ public static void generateDocumentation(String outFolder, Configuration c, File
System.out.println("Error while reading the language file: "+e1.getMessage());
}
}
lodeContent = LODEGeneration.getLODEhtml(c, lodeResources);
LODEParser lode = new LODEParser(lodeContent,c,languageFile);
if(c.isCreateHTACCESS()){
File f = new File (folderOut);
if(!f.exists()){
Expand Down Expand Up @@ -104,7 +101,7 @@ public static void generateDocumentation(String outFolder, Configuration c, File
if(sValue.startsWith("ontology")){
try {
out = new FileOutputStream(folderOut+File.separator+sValue);
c.getMainModel().write(out,serialization);
c.getMainOntology().getMainModel().write(out,serialization);
out.close();
} catch (Exception ex) {
System.out.println("Error while writing the model to file "+ex.getMessage());
Expand Down Expand Up @@ -322,21 +319,29 @@ private static void createFolderStructure(String s, Configuration c, Properties
public static void saveConfigFile(String path, Configuration conf)throws IOException{
String textProperties = "\n";//the first line I leave an intro because there have been problems.
textProperties+=Constants.abstractSectionContent+"="+conf.getAbstractSection()+"\n";
textProperties+=Constants.ontTitle+"="+conf.getTitle()+"\n";
textProperties+=Constants.ontTitle+"="+conf.getMainOntology().getTitle()+"\n";
textProperties+=Constants.ontPrefix+"="+conf.getMainOntology().getNamespacePrefix()+"\n";
textProperties+=Constants.ontNamespaceURI+"="+conf.getMainOntology().getNamespaceURI()+"\n";
textProperties+=Constants.ontName+"="+conf.getMainOntology().getName()+"\n";
textProperties+=Constants.thisVersionURI+"="+conf.getThisVersion()+"\n";
textProperties+=Constants.latestVersionURI+"="+conf.getLatestVersion()+"\n";
textProperties+=Constants.previousVersionURI+"="+conf.getPreviousVersion()+"\n";
textProperties+=Constants.dateOfRelease+"="+conf.getReleaseDate()+"\n";
textProperties+=Constants.ontologyRevision+"="+conf.getRevision()+"\n";
textProperties+=Constants.thisVersionURI+"="+conf.getMainOntology().getThisVersion()+"\n";
textProperties+=Constants.latestVersionURI+"="+conf.getMainOntology().getLatestVersion()+"\n";
textProperties+=Constants.previousVersionURI+"="+conf.getMainOntology().getPreviousVersion()+"\n";
textProperties+=Constants.dateOfRelease+"="+conf.getMainOntology().getReleaseDate()+"\n";
textProperties+=Constants.ontologyRevision+"="+conf.getMainOntology().getRevision()+"\n";
textProperties+=Constants.licenseURI+"="+conf.getMainOntology().getLicense().getUrl()+"\n";
textProperties+=Constants.licenseName+"="+conf.getMainOntology().getLicense().getName()+"\n";
textProperties+=Constants.licenseIconURL+"="+conf.getMainOntology().getLicense().getIcon()+"\n";
textProperties+=Constants.citeAs+"="+conf.getCiteAs()+"\n";
String authors="", authorURLs="", authorInstitutions="";
ArrayList<Agent> ag = conf.getCreators();
textProperties+=Constants.citeAs+"="+conf.getMainOntology().getCiteAs()+"\n";
textProperties+=Constants.doi+"="+conf.getMainOntology().getDoi()+"\n";
textProperties+=Constants.status+"="+conf.getMainOntology().getStatus()+"\n";
if(conf.getMainOntology().getPublisher()!=null){
textProperties+=Constants.publisher+"="+conf.getMainOntology().getPublisher().getName()+"\n";
textProperties+=Constants.publisherURI+"="+conf.getMainOntology().getPublisher().getURL()+"\n";
textProperties+=Constants.publisherInstitution+"="+conf.getMainOntology().getPublisher().getInstitutionName()+"\n";
textProperties+=Constants.publisherInstitutionURI+"="+conf.getMainOntology().getPublisher().getInstitutionURL()+"\n";
}
String authors="", authorURLs="", authorInstitutions="",authorInstitutionURLs="";
ArrayList<Agent> ag = conf.getMainOntology().getCreators();
if(!ag.isEmpty()){
for(int i=0; i<ag.size()-1;i++){
Agent a = ag.get(i);
Expand All @@ -346,20 +351,25 @@ public static void saveConfigFile(String path, Configuration conf)throws IOExcep
authorURLs+=";";
if(a.getInstitutionName()!=null)authorInstitutions+=a.getInstitutionName();
authorInstitutions+=";";
if(a.getInstitutionURL()!=null)authorInstitutionURLs+=a.getInstitutionURL();
authorInstitutionURLs+=";";
}
//last agent: no ";"
if(ag.get(ag.size()-1).getName()!=null) authors+=ag.get(ag.size()-1).getName();
if(ag.get(ag.size()-1).getURL()!=null) authorURLs+=ag.get(ag.size()-1).getURL();
if(ag.get(ag.size()-1).getInstitutionName()!=null) authorInstitutions+=ag.get(ag.size()-1).getInstitutionName();
if(ag.get(ag.size()-1).getInstitutionURL()!=null) authorInstitutionURLs+=ag.get(ag.size()-1).getInstitutionURL();
}
textProperties+=Constants.authors+"="+authors+"\n";
textProperties+=Constants.authorsURI+"="+authorURLs+"\n";
textProperties+=Constants.authorsInstitution+"="+authorInstitutions+"\n";
textProperties+=Constants.authorsInstitutionURI+"="+authorInstitutionURLs+"\n";

ag = conf.getContributors();
ag = conf.getMainOntology().getContributors();
authors="";
authorURLs="";
authorInstitutions="";
authorInstitutionURLs="";
if(!ag.isEmpty()){
for(int i=0; i<ag.size()-1;i++){
Agent a = ag.get(i);
Expand All @@ -369,16 +379,20 @@ public static void saveConfigFile(String path, Configuration conf)throws IOExcep
authorURLs+=";";
if(a.getInstitutionName()!=null)authorInstitutions+=a.getInstitutionName();
authorInstitutions+=";";
if(a.getInstitutionURL()!=null)authorInstitutionURLs+=a.getInstitutionURL();
authorInstitutionURLs+=";";
}
if(ag.get(ag.size()-1).getName()!=null) authors+=ag.get(ag.size()-1).getName();
if(ag.get(ag.size()-1).getURL()!=null) authorURLs+=ag.get(ag.size()-1).getURL();
if(ag.get(ag.size()-1).getInstitutionName()!=null) authorInstitutions+=ag.get(ag.size()-1).getInstitutionName();
if(ag.get(ag.size()-1).getInstitutionURL()!=null) authorInstitutionURLs+=ag.get(ag.size()-1).getInstitutionURL();
}
textProperties+=Constants.contributors+"="+authors+"\n";
textProperties+=Constants.contributorsURI+"="+authorURLs+"\n";
textProperties+=Constants.contributorsInstitution+"="+authorInstitutions+"\n";
textProperties+=Constants.contributorsInstitutionURI+"="+authorInstitutionURLs+"\n";
String importedNames="", importedURIs="";
ArrayList<Ontology> imported = conf.getImportedOntologies();
ArrayList<Ontology> imported = conf.getMainOntology().getImportedOntologies();
if(!imported.isEmpty()){
for(int i=0; i<imported.size()-1;i++){
Ontology o = imported.get(i);
Expand All @@ -393,7 +407,7 @@ public static void saveConfigFile(String path, Configuration conf)throws IOExcep
}
textProperties+=Constants.importedOntologyNames+"="+importedNames+"\n";
textProperties+=Constants.importedOntologyURIs+"="+importedURIs+"\n";
imported = conf.getExtendedOntologies();
imported = conf.getMainOntology().getExtendedOntologies();
importedNames = "";
importedURIs = "";
if(!imported.isEmpty()){
Expand All @@ -410,6 +424,20 @@ public static void saveConfigFile(String path, Configuration conf)throws IOExcep
}
textProperties+=Constants.extendedOntologyNames+"="+importedNames+"\n";
textProperties+=Constants.extendedOntologyURIs+"="+importedURIs+"\n";
//serializations
HashMap<String,String> serializations = conf.getMainOntology().getSerializations();
if(serializations.containsKey("RDF/XML")){
textProperties+=Constants.rdf+"="+serializations.get("RDF/XML")+"\n";
}
if(serializations.containsKey("TTL")){
textProperties+=Constants.ttl+"="+serializations.get("TTL")+"\n";
}
if(serializations.containsKey("N-Triples")){
textProperties+=Constants.n3+"="+serializations.get("N-Triples")+"\n";
}
if(serializations.containsKey("JSON-LD")){
textProperties+=Constants.json+"="+serializations.get("JSON-LD")+"\n";
}
//copy the result into the file
Writer writer = null;
try {
Expand All @@ -425,38 +453,5 @@ public static void saveConfigFile(String path, Configuration conf)throws IOExcep
} catch (IOException ex) {}
}
}
// public static void main(String[] args){
// //these methods have to be private!!
//// createFolderStructure("C:\\Users\\Monen\\Desktop\\myDoc", false, false);
// Configuration c = new Configuration();
//// c.setIncludeOverview(false);
//// c.setIncludeCrossReferenceSection(false);
// c.setMainOntology(new Ontology("The Wf-Motif Ontology", "Wf-motif", "http://purl.org/net/wf-motifs#"));//<-cuidado con el hash y el slash del final...
// c.setTitle("The Wf-Motif Ontology"); //redindant??
// c.setRevision("5.0");
// c.setReleaseDate("1-1-2011");
// c.setThisVersion("thisversion.org");
// c.setPreviousVersion("lastVersion.link");
// c.setOntologyURI("http://purl.org/net/example#");//check why do I need ont path and ont uri... and ontology namespace.
// //c.setOntologyPath("http://purl.org/net/wf-motifs#");
// //local copy test
// c.setOntologyPath("C:\\Users\\Dani\\Desktop\\RO-opt.owl");
// Agent a = new Agent();
// a.setName("Dani");a.setURL("http://dani.org");a.setInstitutionName("OEG Corp");
// Agent a2 = new Agent("A", "http://bananen.org", "monen group", "hdhw");
// ArrayList<Agent> aux = new ArrayList<Agent>();
// aux.add(a);aux.add(a2);
// c.setCreators(aux);
// c.setContributors(aux);
// Ontology test = new Ontology("a", "b", "cbc");
// ArrayList<Ontology> t = new ArrayList<Ontology>();
// t.add(test);
// c.setImportedOntolgies(t);
// License l = new License("http://licenseUri", "LicenseName", "http://i.creativecommons.org/l/by-nc-sa/2.0/88x31.png");
// c.setLicense(l);
//// generateDocumentation("C:\\Users\\Monen\\Desktop\\myDoc", c);
// generateDocumentation("C:\\Users\\Dani\\Desktop\\myDoc", c, false);
// }


}
16 changes: 10 additions & 6 deletions src/main/java/widoco/LODEParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.StringWriter;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilder;
Expand Down Expand Up @@ -58,20 +59,18 @@ public class LODEParser {
private final HashMap <String,String> namespaceDeclarations;
Configuration c;

// public LODEParser() {
// replacements = new HashMap<String, String>();
// }
/**
* Constructor for the lode parser. The reason for creating this class is that
* I don't want to edit LODE's xls file, and I only want to reuse certain parts.
* @param lodeContent text obtained as a response from LODE.
* @param c configuration object
* @param langFile language file to do proper annotations of classes, props, etc.
*/
public LODEParser(String lodeContent, Configuration c) {
public LODEParser(String lodeContent, Configuration c, Properties langFile) {
replacements = new HashMap<String, String>();
namespaceDeclarations = new HashMap<String, String>();
this.c = c;
parse(lodeContent);
parse(lodeContent, langFile);
}

public String getClassList() {
Expand Down Expand Up @@ -119,7 +118,7 @@ public String getNamedIndividualList() {
}


private void parse(String content){
private void parse(String content, Properties langFile){
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Expand All @@ -132,22 +131,27 @@ private void parse(String content){
if(attrID.equals("classes")){
classList = getTermList(html.item(i));
classes = nodeToString(html.item(i));
classes = classes.replace("<h2>"+langFile.getProperty("classes")+"</h2>", "<h3 id=\"classes\" class=\"list\">"+langFile.getProperty("classes")+"</h3>");
}
else if(attrID.equals("objectproperties")){
propertyList =getTermList(html.item(i));
properties = (nodeToString(html.item(i)));
properties = properties.replace("<h2>"+langFile.getProperty("objProp")+"</h2>", "<h3 id=\"properties\" class=\"list\">"+langFile.getProperty("objProp")+"</h3>");
}
else if(attrID.equals("dataproperties")){
dataPropList = (getTermList(html.item(i)));
dataProp = (nodeToString(html.item(i)));
dataProp = dataProp.replace("<h2>"+langFile.getProperty("dataProp")+"</h2>", "<h3 id=\"dataproperties\" class=\"list\">"+langFile.getProperty("dataProp")+"</h3>");
}
else if(attrID.equals("annotationproperties")){
annotationPropList = (getTermList(html.item(i)));
annotationProp = (nodeToString(html.item(i)));
annotationProp = annotationProp.replace("<h2>"+langFile.getProperty("annProp")+"</h2>", "<h3 id=\"annotationproperties\" class=\"list\">"+langFile.getProperty("annProp")+"</h3>");
}
else if(attrID.equals("namedindividuals")){
namedIndividualList = (getTermList(html.item(i)));
namedIndividuals = (nodeToString(html.item(i)));
namedIndividuals = namedIndividuals.replace("<h2>"+langFile.getProperty("namedIndiv")+"</h2>", "<h3 id=\"namedindividuals\" class=\"list\">"+langFile.getProperty("namedIndiv")+"</h3>");
}
else if(attrID.equals("namespacedeclarations")){
Node namespace = html.item(i);
Expand Down
Loading

0 comments on commit 5b10a41

Please sign in to comment.