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

8822 incomplete datasets via api #8940

Merged
merged 52 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c2b47a1
initial implementation
ErykKul Aug 8, 2022
f8ff294
implementation of dataset metadata validity in solr
ErykKul Aug 12, 2022
0c71b2c
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul Aug 12, 2022
c0947f9
validity status of metadata in solr
ErykKul Aug 12, 2022
b898593
ui settings for invalid metadata
ErykKul Aug 12, 2022
b8ebbf8
merge develop branch
ErykKul Aug 18, 2022
b31351e
validity bugfixes in dataset page
ErykKul Aug 18, 2022
3521ea8
message improvement in properties
ErykKul Aug 19, 2022
f041d71
merge with develop
ErykKul Aug 19, 2022
db1a99d
more defensive implementation of not validating metadata
ErykKul Aug 26, 2022
a785b69
updataed Ivalid to Invalid metadata
ErykKul Aug 26, 2022
1a00ad8
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul Aug 26, 2022
8b67837
added documentation
ErykKul Aug 26, 2022
d28303f
changes in documentation
ErykKul Aug 26, 2022
1513da6
changes in documentation
ErykKul Aug 26, 2022
3a75244
changes in documentation
ErykKul Aug 26, 2022
69855de
changes in documentation
ErykKul Aug 26, 2022
b97efb1
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul Aug 29, 2022
c59b227
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul Sep 9, 2022
73980ef
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul Sep 12, 2022
c7edc36
Merge branch 'dev_sync' into 8822_incomplete_datasets_via_api
ErykKul Sep 27, 2022
0041c04
Merge branch 'dev_sync' into 8822_incomplete_datasets_via_api
ErykKul Sep 27, 2022
c260c5f
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul Nov 7, 2022
e647323
Merge 'iqss/develop'
ErykKul Nov 21, 2022
e437b46
Merge branch 'trunk' of https://github.com/ErykKul/dataverse into trunk
ErykKul Dec 13, 2022
b33526a
merged develop branch
ErykKul Dec 13, 2022
5b292be
Merge branch '8822_incomplete_datasets_via_api' of https://github.com…
ErykKul Dec 13, 2022
4fd50e1
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul Dec 16, 2022
786fa1e
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul Dec 23, 2022
320087d
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul Feb 20, 2023
f0c1fef
merged develop branch
ErykKul Apr 17, 2023
7f9a8a7
typo fix
ErykKul Apr 17, 2023
2de1ad2
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul Apr 21, 2023
1eb841d
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul May 4, 2023
fdc50da
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul May 8, 2023
53faec9
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul May 12, 2023
1f6e916
wording: invalid -> incomplete
ErykKul May 12, 2023
b8b2b89
Merge branch '8822_incomplete_datasets_via_api' of https://github.com…
ErykKul May 12, 2023
884d1c7
wording: invalid -> incomplete
ErykKul May 12, 2023
11de6d9
publish button hidden when metadata is incomplete
ErykKul May 12, 2023
b8b5075
#8822 fix underline length
sekmiller May 16, 2023
86b0625
Merge branch 'IQSS:develop' into 8822_incomplete_datasets_via_api
ErykKul May 17, 2023
c739cbc
publish button is now disabled i.s.o. hidden when metadata is not valid
ErykKul May 17, 2023
048ff4b
migrated settings to jvm settings
ErykKul May 17, 2023
25f53b3
style: rephrase JvmSettings for invalid dataset deposition
poikilotherm May 18, 2023
dce8b63
docs: adapt config settings to renaming for incomplete dataset deposi…
poikilotherm May 18, 2023
bd83490
feat: add info API endpoint to expose incomplete metadata support status
poikilotherm May 18, 2023
3698abe
docs,style: extend docs on incomplete metadata via native api
poikilotherm May 18, 2023
2479b3d
Merge branch 'develop' into 8822_incomplete_datasets_via_api
poikilotherm May 18, 2023
bc5f44c
doc improvements
ErykKul May 22, 2023
3518da8
doc improvements
ErykKul May 22, 2023
fe46cde
when title of dataset is not set use global id as display name
ErykKul May 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions conf/solr/8.11.1/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@
<field name="geolocation" type="location_rpt" multiValued="true" stored="true" indexed="true"/>
<!-- https://solr.apache.org/guide/8_11/spatial-search.html#bboxfield -->
<field name="boundingBox" type="bbox" multiValued="true" stored="true" indexed="true"/>

<!-- incomplete datasets issue 8822 -->
<field name="datasetValid" type="boolean" stored="true" indexed="true" multiValued="false"/>

<!--
METADATA SCHEMA FIELDS
Expand Down Expand Up @@ -470,6 +473,8 @@
<!-- <copyField source="*_ss" dest="_text_" maxChars="3000"/> -->
<!-- <copyField source="*_i" dest="_text_" maxChars="3000"/> -->

<copyField source="datasetValid" dest="_text_" maxChars="3000"/>

<!--
METADATA SCHEMA FIELDS
Now following: copyFields to copy the contents of the metadata fields above to a
Expand Down
14 changes: 14 additions & 0 deletions doc/release-notes/8822-incomplete-datasets-via-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### Creating datasets with incomplete metadata through API

The create dataset API call (POST to /api/dataverses/#dataverseId/datasets) is extended with the "doNotValidate" parameter. However, in order to be able to create a dataset with incomplete metadata, the solr configuration must be updated first with the new "schema.xml" file (do not forget to run the metadata fields update script when you use custom metadata). Reindexing is optional, but recommended. Also, even when this feature is not used, it is recommended to update the solar configuration and reindex the metadata. Finally, this new feature can be activated with the "dataverse.api.allow-incomplete-metadata" JVM option.

You can also enable a valid/incomplete metadata filter in the "My Data" page using the "dataverse.ui.show-validity-filter" JVM option. By default, this filter is not shown. When you wish to use this filter, you must reindex the datasets first, otherwise datasets with valid metadata will not be shown in the results.

It is not possible to publish datasets with incomplete or incomplete metadata. By default, you also cannot send such datasets for review. If you wish to enable sending for review of datasets with incomplete metadata, turn on the "dataverse.ui.allow-review-for-incomplete" JVM option.

In order to customize the wording and add translations to the UI sections extended by this feature, you can edit the "Bundle.properties" file and the localized versions of that file. The property keys used by this feature are:
- incomplete
- valid
- dataset.message.incomplete.warning
- mydataFragment.validity
- dataverses.api.create.dataset.error.mustIncludeAuthorName
75 changes: 75 additions & 0 deletions doc/sphinx-guides/source/api/native-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,60 @@ To create a dataset, you must supply a JSON file that contains at least the foll
- Description Text
- Subject

Submit Incomplete Dataset
^^^^^^^^^^^^^^^^^^^^^^^^^

**Note:** This feature requires :ref:`dataverse.api.allow-incomplete-metadata` to be enabled and your Solr
Schema to be up-to-date with the ``datasetValid`` field.

Providing a ``.../datasets?doNotValidate=true`` query parameter turns off the validation of metadata.
In this case, only the "Author Name" is required. For example, a minimal JSON file would look like this:

.. code-block:: json
:name: dataset-incomplete.json

{
"datasetVersion": {
"metadataBlocks": {
"citation": {
"fields": [
{
"value": [
{
"authorName": {
"value": "Finch, Fiona",
"typeClass": "primitive",
"multiple": false,
"typeName": "authorName"
}
}
],
"typeClass": "compound",
"multiple": true,
"typeName": "author"
}
],
"displayName": "Citation Metadata"
}
}
}
}

The following is an example HTTP call with deactivated validation:

.. code-block:: bash

export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export PARENT=root
export SERVER_URL=https://demo.dataverse.org

curl -H X-Dataverse-key:$API_TOKEN -X POST "$SERVER_URL/api/dataverses/$PARENT/datasets?doNotValidate=true" --upload-file dataset-incomplete.json -H 'Content-type:application/json'

**Note:** You may learn about an instance's support for deposition of incomplete datasets via :ref:`info-incomplete-metadata`.

Submit Dataset
^^^^^^^^^^^^^^

As a starting point, you can download :download:`dataset-finch1.json <../../../../scripts/search/tests/data/dataset-finch1.json>` and modify it to meet your needs. (:download:`dataset-finch1_fr.json <../../../../scripts/api/data/dataset-finch1_fr.json>` is a variant of this file that includes setting the metadata language (see :ref:`:MetadataLanguages`) to French (fr). In addition to this minimal example, you can download :download:`dataset-create-new-all-default-fields.json <../../../../scripts/api/data/dataset-create-new-all-default-fields.json>` which populates all of the metadata fields that ship with a Dataverse installation.)

The curl command below assumes you have kept the name "dataset-finch1.json" and that this file is in your current working directory.
Expand Down Expand Up @@ -3191,6 +3245,27 @@ The fully expanded example above (without environment variables) looks like this

curl https://demo.dataverse.org/api/info/apiTermsOfUse

.. _info-incomplete-metadata:

Show Support Of Incomplete Metadata Deposition
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Learn if an instance has been configured to allow deposition of incomplete datasets via the API.
See also :ref:`create-dataset-command` and :ref:`dataverse.api.allow-incomplete-metadata`

.. code-block:: bash

export SERVER_URL=https://demo.dataverse.org

curl $SERVER_URL/api/info/settings/incompleteMetadataViaApi

The fully expanded example above (without environment variables) looks like this:

.. code-block:: bash

curl https://demo.dataverse.org/api/info/settings/incompleteMetadataViaApi


.. _metadata-blocks-api:

Metadata Blocks
Expand Down
36 changes: 36 additions & 0 deletions doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2344,6 +2344,19 @@ Can also be set via any `supported MicroProfile Config API source`_, e.g. the en
**WARNING:** For security, do not use the sources "environment variable" or "system property" (JVM option) in a
production context! Rely on password alias, secrets directory or cloud based sources instead!

.. _dataverse.api.allow-incomplete-metadata:

dataverse.api.allow-incomplete-metadata
+++++++++++++++++++++++++++++++++++++++

When enabled, dataset with incomplete metadata can be submitted via API for later corrections.
See :ref:`create-dataset-command` for details.

Defaults to ``false``.

Can also be set via any `supported MicroProfile Config API source`_, e.g. the environment variable
``DATAVERSE_API_ALLOW_INCOMPLETE_METADATA``. Will accept ``[tT][rR][uU][eE]|1|[oO][nN]`` as "true" expressions.

.. _dataverse.signposting.level1-author-limit:

dataverse.signposting.level1-author-limit
Expand Down Expand Up @@ -2383,6 +2396,29 @@ The default is false.

Can also be set via *MicroProfile Config API* sources, e.g. the environment variable ``DATAVERSE_MAIL_CC_SUPPORT_ON_CONTACT_EMAIL``.

dataverse.ui.allow-review-for-incomplete
++++++++++++++++++++++++++++++++++++++++

Determines if dataset submitted via API with incomplete metadata (for later corrections) can be submitted for review
from the UI.

Defaults to ``false``.

Can also be set via any `supported MicroProfile Config API source`_, e.g. the environment variable
``DATAVERSE_UI_ALLOW_REVIEW_FOR_INCOMPLETE``. Will accept ``[tT][rR][uU][eE]|1|[oO][nN]`` as "true" expressions.

dataverse.ui.show-validity-filter
+++++++++++++++++++++++++++++++++

When enabled, the filter for validity of metadata is shown in "My Data" page.
**Note:** When you wish to use this filter, you must reindex the datasets first, otherwise datasets with valid metadata
will not be shown in the results.

Defaults to ``false``.

Can also be set via any `supported MicroProfile Config API source`_, e.g. the environment variable
``DATAVERSE_UI_SHOW_VALIDITY_FILTER``. Will accept ``[tT][rR][uU][eE]|1|[oO][nN]`` as "true" expressions.


.. _feature-flags:

Expand Down
2 changes: 2 additions & 0 deletions doc/sphinx-guides/source/user/account.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ Microsoft Azure AD, GitHub, and Google Log In

You can also convert your Dataverse installation account to use authentication provided by GitHub, Microsoft, or Google. These options may be found in the "Other options" section of the log in page, and function similarly to how ORCID is outlined above. If you would like to convert your account away from using one of these services for log in, then you can follow the same steps as listed above for converting away from the ORCID log in.

.. _my-data:

My Data
-------

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/Dataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,12 @@ public <T> T accept(Visitor<T> v) {
@Override
public String getDisplayName() {
DatasetVersion dsv = getReleasedVersion();
return dsv != null ? dsv.getTitle() : getLatestVersion().getTitle();
String result = dsv != null ? dsv.getTitle() : getLatestVersion().getTitle();
boolean resultIsEmpty = result == null || "".equals(result);
if (resultIsEmpty && getGlobalId() != null) {
return getGlobalId().asString();
}
return result;
}

@Override
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2168,10 +2168,24 @@ private void displayPublishMessage(){
if (workingVersion.isDraft() && workingVersion.getId() != null && canUpdateDataset()
&& !dataset.isLockedFor(DatasetLock.Reason.finalizePublication)
&& (canPublishDataset() || !dataset.isLockedFor(DatasetLock.Reason.InReview) )){
JsfHelper.addWarningMessage(datasetService.getReminderString(dataset, canPublishDataset()));
JsfHelper.addWarningMessage(datasetService.getReminderString(dataset, canPublishDataset(), false, isValid()));
}
}

public boolean isValid() {
DatasetVersion version = dataset.getLatestVersion();
if (!version.isDraft()) {
return true;
}
DatasetVersion newVersion = version.cloneDatasetVersion();
newVersion.setDatasetFields(newVersion.initDatasetFields());
return newVersion.isValid();
}

public boolean isValidOrCanReviewIncomplete() {
return isValid() || JvmSettings.UI_ALLOW_REVIEW_INCOMPLETE.lookupOptional(Boolean.class).orElse(false);
}

private void displayLockInfo(Dataset dataset) {
// Various info messages, when the dataset is locked (for various reasons):
if (dataset.isLocked() && canUpdateDataset()) {
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/edu/harvard/iq/dataverse/DatasetServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,6 @@ public void exportAllDatasets(boolean forceReExport) {
}

}


@Asynchronous
public void reExportDatasetAsync(Dataset dataset) {
Expand Down Expand Up @@ -757,13 +756,9 @@ public void exportDataset(Dataset dataset, boolean forceReExport) {

}

public String getReminderString(Dataset dataset, boolean canPublishDataset) {
return getReminderString( dataset, canPublishDataset, false);
}

//get a string to add to save success message
//depends on page (dataset/file) and user privleges
public String getReminderString(Dataset dataset, boolean canPublishDataset, boolean filePage) {
public String getReminderString(Dataset dataset, boolean canPublishDataset, boolean filePage, boolean isValid) {

String reminderString;

Expand All @@ -789,6 +784,10 @@ public String getReminderString(Dataset dataset, boolean canPublishDataset, bool
}
}

if (!isValid) {
reminderString = reminderString + "<br/><b style=\"color:red;\"> " + BundleUtil.getStringFromBundle("dataset.message.incomplete.warning") + "</b>";
}

if (reminderString != null) {
return reminderString;
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.StringUtils;

Expand All @@ -77,6 +76,7 @@
public class DatasetVersion implements Serializable {

private static final Logger logger = Logger.getLogger(DatasetVersion.class.getCanonicalName());
private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator();

/**
* Convenience comparator to compare dataset versions by their version number.
Expand Down Expand Up @@ -1706,8 +1706,6 @@ public String getSemanticVersion() {

public List<ConstraintViolation<DatasetField>> validateRequired() {
List<ConstraintViolation<DatasetField>> returnListreturnList = new ArrayList<>();
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
for (DatasetField dsf : this.getFlatDatasetFields()) {
dsf.setValidationMessage(null); // clear out any existing validation message
Set<ConstraintViolation<DatasetField>> constraintViolations = validator.validate(dsf);
Expand All @@ -1721,11 +1719,13 @@ public List<ConstraintViolation<DatasetField>> validateRequired() {
return returnListreturnList;
}

public boolean isValid() {
return validate().isEmpty();
}

public Set<ConstraintViolation> validate() {
Set<ConstraintViolation> returnSet = new HashSet<>();

ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();

for (DatasetField dsf : this.getFlatDatasetFields()) {
dsf.setValidationMessage(null); // clear out any existing validation message
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/FilePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,19 @@ public String init() {
private void displayPublishMessage(){
if (fileMetadata.getDatasetVersion().isDraft() && canUpdateDataset()
&& (canPublishDataset() || !fileMetadata.getDatasetVersion().getDataset().isLockedFor(DatasetLock.Reason.InReview))){
JsfHelper.addWarningMessage(datasetService.getReminderString(fileMetadata.getDatasetVersion().getDataset(), canPublishDataset(), true));
JsfHelper.addWarningMessage(datasetService.getReminderString(fileMetadata.getDatasetVersion().getDataset(), canPublishDataset(), true, isValid()));
}
}

public boolean isValid() {
if (!fileMetadata.getDatasetVersion().isDraft()) {
return true;
}
DatasetVersion newVersion = fileMetadata.getDatasetVersion().cloneDatasetVersion();
newVersion.setDatasetFields(newVersion.initDatasetFields());
return newVersion.isValid();
}

private boolean canViewUnpublishedDataset() {
return permissionsWrapper.canViewUnpublishedDataset( dvRequestService.getDataverseRequest(), fileMetadata.getDatasetVersion().getDataset());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import edu.harvard.iq.dataverse.util.MailUtil;
import edu.harvard.iq.dataverse.util.StringUtil;
import edu.harvard.iq.dataverse.util.SystemConfig;
import edu.harvard.iq.dataverse.util.json.JsonUtil;
import edu.harvard.iq.dataverse.UserNotification.Type;

import java.time.LocalDate;
Expand Down Expand Up @@ -708,4 +707,5 @@ public boolean isCustomLicenseAllowed() {
}
return customLicenseAllowed;
}

}
Loading