Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IQSS/10711 Cvoc updates #10712

Merged
Merged
1 change: 1 addition & 0 deletions doc/release-notes/10711-CVoc Updates.md
Original file line number Diff line number Diff line change
@@ -0,0 +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).
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ public Pair<String, String> getLinkComponents() {
return linkComponents.get(parentDatasetField.getDatasetFieldType().getName());
}

public boolean hasChildOfType(String name) {
for (DatasetField child : childDatasetFields) {
if (child.getDatasetFieldType().getName().equals(name)) {
return true;
}
}
return false;
}

private Map<DatasetField, String> removeLastComma(Map<DatasetField, String> mapIn) {

Iterator<Map.Entry<DatasetField, String>> itr = mapIn.entrySet().iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public class DatasetFieldServiceBean implements java.io.Serializable {
//Note that for primitive fields, the prent and term-uri-field are the same and these maps have the same entry
Map <Long, JsonObject> cvocMapByTermUri = null;

//Flat list of cvoc term-uri and managed fields by Id
Set<Long> cvocFieldSet = null;

//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
String oldHash = null;

Expand Down Expand Up @@ -278,6 +281,10 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermUriField){
String cvocSetting = settingsService.getValueForKey(SettingsServiceBean.Key.CVocConf);
if (cvocSetting == null || cvocSetting.isEmpty()) {
oldHash=null;
//Release old maps
cvocMap=null;
cvocMapByTermUri=null;
cvocFieldSet = null;
return new HashMap<>();
}
String newHash = DigestUtils.md5Hex(cvocSetting);
Expand All @@ -287,6 +294,7 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermUriField){
oldHash=newHash;
cvocMap=new HashMap<>();
cvocMapByTermUri=new HashMap<>();
cvocFieldSet = new HashSet<>();

try (JsonReader jsonReader = Json.createReader(new StringReader(settingsService.getValueForKey(SettingsServiceBean.Key.CVocConf)))) {
JsonArray cvocConfJsonArray = jsonReader.readArray();
Expand All @@ -303,11 +311,13 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermUriField){
if (termUriField.equals(dft.getName())) {
logger.fine("Found primitive field for term uri : " + dft.getName() + ": " + dft.getId());
cvocMapByTermUri.put(dft.getId(), jo);
cvocFieldSet.add(dft.getId());
}
} else {
DatasetFieldType childdft = findByNameOpt(jo.getString("term-uri-field"));
logger.fine("Found term child field: " + childdft.getName()+ ": " + childdft.getId());
cvocMapByTermUri.put(childdft.getId(), jo);
cvocFieldSet.add(childdft.getId());
if (childdft.getParentDatasetFieldType() != dft) {
logger.warning("Term URI field (" + childdft.getDisplayName() + ") not a child of parent: "
+ dft.getDisplayName());
Expand All @@ -327,6 +337,7 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermUriField){
+ managedFields.getString(s));
} else {
logger.fine("Found: " + dft.getName());
cvocFieldSet.add(dft.getId());
}
}
}
Expand All @@ -338,6 +349,10 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermUriField){
return byTermUriField ? cvocMapByTermUri : cvocMap;
}

public Set<Long> getCvocFieldSet() {
return cvocFieldSet;
}

/**
* Adds information about the external vocabulary term being used in this DatasetField to the ExternalVocabularyValue table if it doesn't already exist.
* @param df - the primitive/parent compound field containing a newly saved value
Expand Down Expand Up @@ -468,7 +483,8 @@ public JsonObject getExternalVocabularyValue(String termUri) {
logger.warning("Problem parsing external vocab value for uri: " + termUri + " : " + e.getMessage());
}
} catch (NoResultException nre) {
logger.warning("No external vocab value for uri: " + termUri);
//Could just be a plain text value
logger.fine("No external vocab value for uri: " + termUri);
}
return null;
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/SettingsWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class SettingsWrapper implements java.io.Serializable {
//External Vocabulary support
private Map<Long, JsonObject> cachedCvocMap = null;
private Map<Long, JsonObject> cachedCvocByTermFieldMap = null;
private Set<Long> cvocFieldSet;

private Long zipDownloadLimit = null;

Expand Down Expand Up @@ -806,6 +807,17 @@ public Map<Long, JsonObject> getCVocConf(boolean byTermField) {
}
}

public boolean isCvocField(Long fieldId) {

if(cvocFieldSet == null) {
cvocFieldSet = fieldService.getCvocFieldSet();
}
if(cvocFieldSet == null) {
return false;
}
return cvocFieldSet.contains(fieldId);
}

public String getMetricsUrl() {
if (metricsUrl == null) {
metricsUrl = getValueForKey(SettingsServiceBean.Key.MetricsUrl);
Expand Down
16 changes: 8 additions & 8 deletions src/main/webapp/metadataFragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@
</ui:fragment>

<ui:repeat value="#{dsf.datasetFieldCompoundValues}" var="compoundValue" varStatus="compoundValuesStatus">

<c:set var="cvocOnDsfApplies" value="#{compoundValue.hasChildOfType(cvocConf.get(dsf.datasetFieldType.id).getString('term-uri-field'))}"/>
<ui:repeat value="#{compoundValue.displayValueMap.entrySet().toArray()}" var="cvPart" varStatus="partStatus">
<c:set var="cvocOnCvPart" value="#{cvocConf.containsKey(cvPart.key.datasetFieldType.id)}"/>
<h:outputText value="#{dsf.datasetFieldType.displayFormat} " rendered="${!partStatus.first and !(cvocOnDsf or cvocOnCvPart)}"/>
<ui:fragment rendered="#{!(cvocOnDsf or cvocOnCvPart)}">
<h:outputText value="#{dsf.datasetFieldType.displayFormat} " rendered="${!partStatus.first and !settingsWrapper.isCvocField(cvPart.key.datasetFieldType.id)}"/>
<ui:fragment rendered="#{!cvocOnDsfApplies or !settingsWrapper.isCvocField(cvPart.key.datasetFieldType.id)}">
<ui:fragment rendered="#{compoundValue.isLink(cvPart.key)}">
<h:outputLink value="#{compoundValue.getLink()}" target="_blank">
<h:outputText value="#{cvPart.value}"
Expand Down Expand Up @@ -168,7 +168,7 @@
<!-- Cvoc for others fields -->
<h:outputText value="#{cvPart.key.value}"
escape="#{cvPart.key.datasetFieldType.isEscapeOutputText()}"
rendered="#{(cvocOnDsf or cvocOnCvPart) and not (
rendered="#{(cvocOnDsfApplies or cvocOnCvPart) and not (
cvPart.key.datasetFieldType.name.equals(cvocConf.get(cvPart.key.datasetFieldType.id).getString('term-uri-field'))
or cvPart.key.datasetFieldType.name.equals(cvocConf.get(dsf.datasetFieldType.id).getString('term-uri-field')))}"
styleClass="hidden">
Expand Down Expand Up @@ -251,7 +251,7 @@
<p:fragment id="editPrimitiveValueFragment" rendered="#{dsf.datasetFieldType.primitive}">
<p:autoUpdate/>
<div>
<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">
<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">
#{dsf.datasetFieldType.localeTitle}
<span class="glyphicon glyphicon-asterisk text-danger" jsf:rendered="#{dsf.required}"/>
<span class="glyphicon glyphicon-question-sign tooltip-icon"
Expand Down Expand Up @@ -366,7 +366,7 @@
<h:outputText value="#{bundle.htmlAllowedMsg}" escape="false"/>
</p>
</ui:fragment>
<label jsf:for="#{subdsf.datasetFieldType.controlledVocabulary ? 'cvv_focus' : subdsf.datasetFieldType.fieldType == 'TEXTBOX' ? 'description' : 'inputText'}" class="control-label">
<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">
#{subdsf.datasetFieldType.localeTitle}
<span class="glyphicon glyphicon-asterisk text-danger" jsf:rendered="#{subdsf.required and dsf.required}"/>
<span class="glyphicon glyphicon-question-sign tooltip-icon"
Expand All @@ -377,11 +377,11 @@
<ui:include src="datasetFieldForEditFragment.xhtml">
<ui:param name="dsfv" value="#{subdsf.singleValue}"/>
<ui:param name="dsfvIndex" value="0"/>
<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}"/>
<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}"/>
</ui:include>
</ui:fragment>
<!-- MOVED SELECT ONE TO dataFieldForEdit -->
<div jsf:rendered="#{subdsf.datasetFieldType.controlledVocabulary}">
<div jsf:rendered="#{subdsf.datasetFieldType.controlledVocabulary}" data-cvoc-managed-field="#{settingsWrapper.isCvocField(subdsf.datasetFieldType.id)? subdsf.datasetFieldType.name : ''}">
<p:selectOneMenu id="cvv" value="#{subdsf.singleControlledVocabularyValue}" converter="controlledVocabularyValueConverter" style="width: auto !important; max-width:100%; min-width:200px;"
rendered="#{!subdsf.datasetFieldType.allowMultiples}" filter="#{(subdsf.datasetFieldType.controlledVocabularyValues.size() lt 10) ? 'false':'true'}" filterMatchMode="contains" >
<f:selectItem itemLabel="#{bundle.select}" itemValue="" noSelectionOption="true"/>
Expand Down
12 changes: 11 additions & 1 deletion src/main/webapp/resources/css/structure.css
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,16 @@ div.edit-field div.ui-message {margin:6px 0;}
.metadata-container pre {
white-space: pre-wrap !important;
}

#metadata_author img {
vertical-align: text-top;
margin-right:1px;
margin-left: 3px;
}

#metadata_author img.ror {
vertical-align: middle;
}
/* TRUNCATION */
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%);}
button.desc-more-link {margin:0; padding:0;}
Expand Down Expand Up @@ -1069,7 +1079,7 @@ progress::-webkit-progress-value {
.select2-selection__clear, .select2-selection__rendered {
vertical-align: -webkit-baseline-middle;
}
.select2-results li {
.select2-results ul > li {
font-weight:400;
font-size:14px;
}
Expand Down
Loading