Skip to content

Commit

Permalink
Merge branch 'EMC-349_improve_ObsProperty_templates' into 'develop'
Browse files Browse the repository at this point in the history
Resolve EMC-349 "Improve obsproperty templates"

Closes EMC-349

See merge request eip/catalogue!759
  • Loading branch information
hkhan38 committed Nov 7, 2024
2 parents cbef2e0 + 9de22f0 commit 5630139
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 29 deletions.
17 changes: 17 additions & 0 deletions fixtures/datastore/REV-1/399ed9b1-bf59-4d85-9832-ee4d29f49bfb.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"rawType": "application/gemini+json",
"state": "published",
"documentType": "GEMINI_DOCUMENT",
"permissions": {
"EDIT": [
"phtr"
],
"VIEW": [
"phtr", "public"
],
"DELETE": [
"phtr"
]
},
"catalogue": "eidc"
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public class SolrIndex {
private @Field List<String> keywordsProject;
private @Field List<String> keywordsTheme;
private @Field List<String> keywordsOther;
private @Field List<String> observedProperties;
private @Field List<String> observedPropertyValue;
private @Field List<String> observedPropertyTitle;
private @Field String licence;
private @Field String lineage;
private @Field String dataLevel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public SolrIndex generateIndex(GeminiDocument document) {
.setAuthorOrcid(grab(document.getAuthors(), ResponsibleParty::getNameIdentifier))
.setAuthorRor(grab(document.getAuthors(), ResponsibleParty::getOrganisationIdentifier))
.setKeywordsInstrument(grab(document.getKeywordsInstrument(), Keyword::getValue))
.setObservedProperties(grab(document.getObservedProperty(), ObservedProperty::getValue))
.setObservedPropertyValue(grab(document.getObservedProperty(), ObservedProperty::getValue))
.setObservedPropertyTitle(grab(document.getObservedProperty(), ObservedProperty::getTitle))
.setKeywordsPlace(grab(document.getKeywordsPlace(), Keyword::getValue))
.setKeywordsProject(grab(document.getKeywordsProject(), Keyword::getValue))
.setKeywordsTheme(grab(document.getKeywordsTheme(), Keyword::getValue))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public SolrQuery build(){
SolrQuery query = new SolrQuery()
.setQuery(term)
.setParam("defType", "edismax")
.setParam("qf", "title^50 description^25 keyword^5 lineage organisation individual surname altTitle resourceIdentifier identifier supplementalDescription supplementalName infrastructureCapabilities^2 keywordsParameters^5 observedProperties^10 operatingPeriod objectives^25 responsibleParties")
.setParam("qf", "title^50 description^25 keyword^5 lineage organisation individual surname altTitle resourceIdentifier identifier supplementalDescription supplementalName infrastructureCapabilities^2 keywordsParameters^5 observedPropertyTitle^10 observedPropertyValue^5 operatingPeriod objectives^25 responsibleParties")
.setParam("bq", "resourceStatus:Available^100, resourceStatus:Controlled^100, resourceStatus:Embargoed^80, resourceStatus:Restricted^80, resourceStatus:Superseded^1")
.setParam("bf", "version")
.setParam("ps", "5")
Expand Down
3 changes: 2 additions & 1 deletion solr/documents/conf/managed-schema
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
<field name="keywordsProject" type="keywords_lowercase"/>
<field name="keywordsTheme" type="keywords_lowercase"/>
<field name="keywordsOther" type="keywords_lowercase"/>
<field name="observedProperties" type="keywords_lowercase" />
<field name="observedPropertyValue" type="keywords_lowercase" />
<field name="observedPropertyTitle" type="keywords_lowercase" />
<field name="licence" type="keywords" multiValued="false"/>
<field name="lineage" type="text_general" multiValued="false"/>
<field name="locations" type="spatial"/>
Expand Down
28 changes: 25 additions & 3 deletions templates/html/document/_tags.ftlh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,31 @@
</#if>

<#if observedProperty?has_content>
<@keywordList observedProperty "Observed properties" true/>
<@displayObservedProperties observedProperty />
</#if>

<#macro displayObservedProperties op>
<dt>Observed properties</dt>
<dd>
<#list op?sort_by("value") as item>
<#local opLabel="unknown">
<#if item.title?has_content>
<#local opLabel=item.title?trim>
<#elseif item.value?has_content>
<#local opLabel=item.value?trim>
</#if>

<#if item.uri?has_content>
<span><abbr title="${item.uri?trim}">${opLabel}</abbr></span>
<a href="${item.uri?trim}" target="_blank" rel="noopener noreferrer" class="externalVocabularyLink"><sup class="fa-solid fa-xs fa-arrow-up-right-from-square"></sup></a>
<#else>
<span>${opLabel}</span>
</#if>
<#sep><br></#sep>
</#list>
</dd>
</#macro>

<#macro keywordList list listTitle="Keywords" commaseparated=false>
<dt>${listTitle}</dt>
<dd>
Expand All @@ -31,9 +53,9 @@

<#macro displayLinkedKeyword value="" uri="">
<#if uri?has_content>
<span class="bob"><abbr title="${uri?trim}">${value?trim}</abbr></span>
<span><abbr title="${uri?trim}">${value?trim}</abbr></span>
<a href="${uri?trim}" target="_blank" rel="noopener noreferrer" class="externalVocabularyLink"><sup class="fa-solid fa-xs fa-arrow-up-right-from-square"></sup></a>
<#else>
<span class="bob">${value?trim}</span>
<span>${value?trim}</span>
</#if>
</#macro>
13 changes: 7 additions & 6 deletions templates/rdf/_body.ftl
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
:${id}
dct:title "<@displayLiteral title />" ;
dct:title <@displayLiteral title /> ;

<@identifiers resourceIdentifiers />

<#if datacitable?string=='true' && citation?has_content>
dct:bibliographicCitation "${citation.authors?join(', ')} (${citation.year?string("0")}). <@displayLiteral citation.title />. ${citation.publisher}. ${citation.url?trim}" ;
<#assign citationString = citation.authors?join(', ') + " (" + citation.year?string("0") +"}. " + citation.title + ". " + citation.publisher + ". " + citation.url?trim>
dct:bibliographicCitation <@displayLiteral citationString/>
</#if>

<#if resourceStatus != "Deleted">
<#if description?has_content>
dct:description "<@displayLiteral description />" ;
dct:description <@displayLiteral description /> ;
</#if>

<#if lineage?has_content>
dct:provenance [
a dct:ProvenanceStatement ;
rdfs:label "<@displayLiteral lineage />"
rdfs:label <@displayLiteral lineage />
] ;
</#if>

Expand Down Expand Up @@ -70,7 +71,7 @@
</#if>

<#if observedProperty?has_content>
sdo:variableMeasured <@keywordList observedProperty/> ;
sdo:variableMeasured <@opList /> ;
</#if>

<#if funding?has_content>
Expand Down Expand Up @@ -110,7 +111,7 @@
</#if>

<#if observedProperty?has_content>
<@keywordDetail observedProperty />
<@opDetail />
</#if>

<@fundingDetail />
Expand Down
38 changes: 33 additions & 5 deletions templates/rdf/_macros.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</#if>

<#macro displayLiteral string>
<#--Ensure literals do not contain " characters-->
<#t>${string?replace("\"","'")?replace("\n"," ")}
<#--Ensure literals do not contain " characters or line breaks-->
<#t>"${string?trim?replace("\"","'")?replace("\n"," ")}"
</#macro>

<#macro contactList contacts prefix="c">
Expand Down Expand Up @@ -85,7 +85,7 @@
<#assign fundIdentifier ="\l" + fund.awardURI?trim+ "\g">
</#if>

${fundIdentifier?trim} a prov:Activity ; <#if fund.awardTitle?has_content>rdfs:label "<@displayLiteral fund.awardTitle />"</#if> .
${fundIdentifier?trim} a prov:Activity ; <#if fund.awardTitle?has_content>rdfs:label <@displayLiteral fund.awardTitle /></#if> .
</#list>
</#if>
</#macro>
Expand All @@ -104,7 +104,35 @@
<#macro keywordDetail keywords>
<#list keywords as kw>
<#if kw.uri?has_content>
<${kw.uri?trim}> a skos:Concept; skos:prefLabel "<@displayLiteral kw.value />"; rdfs:label "<@displayLiteral kw.value />".
<${kw.uri?trim}> a skos:Concept; skos:prefLabel <@displayLiteral kw.value />; rdfs:label <@displayLiteral kw.value />.
</#if>
</#list>
</#macro>

<#macro opList >
<#list observedProperty as op>
<#if op.uri?has_content>
<#assign keyword ="\l" + op.uri?trim+ "\g">
<#elseif op.title?has_content>
<#assign keyword ='"' + op.title?replace("\"", "") + '"'>
<#else>
<#assign keyword ='"' + op.value?replace("\"", "") + '"'>
</#if>
${keyword}<#sep>,</#sep><#t>
</#list>
</#macro>

<#macro opDetail>
<#list observedProperty as op>
<#assign opLabel = "unknown">
<#if op.title?has_content>
<#assign opLabel = op.title>
<#elseif op.value?has_content>
<#assign opLabel = op.value>
</#if>

<#if op.uri?has_content>
<${op.uri?trim}> a skos:Concept;skos:prefLabel <@displayLiteral opLabel />; rdfs:label <@displayLiteral opLabel />.
</#if>
</#list>
</#macro>
Expand Down Expand Up @@ -132,7 +160,7 @@
</#if>

${citationIdentifier?trim} a <http://purl.org/vocab/frbr/core#Work> ;
<#if citation.description?has_content>rdfs:label "<@displayLiteral citation.description />"; </#if>
<#if citation.description?has_content>rdfs:label <@displayLiteral citation.description />; </#if>
.
</#list>
</#if>
Expand Down
4 changes: 2 additions & 2 deletions templates/rdf/monitoring/_common.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<#macro displayLiteral string>
<#--Ensure literals do not contain " characters-->
<#t>${string?replace("\"","'")?replace("\n"," ")}
<#t>"${string?trim?replace("\"","'")?replace("\n"," ")}"
</#macro>

<#macro common rdftype="" other="" prefixed=true>
Expand All @@ -20,7 +20,7 @@
a ${rdftype} ;
dct:title "${title}" ;
<#if description?has_content>
dct:description "<@displayLiteral description />" ;
dct:description <@displayLiteral description /> ;
</#if>
<#if boundingBox?has_content>
ef:boundingBox "POLYGON${boundingBox.coordinates?replace('[[[','((')?replace(']]]','))')?replace('[^]], ',' ','r')?replace(']', '')?replace('[', '')}"^^geo:wktLiteral ;
Expand Down
2 changes: 1 addition & 1 deletion templates/rdf/turtle/_rights.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<#if accessLimitation?has_content>
dct:accessRights [ a dct:RightsStatement ;
odrs:attributionText "<@displayLiteral accessLimitation.value />" ;
odrs:attributionText <@displayLiteral accessLimitation.value /> ;
<#if accessLimitation.uri?has_content>odrs:attributionUrl <${accessLimitation.uri?trim}> </#if>
] ;
</#if>
29 changes: 21 additions & 8 deletions templates/schema.org/schema.org.ftlh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@

<#if docType?has_content>
{
"@type":"${docType}",
"name":"${title}",
"@type":<@displayLiteral docType/>,
"name":<@displayLiteral title/>,

<#if docType == "Dataset">
<#if isAttached!false>
Expand All @@ -77,12 +77,12 @@
</#if>

<#if resourceStatus != "Deleted">
<#if description?has_content>"description":"${description?replace("\n", " ")}", </#if>
<#if description?has_content>"description":<@displayLiteral description/>, </#if>

<#if alternateTitles?has_content>
"alternateName":[
<#list alternateTitles as altTitle>
"${altTitle}"<#sep>,</#sep>
<@displayLiteral altTitle/><#sep>,</#sep>
</#list>
],
</#if>
Expand Down Expand Up @@ -160,7 +160,7 @@
<#list incomingCitations as citation>
{
"@type": "CreativeWork"
<#if citation.description?has_content>,"creditText": "${citation.description?replace("\n", " ")?trim}"</#if>
<#if citation.description?has_content>,"creditText": <@displayLiteral citation.description/></#if>
<#if citation.url?has_content>,"url": "${citation.url?trim}"</#if>
}<#sep>,</#sep>
</#list>
Expand Down Expand Up @@ -278,7 +278,7 @@
<#t>{
<#t>"@type": "DefinedTerm",
<#t>"@id": "${keyword.uri?trim}",
<#t>"name": "${keyword.value?trim}"
<#t>"name": <@displayLiteral keyword.value/>
<#t><#if subjectScheme?has_content>,"inDefinedTermSet": "${schemeURI}"</#if>
}
<#else>
Expand All @@ -290,16 +290,23 @@

<#macro displayObservedProperties props>
<#list props as op>
<#assign opLabel ="unknown">
<#if op.title?has_content>
<#assign opLabel = op.title?trim>
<#elseif op.value?has_content>
<#assign opLabel = op.value?trim>
</#if>

<#if op.uri?has_content>
{
"@type": "StatisticalVariable",
"@id": "${op.uri?trim}",
"name": "${op.value?trim}"
"name": "${opLabel}"
<#if op.unitsUri?has_content>,"unitCode": "${op.unitsUri?trim}"</#if>
<#if op.units?has_content>,"unitText": "${op.units?trim}"</#if>
}
<#else>
"${op.value?trim}"
<@displayLiteral opLabel/>
</#if>
<#sep>,</#sep>
</#list>
Expand All @@ -325,3 +332,9 @@
],
</#if>
</#macro>

<#macro displayLiteral string>
<#--Ensure literals do not contain " characters or line breaks-->
<#t>"${string?trim?replace("\"","'")?replace("\n"," ")}"
</#macro>

0 comments on commit 5630139

Please sign in to comment.