Skip to content

Commit

Permalink
Closes #2614 "It should be possible to mark a metadata as anonimizable"
Browse files Browse the repository at this point in the history
  • Loading branch information
lbownik authored and lbownik committed Dec 30, 2024
1 parent 0fc1ef1 commit 4be2290
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ public boolean isEmpty() {
public boolean isEmptyForDisplay() {
return isEmpty(true);
}

public boolean isGeospatial() {
return this.datasetFieldType.isGeospatial();
}

public boolean isVisibleThroughAnonymizedUrl() {
return this.datasetFieldType.isVisibleThroughAnonymizedUrl();
}

public DatasetField copy() {
return DatasetFieldUtil.copyDatasetField(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public class DatasetFieldType implements Serializable, Comparable<DatasetFieldTy
@Column(name="metadata", nullable = false)
@Convert(converter = JsonMapConverter.class)
private Map<String, Object> metadata = emptyMap();
private boolean visibleThroughAnonymizedUrl;

// -------------------- CONSTRUCTORS --------------------

Expand Down Expand Up @@ -281,6 +282,10 @@ public boolean isAdvancedSearchFieldType() {
return this.advancedSearchFieldType;
}

public boolean isVisibleThroughAnonymizedUrl() {
return this.visibleThroughAnonymizedUrl;
}

public List<DatasetFieldDefaultValue> getDatasetFieldDefaultValues() {
return datasetFieldDefaultValues;
}
Expand Down Expand Up @@ -413,6 +418,11 @@ public boolean isHasRequiredChildren() {
public boolean isHasParent() {
return this.parentDatasetFieldType != null;
}


public boolean isGeospatial() {
return this.fieldType == FieldType.GEOBOX;
}

@Override
public int compareTo(DatasetFieldType o) {
Expand Down Expand Up @@ -600,6 +610,10 @@ public void setAdvancedSearchFieldType(boolean advancedSearchFieldType) {
this.advancedSearchFieldType = advancedSearchFieldType;
}

public void setVisibleThroughAnonymizedUrl(final boolean visibleThroughAnonymizedUrl) {
this.visibleThroughAnonymizedUrl = visibleThroughAnonymizedUrl;
}

public void setDatasetFieldDefaultValues(List<DatasetFieldDefaultValue> datasetFieldDefaultValues) {
this.datasetFieldDefaultValues = datasetFieldDefaultValues;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public List<DatasetField> getDatasetFields() {
public boolean isInclude() {
return include;
}

public boolean isVisibleThroughAnonymizedUrl() {
return this.datasetFieldType.isVisibleThroughAnonymizedUrl();
}

// -------------------- LOGIC --------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ public boolean isHasRequired() {
public String getIdString() {
return id.toString();
}

public boolean isVisibleThroughAnonymizedUrl() {
return this.datasetFieldTypes.stream()
.anyMatch(DatasetFieldType::isVisibleThroughAnonymizedUrl);
}

@Transient
private boolean showDatasetFieldTypes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
alter table roleassignment add column if not exists anonymized boolean not null default false;
ALTER TABLE roleassignment DROP CONSTRAINT unq_roleassignment_0;
alter table roleassignment add CONSTRAINT unq_roleassignment_0 UNIQUE (assigneeidentifier, role_id, definitionpoint_id, anonymized);
alter table roleassignment add CONSTRAINT unq_roleassignment_0 UNIQUE (assigneeidentifier, role_id, definitionpoint_id, anonymized);

alter table datasetfieldtype add column visiblethroughanonymizedurl bool default true not null;
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'alternativeURL';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'otherId';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'author';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'datasetContact';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'publication';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'producer';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'productionPlace';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'contributor';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'grantNumber';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'distributor';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'depositor';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'series';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'relatedDataset';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'relatedMaterial';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'otherReferences';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'dataSources';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'originOfSources';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'characteristicOfSources';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'accessToSources';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'dataCollector';
update datasetfieldtype set visiblethroughanonymizedurl = false where name = 'journalVolumeIssue';
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import edu.harvard.iq.dataverse.ingest.UningestInfoService;
import edu.harvard.iq.dataverse.mail.confirmemail.ConfirmEmailServiceBean;
import edu.harvard.iq.dataverse.notification.NotificationParameter;
import edu.harvard.iq.dataverse.persistence.DvObject;
import edu.harvard.iq.dataverse.persistence.datafile.MapLayerMetadata;
import edu.harvard.iq.dataverse.persistence.datafile.license.FileTermsOfUse;
import edu.harvard.iq.dataverse.persistence.datafile.license.LicenseIcon;
Expand Down Expand Up @@ -645,6 +646,10 @@ public void fetchMetricsDownloadCount() {
public boolean isViewedFromPrivateUrl() {
return this.session.isViewedFromPrivateUrl(this.dataset);
}

public boolean isViewedFromAnonymizedPrivateUrl() {
return this.session.isViewedFromAnonymizedPrivateUrl(this.dataset);
}

public boolean isDoiReserved() {
return dataset.isIdentifierRegistered();
Expand Down
1 change: 1 addition & 0 deletions dataverse-webapp/src/main/webapp/metadataTab.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
<ui:param name="globalId" value="#{DatasetMetadataTab.dataset.globalIdString}"/>
<ui:param name="altPID" value="#{DatasetMetadataTab.getAlternativePersistentIdentifier()}"/>
<ui:param name="publicationDate" value="#{DatasetMetadataTab.dataset.publicationDateFormattedYYYYMMDD}"/>
<ui:param name="isViewedFromAnonymizedPrivateUrl" value="#{DatasetPage.isViewedFromAnonymizedPrivateUrl()}"/>
</ui:include>
</ui:composition>
63 changes: 44 additions & 19 deletions dataverse-webapp/src/main/webapp/viewMetadata.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,79 @@
<div class="panel-group form-horizontal">
<ui:repeat value="#{metadataBlocks}"
var="metadataBlockVal" varStatus="block">
<div class="panel panel-default">
<a id="clps#{block.index}" data-toggle="collapse" href="#panelCollapse#{block.index}" class="collapseSrc panel-heading text-info" tabindex="0"
aria-expanded="#{block.first}">
<div jsf:rendered="#{!isViewedFromAnonymizedPrivateUrl or metadataBlockVal.key.isVisibleThroughAnonymizedUrl()}"
class="panel panel-default">
<a id="clps#{block.index}"
data-toggle="collapse"
href="#panelCollapse#{block.index}"
class="collapseSrc panel-heading text-info"
tabindex="0"
aria-expanded="#{block.first}">
<h3>#{metadataBlockVal.key.localeDisplayName} &#160;<span class="collapseSrc glyphicon #{block.first?'glyphicon-chevron-up':'glyphicon-chevron-down'}" aria-hidden="true"/></h3>
</a>
<div id="panelCollapse#{block.index}" class="collapse #{block.first?'in':''}">
<div class="panel-body metadata-panel-body">
<ui:fragment rendered="#{block.first}">
<div class="form-group" jsf:rendered="#{!empty globalId}">
<div jsf:rendered="#{!empty globalId}"
class="form-group">
<div class="col-sm-3 control-label section-title">
#{bundle['dataset.metadata.persistentId']}
<span class="glyphicon glyphicon-question-sign tooltip-icon" tabindex="0" role="button"
data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataset.metadata.persistentId.tip']}"></span>
<span class="glyphicon glyphicon-question-sign tooltip-icon"
tabindex="0"
role="button"
data-toggle="tooltip"
data-placement="auto right"
data-original-title="#{bundle['dataset.metadata.persistentId.tip']}"/>
</div>
<div class="col-sm-9 form-control-static">
<p class="text-block">#{globalId}</p>
</div>
</div>
<div class="form-group" jsf:rendered="#{!empty altPID}">
<div jsf:rendered="#{!empty altPID}"
class="form-group">
<div class="col-sm-3 control-label section-title">
#{bundle['dataset.metadata.alternativePersistentId']}
<span class="glyphicon glyphicon-question-sign tooltip-icon" tabindex="0" role="button"
data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataset.metadata.alternativePersistentId.tip']}"></span>
<span class="glyphicon glyphicon-question-sign tooltip-icon"
tabindex="0"
role="button"
data-toggle="tooltip"
data-placement="auto right"
data-original-title="#{bundle['dataset.metadata.alternativePersistentId.tip']}"/>
</div>
<div class="col-sm-9 form-control-static">
<p class="text-block">#{altPID}</p>
</div>
</div>
<div class="form-group" jsf:rendered="#{!empty publicationDate}">
<div jsf:rendered="#{!empty publicationDate}"
class="form-group">
<div class="col-sm-3 control-label section-title">
#{bundle['dataset.metadata.publicationDate']}
<span class="glyphicon glyphicon-question-sign tooltip-icon" tabindex="0" role="button"
data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataset.metadata.publicationDate.tip']}"></span>
<span class="glyphicon glyphicon-question-sign tooltip-icon"
tabindex="0"
role="button"
data-toggle="tooltip"
data-placement="auto right"
data-original-title="#{bundle['dataset.metadata.publicationDate.tip']}"/>
</div>
<div class="col-sm-9 form-control-static">
<p class="text-block">#{publicationDate}</p>
</div>
</div>
</ui:fragment>
<ui:repeat value="#{metadataBlockVal.value}" var="fieldsByType" varStatus="fieldTypeIndex">
<div class="form-group">
<ui:repeat value="#{metadataBlockVal.value}"
var="fieldsByType"
varStatus="fieldTypeIndex">
<div jsf:rendered="#{!isViewedFromAnonymizedPrivateUrl or fieldsByType.isVisibleThroughAnonymizedUrl()}"
class="form-group">
<div class="col-sm-3 control-label section-title">
<h:outputText value="#{fieldsByType.datasetFieldType.localeTitle}" escape="false" />
<span class="glyphicon glyphicon-question-sign tooltip-icon"
jsf:rendered="#{not empty fieldsByType.datasetFieldType.localeDescription}"
tabindex="0" role="button"
data-toggle="tooltip" data-placement="auto right"
data-original-title="#{fieldsByType.datasetFieldType.localeDescription}"></span>
<span jsf:rendered="#{not empty fieldsByType.datasetFieldType.localeDescription}"
class="glyphicon glyphicon-question-sign tooltip-icon"
tabindex="0"
role="button"
data-toggle="tooltip"
data-placement="auto right"
data-original-title="#{fieldsByType.datasetFieldType.localeDescription}"/>
</div>

<ui:include src="viewMetadataField.xhtml">
Expand Down
7 changes: 3 additions & 4 deletions dataverse-webapp/src/main/webapp/viewMetadataField.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
xmlns:jsf="http://xmlns.jcp.org/jsf">

<!--@elvariable id="fieldsByType" type="edu.harvard.iq.dataverse.persistence.dataset.DatasetFieldsByType"-->
<o:importConstants type="edu.harvard.iq.dataverse.persistence.dataset.FieldType"/>
<div class="col-sm-9 form-control-static">
<ui:fragment rendered="#{fieldsByType.datasetFieldType.name == 'datasetContact'}">
<p class="help-block no-margin-top">
Expand All @@ -19,13 +18,13 @@
</ui:fragment>

<ui:repeat var="datasetField" value="#{fieldsByType.datasetFields}" varStatus="fieldsLoop">
<div style="#{fieldsLoop.last ? '': 'padding-bottom: 10px;'}" class="datasetfield-value
#{datasetField.datasetFieldType.separableOnGui ? 'datasetfield-separable' : ''}">
<div style="#{fieldsLoop.last ? '': 'padding-bottom: 10px;'}"
class="datasetfield-value #{datasetField.datasetFieldType.separableOnGui ? 'datasetfield-separable' : ''}">
<ui:repeat var="value" value="#{datasetField.values}" varStatus="valuesLoop">
<h:outputText value="#{valuesLoop.first?'':'; '}#{ value }"
escape="false"/>
</ui:repeat>
<c:set var="isGeospatial" value="#{datasetField.datasetFieldType.fieldType eq FieldType.GEOBOX}"/>
<c:set var="isGeospatial" value="#{datasetField.isGeospatial()}"/>
<c:set var="currentGsIndex" value="map_#{mdBlockName}_#{fieldIndex}_#{fieldsLoop.index}"/>
<script jsf:rendered="#{isGeospatial}">
DvJS.Geo.MetadataView.prepare('#{currentGsIndex}');
Expand Down

0 comments on commit 4be2290

Please sign in to comment.