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 Jul 6, 2016
2 parents 9cb2863 + d6ff8b4 commit 23deacf
Show file tree
Hide file tree
Showing 19 changed files with 476 additions and 174 deletions.
7 changes: 5 additions & 2 deletions ConfigSamples/config/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ licenseName=License name. E.g.: Creative Commons Attribution-NonCommercial-Share
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.
deafultSerialization=RDF/XML
status=Ontology Draft
status=Ontology Draft
deafultSerialization=RDF/XMLRDFXMLSerialization=http://vocab.linkeddata.es/p-plan/p-plan.owl
TurtleSerialization=
N3Serialization=
JSONLDSerialization=
2 changes: 1 addition & 1 deletion ConfigSamples/sampleConsoleExecution.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java -jar widoco-0.0.1-jar-with-dependencies.jar -ontURI http://ontosoft.org/software# -outFolder doc -confFile ./config/ontosoft.properties -rewriteAll -useCustomStyle -lang en;es
java -jar widoco-1.0.1-jar-with-dependencies.jar -ontURI http://ontosoft.org/software# -outFolder doc -confFile ./config/ontosoft.properties -rewriteAll -useCustomStyle -lang en;es -includeImportedOntologies -htaccess
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ The structure of the template is as follows:

How to use Widoco
==========
Download all the JAR and configuraiton samples into the same folder (the JAR is available on the release tab in Github: https://github.com/dgarijo/Widoco/releases). Then just double click the .jar file.
Download all the files of the "JAR" folder into the same folder. Then just double click the .jar file.

For customizing the metadata of your ontology, edit the project properties of /config/config.properties.

The character ";" is used for lists (for instance first author; second author; third author).

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

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

Expand All @@ -69,6 +69,8 @@ The -lang option allows showing the languages in which the documentation will be

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

The -htaccess flag creates a bundle for publication ready to be deployed on your apache server.

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
6 changes: 2 additions & 4 deletions src/main/java/licensius/GetLicense.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@
package licensius;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import widoco.TextConstants;

/**
Expand All @@ -35,9 +32,10 @@
* Integrated by Daniel Garijo
*/
public class GetLicense {

// hay que hacer un post! POST /license/findlicenseinrdf

public static String getTitle(String uriToScan) {

String output="unknown";
try {
String uri=TextConstants.licensiusURIServiceLicenseInfo;
Expand Down
156 changes: 104 additions & 52 deletions src/main/java/widoco/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ public class Configuration {
private String revision;
private ArrayList<Ontology> importedOntologies;
private ArrayList<Ontology> extendedOntologies;
private Ontology mainOntology;
private License license;
private Ontology mainOntologyMetadata;

private String ontologyPath;
/**
* Path where the documentation will be generated.
*/
private String documentationURI;
private String title;
private String releaseDate;
private String status; //status of the ontology: draft, official release, etc
private String vocabSerialization ="";
// private String vocabLoadedSerialization ="";//serialization of the vocabulary loaded by Widoco

private boolean fromFile;//if this is true, the onto will be from a file. otherwise it's a URI

Expand Down Expand Up @@ -113,6 +116,11 @@ public class Configuration {
//add imported ontologies in the doc as well
private boolean addImportedOntologies;
private File tmpFolder; //file where different auxiliary resources might be copied to
private boolean createHTACCESS;


private OntModel mainOntologyModel;//model of the mainOntology. Loaded separately
//because the ontology metadata may not exist when the model is read

//model everything as a singleton object. No need: only the controller accesses this file.
public Configuration() {
Expand Down Expand Up @@ -155,13 +163,19 @@ public void cleanConfig(){
importedOntologies = new ArrayList<Ontology>();
extendedOntologies = new ArrayList<Ontology>();
//this has to be checked because we might delete the uri of the onto from a previous step.
if(mainOntology==null){
mainOntology = new Ontology();
mainOntology.setName("");
mainOntology.setNamespacePrefix("");
mainOntology.setNamespaceURI("");
if(mainOntologyMetadata==null){
mainOntologyMetadata = new Ontology();
mainOntologyMetadata.setName("");
mainOntologyMetadata.setNamespacePrefix("");
mainOntologyMetadata.setNamespaceURI("");
License l = new License();
mainOntologyMetadata.setLicense(l);
mainOntologyMetadata.setSerializations(new HashMap<String, String>());
//add default serializations: rdf/xml, n3 and turtle
mainOntologyMetadata.addSerialization("RDF/XML", "ontology.xml");
mainOntologyMetadata.addSerialization("TTL", "ontology.ttl");
mainOntologyMetadata.addSerialization("N-Triples", "ontology.n3");
}
license = new License();
citeAs = "";
publishProvenance = true;
includeAbstract = true;
Expand All @@ -181,6 +195,7 @@ public void cleanConfig(){
error = "";
addImportedOntologies = false;
status = "";
createHTACCESS = false;
}

private void loadConfigPropertyFile(String path){
Expand All @@ -195,9 +210,9 @@ private void loadConfigPropertyFile(String path){
previousVersion =propertyFile.getProperty(TextConstants.previousVersionURI);
thisVersion =propertyFile.getProperty(TextConstants.thisVersionURI);
latestVersion =propertyFile.getProperty(TextConstants.latestVersionURI);
mainOntology.setName(propertyFile.getProperty(TextConstants.ontName));
mainOntology.setNamespacePrefix(propertyFile.getProperty(TextConstants.ontPrefix));
mainOntology.setNamespaceURI(propertyFile.getProperty(TextConstants.ontNamespaceURI));
mainOntologyMetadata.setName(propertyFile.getProperty(TextConstants.ontName));
mainOntologyMetadata.setNamespacePrefix(propertyFile.getProperty(TextConstants.ontPrefix));
mainOntologyMetadata.setNamespaceURI(propertyFile.getProperty(TextConstants.ontNamespaceURI));
revision = propertyFile.getProperty(TextConstants.ontologyRevision);
String aux = propertyFile.getProperty(TextConstants.authors,"");
String[]names,urls,authorInst;
Expand Down Expand Up @@ -278,12 +293,28 @@ private void loadConfigPropertyFile(String path){
extendedOntologies.add(o);
}
}
license.setName(propertyFile.getProperty(TextConstants.licenseName,""));
license.setUrl(propertyFile.getProperty(TextConstants.licenseURI,""));
license.setIcon(propertyFile.getProperty(TextConstants.licenseIconURL,""));
mainOntologyMetadata.getLicense().setName(propertyFile.getProperty(TextConstants.licenseName,""));
mainOntologyMetadata.getLicense().setUrl(propertyFile.getProperty(TextConstants.licenseURI,""));
mainOntologyMetadata.getLicense().setIcon(propertyFile.getProperty(TextConstants.licenseIconURL,""));
status = propertyFile.getProperty(TextConstants.status,"Specification Draft");
citeAs = propertyFile.getProperty(TextConstants.citeAs, "");
vocabSerialization = propertyFile.getProperty(TextConstants.deafultSerialization, "RDF/XML");
//vocabLoadedSerialization = propertyFile.getProperty(TextConstants.deafultSerialization, "RDF/XML");
String serializationRDFXML = propertyFile.getProperty(TextConstants.rdf,"");
if(!"".equals(serializationRDFXML)){
mainOntologyMetadata.addSerialization("RDF/XML", serializationRDFXML);
}
String serializationTTL = propertyFile.getProperty(TextConstants.ttl,"");
if(!"".equals(serializationTTL)){
mainOntologyMetadata.addSerialization("TTL", serializationTTL);
}
String serializationN3 = propertyFile.getProperty(TextConstants.n3,"");
if(!"".equals(serializationN3)){
mainOntologyMetadata.addSerialization("N-Triples", serializationN3);
}
String serializationJSONLD = propertyFile.getProperty(TextConstants.json,"");
if(!"".equals(serializationJSONLD)){
mainOntologyMetadata.addSerialization("JSON-LD", serializationJSONLD);
}
} catch (Exception ex) {
System.err.println("Error while reading configuration properties "+ex.getMessage());
}
Expand All @@ -296,14 +327,14 @@ public void loadPropertiesFromOntology(OntModel m){
return;
}
cleanConfig();
this.mainOntology.setName("[Ontology Name]");
this.mainOntology.setNamespacePrefix("[Ontology NS Prefix]");
this.mainOntology.setNamespaceURI("[Ontology URI]");
this.mainOntologyMetadata.setName("[Ontology Name]");
this.mainOntologyMetadata.setNamespacePrefix("[Ontology NS Prefix]");
this.mainOntologyMetadata.setNamespaceURI("[Ontology URI]");
//we assume only one ontology per file.
try{
OntResource onto = m.getOntClass("http://www.w3.org/2002/07/owl#Ontology").listInstances().next();
this.mainOntology.setNamespaceURI(onto.getURI());
this.mainOntology.setName(onto.getLocalName());
this.mainOntologyMetadata.setNamespaceURI(onto.getURI());
this.mainOntologyMetadata.setName(onto.getLocalName());
Iterator it = onto.listProperties();//model.getResource("http://purl.org/net/wf-motifs").listProperties();
String propertyName, value;
while(it.hasNext()){
Expand All @@ -317,7 +348,7 @@ public void loadPropertiesFromOntology(OntModel m){
// System.out.println(propertyName + " " + value);
// fill in the properties here.
if(propertyName.equals("label")){
this.mainOntology.setName(value);
this.mainOntologyMetadata.setName(value);
}else
if(propertyName.equals("abstract")){
this.abstractSection = value;
Expand All @@ -332,20 +363,21 @@ public void loadPropertiesFromOntology(OntModel m){
this.revision = value;
}else
if(propertyName.equals("preferredNamespacePrefix")){
this.mainOntology.setNamespacePrefix(value);
this.mainOntologyMetadata.setNamespacePrefix(value);
}else
if(propertyName.equals("preferredNamespaceUri")){
this.mainOntology.setNamespaceURI(value);
this.mainOntologyMetadata.setNamespaceURI(value);
}else
//we deal with the license by invoking the licensius service
//(only if we cannot find it)
if(propertyName.equals("license")){
this.license = new License();
License l = new License();
if(isURL(value)){
this.license.setUrl(value);
l.setUrl(value);
}else{
license.setName(value);
l.setName(value);
}
mainOntologyMetadata.setLicense(l);
}else
if(propertyName.equals("creator")||propertyName.equals("contributor")){
Agent g = new Agent();
Expand Down Expand Up @@ -383,24 +415,24 @@ public void loadPropertiesFromOntology(OntModel m){
}
//to do: if property is comment and abstract is null, then complete abstract.
}
if(this.mainOntology.getName()==null || this.mainOntology.getName().equals("")){
this.mainOntology.setName(this.title);
if(this.mainOntologyMetadata.getName()==null || this.mainOntologyMetadata.getName().equals("")){
this.mainOntologyMetadata.setName(this.title);
}
if(this.status==null || this.status.equals("")){
this.status = "Ontology Specification Draft";
}
}catch(Exception e){
System.err.println("No ontology declared. Ignoring properties");
}
//refine license from licensius
String licName = null;
String lic = GetLicense.getFirstLicenseFound(mainOntology.getNamespaceURI());
if (!lic.isEmpty()&& !lic.equals("unknown"))
{
this.license.setUrl(lic);
licName = GetLicense.getTitle(lic);
this.license.setName(licName);
}
//refine license from licensius. This should be optional
// String licName = null;
// String lic = GetLicense.getFirstLicenseFound(mainOntologyMetadata.getNamespaceURI());
// if (!lic.isEmpty()&& !lic.equals("unknown"))
// {
// mainOntologyMetadata.getLicense().setUrl(lic);
// licName = GetLicense.getTitle(lic);
// mainOntologyMetadata.getLicense().setName(licName);
// }

System.out.println("Loaded properties from ontology");
}
Expand Down Expand Up @@ -445,6 +477,10 @@ public ArrayList<Agent> getCreators() {
return creators;
}

/**
* returns the path where the documentation will be generated.
* @return documentation path
*/
public String getDocumentationURI() {
return documentationURI;
}
Expand All @@ -462,20 +498,18 @@ public String getLatestVersion() {
return latestVersion;
}

public License getLicense() {
return license;
}


public Ontology getMainOntology() {
return mainOntology;
return mainOntologyMetadata;
}

public String getOntologyPath() {
return ontologyPath;
}

public String getOntologyURI() {
return this.mainOntology.getNamespaceURI();
return this.mainOntologyMetadata.getNamespaceURI();
}

public String getPreviousVersion() {
Expand Down Expand Up @@ -542,20 +576,18 @@ public void setLatestVersion(String latestVersion) {
this.latestVersion = latestVersion;
}

public void setLicense(License license) {
this.license = license;
}


public void setMainOntology(Ontology mainOntology) {
this.mainOntology = mainOntology;
this.mainOntologyMetadata = mainOntology;
}

public void setOntologyPath(String ontologyPath) {
this.ontologyPath = ontologyPath;
}

public void setOntologyURI(String ontologyURI) {
this.mainOntology.setNamespaceURI(ontologyURI);
this.mainOntologyMetadata.setNamespaceURI(ontologyURI);
}

public void setPreviousVersion(String previousVersion) {
Expand Down Expand Up @@ -867,11 +899,31 @@ public void setAddImportedOntologies(boolean addImportedOntologies) {
this.addImportedOntologies = addImportedOntologies;
}

public void setVocabSerialization(String vocabSerialization) {
this.vocabSerialization = vocabSerialization;
// public void setVocabSerialization(String vocabSerialization) {
// this.vocabLoadedSerialization = vocabSerialization;
// }
//
// public String getVocabSerialization() {
// return vocabLoadedSerialization;
// }

public boolean isCreateHTACCESS() {
return createHTACCESS;
}

public String getVocabSerialization() {
return vocabSerialization;
public void setCreateHTACCESS(boolean createHTACCESS) {
this.createHTACCESS = createHTACCESS;
}

public OntModel getMainModel() {
return mainOntologyModel;
}

public void setMainModel(OntModel model) {
this.mainOntologyModel = model;
}




}
1 change: 0 additions & 1 deletion src/main/java/widoco/CreateDocInThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public CreateDocInThread(Configuration c, GuiController g, File lodeTmpResources
}

public void run() {
//el false/true es por el path de la doc o la uri. Aclararse..
//use config to create doc. If null, return error.
try{
System.out.println("Generating doc. "+ c.getMainOntology().getNamespaceURI());
Expand Down
Loading

0 comments on commit 23deacf

Please sign in to comment.