Skip to content

Commit 050064e

Browse files
authored
Merge pull request #10712 from QualitativeDataRepository/QDR-CVoc_updates_for_author
IQSS/10711 Cvoc updates
2 parents d40ce32 + f1218a3 commit 050064e

6 files changed

Lines changed: 58 additions & 10 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Changes in Dataverse and updates to the ORCID and ROR external vocabulary scripts support deploying these for the citation block author field (and others).

src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,15 @@ public Pair<String, String> getLinkComponents() {
225225
return linkComponents.get(parentDatasetField.getDatasetFieldType().getName());
226226
}
227227

228+
public boolean hasChildOfType(String name) {
229+
for (DatasetField child : childDatasetFields) {
230+
if (child.getDatasetFieldType().getName().equals(name)) {
231+
return true;
232+
}
233+
}
234+
return false;
235+
}
236+
228237
private Map<DatasetField, String> removeLastComma(Map<DatasetField, String> mapIn) {
229238

230239
Iterator<Map.Entry<DatasetField, String>> itr = mapIn.entrySet().iterator();

src/main/java/edu/harvard/iq/dataverse/DatasetFieldServiceBean.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public class DatasetFieldServiceBean implements java.io.Serializable {
8585
//Note that for primitive fields, the prent and term-uri-field are the same and these maps have the same entry
8686
Map <Long, JsonObject> cvocMapByTermUri = null;
8787

88+
//Flat list of cvoc term-uri and managed fields by Id
89+
Set<Long> cvocFieldSet = null;
90+
8891
//The hash of the existing CVocConf setting. Used to determine when the setting has changed and it needs to be re-parsed to recreate the cvocMaps
8992
String oldHash = null;
9093

@@ -278,6 +281,10 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermUriField){
278281
String cvocSetting = settingsService.getValueForKey(SettingsServiceBean.Key.CVocConf);
279282
if (cvocSetting == null || cvocSetting.isEmpty()) {
280283
oldHash=null;
284+
//Release old maps
285+
cvocMap=null;
286+
cvocMapByTermUri=null;
287+
cvocFieldSet = null;
281288
return new HashMap<>();
282289
}
283290
String newHash = DigestUtils.md5Hex(cvocSetting);
@@ -287,6 +294,7 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermUriField){
287294
oldHash=newHash;
288295
cvocMap=new HashMap<>();
289296
cvocMapByTermUri=new HashMap<>();
297+
cvocFieldSet = new HashSet<>();
290298

291299
try (JsonReader jsonReader = Json.createReader(new StringReader(settingsService.getValueForKey(SettingsServiceBean.Key.CVocConf)))) {
292300
JsonArray cvocConfJsonArray = jsonReader.readArray();
@@ -303,11 +311,13 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermUriField){
303311
if (termUriField.equals(dft.getName())) {
304312
logger.fine("Found primitive field for term uri : " + dft.getName() + ": " + dft.getId());
305313
cvocMapByTermUri.put(dft.getId(), jo);
314+
cvocFieldSet.add(dft.getId());
306315
}
307316
} else {
308317
DatasetFieldType childdft = findByNameOpt(jo.getString("term-uri-field"));
309318
logger.fine("Found term child field: " + childdft.getName()+ ": " + childdft.getId());
310319
cvocMapByTermUri.put(childdft.getId(), jo);
320+
cvocFieldSet.add(childdft.getId());
311321
if (childdft.getParentDatasetFieldType() != dft) {
312322
logger.warning("Term URI field (" + childdft.getDisplayName() + ") not a child of parent: "
313323
+ dft.getDisplayName());
@@ -327,6 +337,7 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermUriField){
327337
+ managedFields.getString(s));
328338
} else {
329339
logger.fine("Found: " + dft.getName());
340+
cvocFieldSet.add(dft.getId());
330341
}
331342
}
332343
}
@@ -338,6 +349,10 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermUriField){
338349
return byTermUriField ? cvocMapByTermUri : cvocMap;
339350
}
340351

352+
public Set<Long> getCvocFieldSet() {
353+
return cvocFieldSet;
354+
}
355+
341356
/**
342357
* Adds information about the external vocabulary term being used in this DatasetField to the ExternalVocabularyValue table if it doesn't already exist.
343358
* @param df - the primitive/parent compound field containing a newly saved value
@@ -468,7 +483,8 @@ public JsonObject getExternalVocabularyValue(String termUri) {
468483
logger.warning("Problem parsing external vocab value for uri: " + termUri + " : " + e.getMessage());
469484
}
470485
} catch (NoResultException nre) {
471-
logger.warning("No external vocab value for uri: " + termUri);
486+
//Could just be a plain text value
487+
logger.fine("No external vocab value for uri: " + termUri);
472488
}
473489
return null;
474490
}

src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public class SettingsWrapper implements java.io.Serializable {
9898
//External Vocabulary support
9999
private Map<Long, JsonObject> cachedCvocMap = null;
100100
private Map<Long, JsonObject> cachedCvocByTermFieldMap = null;
101+
private Set<Long> cvocFieldSet;
101102

102103
private Long zipDownloadLimit = null;
103104

@@ -806,6 +807,17 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermField) {
806807
}
807808
}
808809

810+
public boolean isCvocField(Long fieldId) {
811+
812+
if(cvocFieldSet == null) {
813+
cvocFieldSet = fieldService.getCvocFieldSet();
814+
}
815+
if(cvocFieldSet == null) {
816+
return false;
817+
}
818+
return cvocFieldSet.contains(fieldId);
819+
}
820+
809821
public String getMetricsUrl() {
810822
if (metricsUrl == null) {
811823
metricsUrl = getValueForKey(SettingsServiceBean.Key.MetricsUrl);

src/main/webapp/metadataFragment.xhtml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@
126126
</ui:fragment>
127127

128128
<ui:repeat value="#{dsf.datasetFieldCompoundValues}" var="compoundValue" varStatus="compoundValuesStatus">
129-
129+
<c:set var="cvocOnDsfApplies" value="#{compoundValue.hasChildOfType(cvocConf.get(dsf.datasetFieldType.id).getString('term-uri-field'))}"/>
130130
<ui:repeat value="#{compoundValue.displayValueMap.entrySet().toArray()}" var="cvPart" varStatus="partStatus">
131131
<c:set var="cvocOnCvPart" value="#{cvocConf.containsKey(cvPart.key.datasetFieldType.id)}"/>
132-
<h:outputText value="#{dsf.datasetFieldType.displayFormat} " rendered="${!partStatus.first and !(cvocOnDsf or cvocOnCvPart)}"/>
133-
<ui:fragment rendered="#{!(cvocOnDsf or cvocOnCvPart)}">
132+
<h:outputText value="#{dsf.datasetFieldType.displayFormat} " rendered="${!partStatus.first and !settingsWrapper.isCvocField(cvPart.key.datasetFieldType.id)}"/>
133+
<ui:fragment rendered="#{!cvocOnDsfApplies or !settingsWrapper.isCvocField(cvPart.key.datasetFieldType.id)}">
134134
<ui:fragment rendered="#{compoundValue.isLink(cvPart.key)}">
135135
<h:outputLink value="#{compoundValue.getLink()}" target="_blank">
136136
<h:outputText value="#{cvPart.value}"
@@ -168,7 +168,7 @@
168168
<!-- Cvoc for others fields -->
169169
<h:outputText value="#{cvPart.key.value}"
170170
escape="#{cvPart.key.datasetFieldType.isEscapeOutputText()}"
171-
rendered="#{(cvocOnDsf or cvocOnCvPart) and not (
171+
rendered="#{(cvocOnDsfApplies or cvocOnCvPart) and not (
172172
cvPart.key.datasetFieldType.name.equals(cvocConf.get(cvPart.key.datasetFieldType.id).getString('term-uri-field'))
173173
or cvPart.key.datasetFieldType.name.equals(cvocConf.get(dsf.datasetFieldType.id).getString('term-uri-field')))}"
174174
styleClass="hidden">
@@ -251,7 +251,7 @@
251251
<p:fragment id="editPrimitiveValueFragment" rendered="#{dsf.datasetFieldType.primitive}">
252252
<p:autoUpdate/>
253253
<div>
254-
<h:outputLabel for="#{dsf.datasetFieldType.controlledVocabulary ? (!dsf.datasetFieldType.allowMultiples ? 'unique1_focus' : 'unique2_focus') : ('fieldvaluelist:0:'.concat(((dsf.datasetFieldType.fieldType == 'TEXTBOX') ? 'description' : 'inputText')))}" styleClass="col-sm-3 control-label">
254+
<h:outputLabel for="#{dsf.datasetFieldType.controlledVocabulary ? (!dsf.datasetFieldType.allowMultiples ? 'unique1_focus' : 'unique2_focus') : ('fieldvaluelist:0:'.concat(((dsf.datasetFieldType.fieldType == 'TEXTBOX') ? 'description' : cvocConf.containsKey(dsf.datasetFieldType.id)? 'cvocInputText': 'inputText')))}" styleClass="col-sm-3 control-label">
255255
#{dsf.datasetFieldType.localeTitle}
256256
<span class="glyphicon glyphicon-asterisk text-danger" jsf:rendered="#{dsf.required}"/>
257257
<span class="glyphicon glyphicon-question-sign tooltip-icon"
@@ -366,7 +366,7 @@
366366
<h:outputText value="#{bundle.htmlAllowedMsg}" escape="false"/>
367367
</p>
368368
</ui:fragment>
369-
<label jsf:for="#{subdsf.datasetFieldType.controlledVocabulary ? 'cvv_focus' : subdsf.datasetFieldType.fieldType == 'TEXTBOX' ? 'description' : 'inputText'}" class="control-label">
369+
<label jsf:for="#{subdsf.datasetFieldType.controlledVocabulary ? 'cvv_focus' : subdsf.datasetFieldType.fieldType == 'TEXTBOX' ? 'description' : cvocConf.containsKey(subdsf.datasetFieldType.id) ? 'cvocInputText' : cvocConf.containsKey(dsf.datasetFieldType.id) ? 'cvocInputText2' : 'inputText'}" class="control-label">
370370
#{subdsf.datasetFieldType.localeTitle}
371371
<span class="glyphicon glyphicon-asterisk text-danger" jsf:rendered="#{subdsf.required and dsf.required}"/>
372372
<span class="glyphicon glyphicon-question-sign tooltip-icon"
@@ -377,11 +377,11 @@
377377
<ui:include src="datasetFieldForEditFragment.xhtml">
378378
<ui:param name="dsfv" value="#{subdsf.singleValue}"/>
379379
<ui:param name="dsfvIndex" value="0"/>
380-
<ui:param name="cvoc" value="#{cvocConf.containsKey(dsf.datasetFieldType.id)? cvocConf.get(dsf.datasetFieldType.id): cvocConf.containsKey(dsfv.datasetField.datasetFieldType.id)? cvocConf.get(dsfv.datasetField.datasetFieldType.id): null}"/>
380+
<ui:param name="cvoc" value="#{cvocConf.containsKey(subdsf.datasetFieldType.id) ? cvocConf.get(subdsf.datasetFieldType.id) : cvocConf.containsKey(dsf.datasetFieldType.id)? cvocConf.get(dsf.datasetFieldType.id): cvocConf.containsKey(dsfv.datasetField.datasetFieldType.id)? cvocConf.get(dsfv.datasetField.datasetFieldType.id): null}"/>
381381
</ui:include>
382382
</ui:fragment>
383383
<!-- MOVED SELECT ONE TO dataFieldForEdit -->
384-
<div jsf:rendered="#{subdsf.datasetFieldType.controlledVocabulary}">
384+
<div jsf:rendered="#{subdsf.datasetFieldType.controlledVocabulary}" data-cvoc-managed-field="#{settingsWrapper.isCvocField(subdsf.datasetFieldType.id)? subdsf.datasetFieldType.name : ''}">
385385
<p:selectOneMenu id="cvv" value="#{subdsf.singleControlledVocabularyValue}" converter="controlledVocabularyValueConverter" style="width: auto !important; max-width:100%; min-width:200px;"
386386
rendered="#{!subdsf.datasetFieldType.allowMultiples}" filter="#{(subdsf.datasetFieldType.controlledVocabularyValues.size() lt 10) ? 'false':'true'}" filterMatchMode="contains" >
387387
<f:selectItem itemLabel="#{bundle.select}" itemValue="" noSelectionOption="true"/>

src/main/webapp/resources/css/structure.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,16 @@ div.edit-field div.ui-message {margin:6px 0;}
670670
.metadata-container pre {
671671
white-space: pre-wrap !important;
672672
}
673+
674+
#metadata_author img {
675+
vertical-align: text-top;
676+
margin-right:1px;
677+
margin-left: 3px;
678+
}
679+
680+
#metadata_author img.ror {
681+
vertical-align: middle;
682+
}
673683
/* TRUNCATION */
674684
div.more-block {text-align:center; padding-top:250px; width:100%; position:absolute; bottom:0; background:linear-gradient(180deg,hsla(0,0%,100%,0),#fff 80%);}
675685
button.desc-more-link {margin:0; padding:0;}
@@ -1069,7 +1079,7 @@ progress::-webkit-progress-value {
10691079
.select2-selection__clear, .select2-selection__rendered {
10701080
vertical-align: -webkit-baseline-middle;
10711081
}
1072-
.select2-results li {
1082+
.select2-results ul > li {
10731083
font-weight:400;
10741084
font-size:14px;
10751085
}

0 commit comments

Comments
 (0)