Skip to content

Commit

Permalink
Fix #648
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarijo committed Apr 2, 2024
1 parent 4f26e51 commit 4b96b33
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 54 deletions.
4 changes: 2 additions & 2 deletions doc/bestPractices/sections/checklist-en.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h5>Example:</h5>
@prefix rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
@prefix vann: &lt;http://purl.org/vocab/vann/&gt; .
&lt;https://w3id.org/example&gt; rdf:type owl:Ontology ;
vann:preferredNamespaceUri "https://w3id.org/example" .
vann:preferredNamespaceUri &lt;https://w3id.org/example#&gt; .
</pre>

<h4 class="list" id="prefix">Prefix [<em class="rfc2119" title="RECOMMENDED">RECOMMENDED</em>]</h4>
Expand Down Expand Up @@ -698,7 +698,7 @@ <h5>Example:</h5>

<h4 class="list" id="status1">Status [<em class="rfc2119" title="OPTIONAL">OPTIONAL</em>]</h4>
<p>
Property indicating the usage status of the term. For example, whether the term is mature enough, whether it has been deprecated, curated, etc. Note that some of the properties proposed below, such as obo:IAO_0000114, have as range a set of fixed values. The <a href="https://github.com/UKGovLD/registry-core/wiki/Principles-and-concepts#status-and-life-cycle">registry vocabulary</a> proposes a hierarchy of status that may be used to represent terms as well (reg:statusAccepted, reg:statusValid, reg:statusDeprecated, etc.).
Property indicating the usage status of the term. For example, whether the term is mature enough, whether it has been deprecated, curated, etc. Note that some of the properties proposed below, such as obo:IAO_0000114, have as range a set of fixed values. The <a href="https://github.com/UKGovLD/registry-core/wiki/Principles-and-concepts#status-and-life-cycle">registry vocabulary</a> proposes a hierarchy of status that may be used to represent terms as well (reg:statusAccepted, reg:statusValid, reg:statusDeprecated, etc.).
</p>

<ul class="hlist"><strong>Properties you may use</strong>:
Expand Down
9 changes: 6 additions & 3 deletions doc/configuration/config.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

abstract=An example ontology
backwardCompatibleWith=https://w3id.org/example/1.0.0
citeAs="add some citattion text here."
citeAs="add some citation text here."
dateCreated="13 Nov, 2022"
dateModified="15 Nov, 2022"
authors=First Author;Second Author
Expand All @@ -16,10 +16,11 @@ description="A description of what the ontology does goes here"
diagram="https://example.org/diagram.svg"
DOI=
funders=
fundingGrants=
funding=
incompatibleWith=
issued=
images=image1.png;image2.png
introduction="This is some introduction text"
issued=
licenseURI=http://creativecommons.org/licenses/by/2.0/
licenseName=CC-BY
licenseIconURL=https://i.creativecommons.org/l/by/2.0/88x31.png
Expand All @@ -45,3 +46,5 @@ extendedOntologyURIs=http://example.org/test1; http://example.org/test2
RDFXMLSerialization=ontology.xml
TurtleSerialization=ontology.ttl
NTSerialization=ontology.nt
pathToOverview=overview.html
pathToReferences=references.html
37 changes: 21 additions & 16 deletions doc/configuration/configuration_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,63 @@ In order to have Widoco accept a configuration file, you need to create a `confi

```
abstract=An example ontology
backwardCompatibleWith=https://w3id.org/example/1.0.0
citeAs="add some citattion text here."
dateCreated="13 Nov, 2022"
dateIssued=
dateModified="15 Nov, 2022"
authors=First Author;Second Author
authorsURI=http://example.org/author1;http://example.org/author2
authorsInstitution=First author institution;Second author institution
authorsInstitutionURI=https://www.isi.edu/;https://www.isi.edu/
backwardCompatibleWith=https://w3id.org/example/1.0.0
citeAs="add some citattion text here."
contributors=First contributor;Second contributor
contributorsURI=http://example.org/contributor1;http://example.org/contributor2
contributorsInstitution=First contributor institution;Second contributor institution
contributorsInstitutionURI=https://isi.edu/;https://isi.edu/
dateCreated="13 Nov, 2022"
dateIssued=
dateModified="15 Nov, 2022"
description="A description of what the ontology does goes here"
diagram="https://example.org/diagram.svg"
DOI=
funder=
fundingGrant=
funding=
incompatibleWith=
introduction=A brief text for the introduction section may be written here.
images=image1.png;image2.png
licenseURI=http://creativecommons.org/licenses/by/2.0/
licenseName=CC-BY
licenseIconURL=https://i.creativecommons.org/l/by/2.0/88x31.png
logo="https://example.org/logo.svg"
ontologyName=Example
ontologyPrefix=exo
ontologyNamespaceURI=https://w3id.org/example
ontologyRevisionNumber=1.0.0
ontologyTitle=The Example Ontology
ontologyPrefix=exo
previousVersionURI=https://w3id.org/example/1.0.0
publisher=Ontology Engineering Group
publisherURI=https://oeg-upm.es
publisherInstitution=UPM
publisherInstitutionURI=https://www.upm.es
source=http://source1;http://source2
seeAlso=http://firstResource
ontologyTitle=The Example Ontology
thisVersionURI=https://w3id.org/example/1.0.1
ontologyRevisionNumber=v1.0.0
status=Ontology Specification Draft
```

Additional configuration options include the following
```
importedOntologyNames=Imported Ontology 1; Imported Ontology 2
importedOntologyURIs=http://example.org/test11; http://example.org/test22
contextURI=JSON-LD context URI.
extendedOntologyNames=test1; test2
extendedOntologyURIs=http://example.org/test1; http://example.org/test2
importedOntologyNames=Imported Ontology 1; Imported Ontology 2
importedOntologyURIs=http://example.org/test11; http://example.org/test22
pathToAbstract=abstract.html (superseedes abstract)
pathToDescription=description.html (superseedes description)
pathToIntro=intro.html (supersedes introduction)
pathToOverview=overview.html
pathToReferences=references.html
GoogleAnalyticsCode=UA-TestCodeGoesHere
JSONLDSerialization=URL of the file with JSON-LD serialization. E.g., http://my-onto/onto.jsonld
NTSerialization=URL of the file with N3 serialization. E.g., http://my-onto/onto.n3
RDFXMLSerialization=URL of the file with RDF-XML serialization. E.g., http://my-onto/onto.owl
TurtleSerialization=URL of the file with Turtle serialization. E.g., http://my-onto/onto..ttl;
NTSerialization=URL of the file with N3 serialization. E.g., http://my-onto/onto.n3
JSONLDSerialization=URL of the file with JSON-LD serialization. E.g., http://my-onto/onto.jsonld
GoogleAnalyticsCode=UA-TestCodeGoesHere
contextURI=JSON-LD context URI.
```

For more information, see the [Widoco readme options](https://github.com/dgarijo/Widoco/#options).
Expand Down
1 change: 0 additions & 1 deletion doc/configurationSamples/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion doc/configurationSamples/config/config.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

abstract=An example ontology
backwardCompatibleWith=https://w3id.org/example/1.0.0
citeAs="add some citattion text here."
citeAs="add some citation text here."
creationDate="13 Nov, 2022"
authors=First Author;Second Author
authorsURI=http://example.org/author1;http://example.org/author2
Expand Down
33 changes: 20 additions & 13 deletions doc/metadataGuide/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,27 +212,27 @@ Create a `config.properties` file and use the `-confFile` option to invoke Widoc

```
abstract=An example ontology
backwardCompatibleWith=https://w3id.org/example/1.0.0
citeAs="add some citattion text here."
authors=First Author;Second Author
authorsURI=http://example.org/author1;http://example.org/author2
authorsInstitution=First author institution;Second author institution
authorsInstitutionURI=https://www.isi.edu/;https://www.isi.edu/
backwardCompatibleWith=https://w3id.org/example/1.0.0
citeAs="add some citattion text here."
contributors=First contributor;Second contributor
contributorsURI=http://example.org/contributor1;http://example.org/contributor2
contributorsInstitution=First contributor institution;Second contributor institution
contributorsInstitutionURI=https://isi.edu/;https://isi.edu/
description=A description of what the ontology does goes here
dateCreated="13 Nov, 2022"
dateIssued="14 Nov, 2022"
dateModified="15 April, 2023"
diagram="https://example.org/diagram.svg"
description=A description of what the ontology does goes here
extendedOntologyNames=test1; test2
extendedOntologyURIs=http://example.org/test1; http://example.org/test2
DOI=https://dx.doi.org/SOME/DOI
funder=https://example.org/institution
funding=https://example.org/fundingGrant
incompatibleWith=https://w3id.org/example/0.0.1
images=image1.png;image2.png
importedOntologyNames=Imported Ontology 1; Imported Ontology 2
importedOntologyURIs=http://example.org/test11; http://example.org/test22
introduction=A brief text for the introduction section may be written here.
Expand All @@ -241,21 +241,28 @@ licenseName=CC-BY
licenseIconURL=https://i.creativecommons.org/l/by/2.0/88x31.png
logo="https://example.org/logo.svg"
ontologyName=The Cohort Ontology
ontologyPrefix=exo
ontologyNamespaceURI=https://w3id.org/example
previousVersionURI=https://w3id.org/example/1.0.0
publisher=
publisherURI=
publisherInstitution=
publisherInstitutionURI=
ontologyTitle=The Example Ontology
ontologyPrefix=exo
ontologyRevisionNumber=1.0.0
pathToAbstract=abstract.html (superseedes abstract)
pathToDescription=description.html (superseedes description)
pathToIntro=intro.html (supersedes introduction)
pathToOverview=overview.html
pathToReferences=references.html
previousVersionURI=https://w3id.org/example/1.0.0
publisher=Ontology Engineering Group
publisherURI=https://oeg-upm.es
publisherInstitution=UPM
publisherInstitutionURI=https://www.upm.es
thisVersionURI=https://w3id.org/example/1.0.1
ontologyRevisionNumber=v1.0.0
source=http://source1;http://source2
seeAlso=http://firstResource
status=Ontology Specification Draft
JSONLDSerialization=ontology.nt
NTSerialization=ontology.nt
RDFXMLSerialization=ontology.xml
TurtleSerialization=ontology.ttl
NTSerialization=ontology.nt
JSONLDSerialization=ontology.nt
```

## Glossary (<a href="#table">Back to table</a>)
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/lode/LODEGeneration.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.HashSet;
import java.util.Set;
import javax.xml.transform.Transformer;
Expand Down Expand Up @@ -61,7 +62,7 @@ public static String getLODEhtml(Configuration c, File lodeResources) throws Exc

String content = "";
String lang = c.getCurrentLanguage();
if (lang == null || "".equals(lang)) {
if (lang == null || lang.isEmpty()) {
lang = "en";
}
// we have stored the ontology locally
Expand Down Expand Up @@ -318,7 +319,7 @@ private static String applyXSLTTransformation(String source, String ontologyUrl,

transformer.transform(inputSource, new StreamResult(output));

return output.toString("UTF-8").replace("any u r i", "anyURI");
return output.toString(StandardCharsets.UTF_8).replace("any u r i", "anyURI");
}

}
34 changes: 19 additions & 15 deletions src/main/java/widoco/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private void loadPropertyFile(String path) throws IOException {
mainOntologyMetadata.setPublisher(publisher);
String aux = propertyFile.getProperty(Constants.PF_AUTHORS, "");
String[] names, urls, authorInst, authorInstURI;
if (!aux.equals("")) {
if (!aux.isEmpty()) {
names = aux.split(";");
aux = propertyFile.getProperty(Constants.PF_AUTHORS_URI, "");
urls = aux.split(";");
Expand Down Expand Up @@ -289,7 +289,7 @@ private void loadPropertyFile(String path) throws IOException {
}
}
aux = propertyFile.getProperty(Constants.PF_CONTRIBUTORS, "");
if (!aux.equals("")) {
if (!aux.isEmpty()) {
names = aux.split(";");
aux = propertyFile.getProperty(Constants.PF_CONTRIBUTORS_URI, "");
urls = aux.split(";");
Expand Down Expand Up @@ -406,7 +406,11 @@ private void loadPropertyFile(String path) throws IOException {
if (!"".equals(funding)){
mainOntologyMetadata.setFundingGrants(new ArrayList<String>(Arrays.asList(funding.split(";"))));
}

this.setAbstractPath(propertyFile.getProperty(Constants.PF_ABSTRACT_PATH, null));
this.setDescriptionPath(propertyFile.getProperty(Constants.PF_DESCRIPTION_PATH, null));
this.setIntroductionPath(propertyFile.getProperty(Constants.PF_INTRO_PATH, null));
this.setOverviewPath(propertyFile.getProperty(Constants.PF_OVERVIEW_PATH, null));
this.setReferencesPath(propertyFile.getProperty(Constants.PF_REFERENCES_PATH, null));
} catch (IOException ex) {
// Only a warning, as we can continue safely without a property file.
logger.warn("Error while reading configuration properties from [" + path + "]: " + ex.getMessage());
Expand Down Expand Up @@ -486,14 +490,14 @@ public void loadPropertiesFromOntology(OWLOntology o) {
mainOntologyMetadata.getLicense().setName(licName);
}
}
if (this.mainOntologyMetadata.getName() == null || this.mainOntologyMetadata.getName().equals("")) {
if (this.mainOntologyMetadata.getName() == null || this.mainOntologyMetadata.getName().isEmpty()) {
this.mainOntologyMetadata.setName(mainOntologyMetadata.getTitle());
}
if (mainOntologyMetadata.getStatus() == null || mainOntologyMetadata.getStatus().equals("")) {
if (mainOntologyMetadata.getStatus() == null || mainOntologyMetadata.getStatus().isEmpty()) {
mainOntologyMetadata.setStatus("Ontology Specification Draft");
}
// default name if no annotations are found
if (mainOntologyMetadata.getName() == null || mainOntologyMetadata.getName().equals("")) {
if (mainOntologyMetadata.getName() == null || mainOntologyMetadata.getName().isEmpty()) {
this.mainOntologyMetadata.setName("[Ontology Name]");
}
// default citation if none is given
Expand Down Expand Up @@ -522,7 +526,7 @@ public void loadNamespaceDeclarations(OWLOntology o){
OWLOntologyXMLNamespaceManager nsManager = new OWLOntologyXMLNamespaceManager(o, o.getFormat());
for (String prefix : nsManager.getPrefixes()) {
String namespaceURI = nsManager.getNamespaceForPrefix(prefix);
if ("".equals(prefix) || namespaceURI.equals(mainOntologyMetadata.getNamespaceURI())){
if (prefix.isEmpty() || namespaceURI.equals(mainOntologyMetadata.getNamespaceURI())){
namespaceDeclarations.put(mainOntologyMetadata.getNamespacePrefix(),namespaceURI);
}else{
namespaceDeclarations.put(prefix,nsManager.getNamespaceForPrefix(prefix));
Expand All @@ -531,7 +535,7 @@ public void loadNamespaceDeclarations(OWLOntology o){
}

private String appendDetails(final String detail, final String prefix, final boolean useFullStop) {
if (detail == null || detail.equals("")) {
if (detail == null || detail.isEmpty()) {
return "";
}

Expand Down Expand Up @@ -581,7 +585,7 @@ private void completeOntologyMetadata(OWLAnnotation a, OWLOntology o) {
valueLanguage = a.getValue().asLiteral().get().getLang();
value = a.getValue().asLiteral().get().getLiteral();
if (this.currentLanguage.equals(valueLanguage)
|| (abstractSection == null || "".equals(abstractSection))) {
|| (abstractSection == null || abstractSection.isEmpty())) {
abstractSection = value;
this.setIncludeAbstract(true); // in case users set no place holder text but added their own
}
Expand Down Expand Up @@ -689,11 +693,11 @@ private void completeOntologyMetadata(OWLAnnotation a, OWLOntology o) {
o.getAnnotationAssertionAxioms(valueURI).stream().forEach(i -> {
completeAgentMetadata(i, ag, o);
});
if(ag.getName()==null || ag.getName().equals("")){
if(ag.getName()==null || ag.getName().isEmpty()){
//the value does not have annotations, so we keep it as it is.
ag.setName(valueURI.getIRIString());
}
if(ag.getURL()==null || ag.getURL().equals("")){
if(ag.getURL()==null || ag.getURL().isEmpty()){
ag.setURL(valueURI.getIRIString());
}
}
Expand Down Expand Up @@ -826,7 +830,7 @@ private void completeOntologyMetadata(OWLAnnotation a, OWLOntology o) {
valueLanguage = a.getValue().asLiteral().get().getLang();
value = a.getValue().asLiteral().get().getLiteral();
if (this.currentLanguage.equals(valueLanguage)
|| (introText == null || "".equals(introText))) {
|| (introText == null || introText.isEmpty())) {
introText = value;
this.setIncludeIntroduction(true);
}
Expand Down Expand Up @@ -937,11 +941,11 @@ private void completeAgentMetadata(OWLAnnotationAssertionAxiom ann, Agent ag, OW
o.getAnnotationAssertionAxioms(valueURI).stream().forEach(i -> {
completeAgentMetadata(i,aux,o);
});
if(aux.getName()==null || aux.getName().equals("")){
if(aux.getName()==null || aux.getName().isEmpty()){
//the value does not have annotations, so we keep it as it is.
aux.setName(valueURI.getIRIString());
}
if(aux.getURL()==null || aux.getURL().equals("")){
if(aux.getURL()==null || aux.getURL().isEmpty()){
aux.setURL(valueURI.getIRIString());
}
}
Expand Down Expand Up @@ -1267,7 +1271,7 @@ public void setIncludeNamedIndividuals(boolean includeNamedIndividuals) {
public void addLanguageToGenerate(String lang) {
if (!this.languages.containsKey(lang)) {
this.languages.put(lang, false);
if (currentLanguage.equals("")) {
if (currentLanguage.isEmpty()) {
currentLanguage = lang;
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/widoco/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ public class Constants {
public static final String PF_SERIALIZATION_JSON = "JSONLDSerialization";
public static final String PF_SERIALIZATION_RDF = "RDFXMLSerialization";
public static final String PF_SERIALIZATION_TTL = "TurtleSerialization";
public static final String PF_ABSTRACT_PATH = "pathToAbstract";
public static final String PF_INTRO_PATH = "pathToIntro";
public static final String PF_DESCRIPTION_PATH = "pathToDescription";
public static final String PF_OVERVIEW_PATH = "pathToOverview";
public static final String PF_REFERENCES_PATH = "pathToReferences";

/*OWL_API RDF Serializations*/
public static final String RDF_XML = "RDF/XML";
Expand Down Expand Up @@ -568,7 +573,7 @@ private static String getOntologies(ArrayList<Ontology> ontos) {
while (it.hasNext()) {
Ontology currentOnto = it.next();
String currentOntoName = currentOnto.getName();
if (currentOntoName == null || "".equals(currentOntoName)) {
if (currentOntoName == null || currentOntoName.isEmpty()) {
currentOntoName = "Onto" + i;
i++;
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/widoco/gui/GuiStep3.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ private void initializeGUI(){
checkBoxWebVowl.setSelected(true);
checkBoxAutomatedChangeLog.setSelected(true);
if(g.getConfig().getGoogleAnalyticsCode()!=null)analyticsField.setText(g.getConfig().getGoogleAnalyticsCode());
abstractPath = g.getConfig().getAbstractPath();
introductionPath = g.getConfig().getIntroductionPath();
descriptionPath = g.getConfig().getDescriptionPath();
overviewPath = g.getConfig().getOverviewPath();
referencesPath = g.getConfig().getReferencesPath();
}

/** This method is called from within the constructor to
Expand Down

0 comments on commit 4b96b33

Please sign in to comment.