Skip to content

Commit

Permalink
added conditional display of license and reasoner info from config fi…
Browse files Browse the repository at this point in the history
…le for EBISPOT#474
  • Loading branch information
Erhun Giray Tuncay committed Jan 6, 2022
1 parent e6a26f4 commit 99a886c
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 7 deletions.
28 changes: 23 additions & 5 deletions ols-web/src/main/resources/templates/ontology.html
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,35 @@ <h4 th:inline="text">[[${ontologyAlias}]] information</h4>
<div th:each="creator : ${ontologyDocument.getConfig().getCreators()}">
<b>Creator: </b> <span th:text="${creator}">NCBI:9606</span>
</div>

<br/>

<div th:unless="${ontologyDocument.getConfig().getReasonerType() == T(uk.ac.ebi.spot.ols.util.ReasonerType).NONE}">
<b>Reasoner: </b> <span th:text="${ontologyDocument.getConfig().getReasonerType()}">NCBI_9606</span>
</div>

<div th:unless="${ontologyDocument.getConfig().getLicense().getLabel() == null}">
<b>License Label: </b> <span th:text="${ontologyDocument.getConfig().getLicense().getLabel()}">NCBI_9606</span>
</div>

<div th:unless="${ontologyDocument.getConfig().getLicense().getLogo() == null}">
<b>License Logo: </b>
<a th:href="${ontologyDocument.getConfig().getLicense().getLogo()}" th:text="${ontologyDocument.getConfig().getLicense().getLogo()}">License Logo</a>
</div>

<div th:unless="${ontologyDocument.getConfig().getLicense().getUrl() == null}">
<b>License URL: </b>
<a th:href="${ontologyDocument.getConfig().getLicense().getUrl()}" th:text="${ontologyDocument.getConfig().getLicense().getUrl()}">License URL</a>
</div>
<div th:each="annotations: ${ontologyDocument.getConfig().getAnnotations()}">
<b>
<a href="#"
th:href="@{../search(q=${annotations.key},exact='true', type=property, ontology=${ontologyDocument.getOntologyId()})}"
th:text="${annotations.key.replaceAll('_', ' ')}">property name</a>
</b>
<p style="margin-left:9px;" th:each="annovalue : ${annotations.value}"
th:text="${annovalue}">
NCBI_9606</p>
<p th:unless="${annotations.key.equals('license')}" style="margin-left:9px;" th:each="annovalue : ${annotations.value}" th:text="${annovalue}">NCBI_9606</p>
<div th:if="${annotations.key.equals('license')}" th:each="annovalue : ${annotations.value}">
<a th:unless="${annovalue.startsWith('http://') or annovalue.startsWith('https://')}" style="margin-left:9px;" th:href="'https://' + ${annovalue}" th:text="${annovalue}">NCBI_9606</a>
<a th:if="${annovalue.startsWith('http://') or annovalue.startsWith('https://')}" style="margin-left:9px;" th:href="${annovalue}" th:text="${annovalue}">NCBI_9606</a>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package uk.ac.ebi.spot.ols.config;


import uk.ac.ebi.spot.ols.util.License;
import uk.ac.ebi.spot.ols.util.ReasonerType;

import java.net.URI;
Expand Down Expand Up @@ -47,6 +48,7 @@ public class OntologyResourceConfig {
private boolean isSkos;

private boolean allowDownload;
private License license;

// these are any metadata properties for the ontology, such as title or definition that are included in the ontology as OWL ontology annotation
private Collection<String> internalMetadataProperties;
Expand All @@ -58,7 +60,7 @@ public OntologyResourceConfig(String id, String versionIri, String title, String
Collection<URI> synonymProperties, Collection<URI> hierarchicalProperties,
Collection<String> baseUris, Collection<URI> hiddenProperties, boolean isSkos,
Collection<String> internalMetadataProperties, Collection<URI> preferredRootTerms,
boolean allowDownload) {
boolean allowDownload, License license) {
this.id = id;
this.versionIri = versionIri;
this.title = title;
Expand All @@ -84,6 +86,7 @@ public OntologyResourceConfig(String id, String versionIri, String title, String
this.internalMetadataProperties = internalMetadataProperties;
this.preferredRootTerms = preferredRootTerms;
this.allowDownload = allowDownload;
this.license = license;
}

public OntologyResourceConfig() {
Expand Down Expand Up @@ -116,6 +119,7 @@ private OntologyResourceConfig(OntologyResourceConfigBuilder builder) {
this.internalMetadataProperties = builder.internalMetadatProperties;
this.preferredRootTerms = builder.preferredRootTerms;
this.allowDownload = builder.allowDownload;
this.license = builder.license;
}

public void setId(String id) {
Expand Down Expand Up @@ -328,6 +332,14 @@ public boolean getAllowDownload() {
public void setAllowDownload(boolean allowDownload) {
this.allowDownload = allowDownload;
}

public License getLicense() {
return this.license;
}

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

public static class OntologyResourceConfigBuilder {
private String id;
Expand Down Expand Up @@ -356,6 +368,7 @@ public static class OntologyResourceConfigBuilder {
private Collection<String> internalMetadatProperties = Collections.emptySet();
private Collection<URI> preferredRootTerms = Collections.emptySet();
private boolean allowDownload = true;
private License license;

public OntologyResourceConfigBuilder(String id, String title, String namespace, URI fileLocation) {
this.id = id;
Expand Down Expand Up @@ -492,6 +505,10 @@ public void setPreferredRootTerms(Collection<URI> preferredRootTerms) {
public void setAllowDownload(boolean allowDownload) {
this.allowDownload = allowDownload;
}

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

public OntologyResourceConfig build() {
return new OntologyResourceConfig(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public enum OntologyResourceConfigEnum {
LOGO("logo"),
CREATOR("creator"),
PREFERRED_ROOT_TERM("preferred_root_term"),
ALLOW_DOWNLOAD("allow_download");
ALLOW_DOWNLOAD("allow_download"),
LICENSE("license");

private final String propertyName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.ac.ebi.spot.ols.exception.ConfigParsingException;
import uk.ac.ebi.spot.ols.util.License;
import uk.ac.ebi.spot.ols.util.ReasonerType;

import java.net.URI;
Expand Down Expand Up @@ -80,6 +81,7 @@ public OntologyResourceConfig getConfiguration() throws ConfigParsingException {
populateCreator(builder);
populatePreferredRootTerms(builder);
populateAllowDownload(builder);
populateLicense(builder);

return builder.build();
}
Expand Down Expand Up @@ -279,4 +281,16 @@ private void populateAllowDownload(OntologyResourceConfig.OntologyResourceConfig
builder.setAllowDownload(true);
}
}

private void populateLicense(OntologyResourceConfig.OntologyResourceConfigBuilder builder) {
if (ontology.containsKey(LICENSE.getPropertyName())) {
License license = new License();
license.setLabel((String) ((Map<String, Object>) ontology.get(LICENSE.getPropertyName())).get("label"));
license.setLogo((String) ((Map<String, Object>) ontology.get(LICENSE.getPropertyName())).get("logo"));
license.setUrl((String) ((Map<String, Object>) ontology.get(LICENSE.getPropertyName())).get("url"));
builder.setLicense(license);
} else {
builder.setLicense(new License());
}
}
}
49 changes: 49 additions & 0 deletions ontology-tools/src/main/java/uk/ac/ebi/spot/ols/util/License.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package uk.ac.ebi.spot.ols.util;

public class License {

String url;
String logo;
String label;

public License() {}

public License(String url, String logo, String label) {
super();
this.url = url;
this.logo = logo;
this.label = label;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public String getLogo() {
return logo;
}

public void setLogo(String logo) {
this.logo = logo;
}

public String getLabel() {
return label;
}

public void setLabel(String label) {
this.label = label;
}

@Override
public String toString() {
return "License [url=" + url + ", logo=" + logo + ", label=" + label + "]";
}



}

0 comments on commit 99a886c

Please sign in to comment.