Skip to content

Commit 200a45a

Browse files
committed
don't add "software" or "workflow" with Flyway #10517
1 parent 1beed5d commit 200a45a

File tree

8 files changed

+48
-15
lines changed

8 files changed

+48
-15
lines changed

doc/release-notes/10517-datasetType.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
### Initial Support for Dataset Types (Dataset, Software, Workflow)
1+
### Initial Support for Dataset Types
22

3-
Datasets now have types. By default the dataset type will be "dataset", but out of the box datasets can have a type of "software" or "workflow" as well. For more details see <https://dataverse-guide--10694.org.readthedocs.build/en/10694/user/dataset-management.html#dataset-types> and #10517. Please note that this feature is highly experimental and is expected to evolve.
3+
Out of the box, all datasets have the type "dataset" but superusers can add additional types. At this time the type can only be set at creation time via API. The types "dataset", "software", and "workflow" will be sent to DataCite when the dataset is published.
4+
5+
For details see <https://dataverse-guide--10694.org.readthedocs.build/en/10694/user/dataset-management.html#dataset-types> and #10517. Please note that this feature is highly experimental and is expected to evolve.
46

57
Upgrade instructions
68
--------------------

doc/sphinx-guides/source/api/native-api.rst

+10-4
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,9 @@ You should expect an HTTP 200 ("OK") response and JSON indicating the database I
788788
Create a Dataset with a Dataset Type (Software, etc.)
789789
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
790790

791-
Follow :ref:`api-create-dataset` as normal but include a line like `"datasetType": "software"` in your JSON. You can check which types are supported by your installation using the :ref:`api-list-dataset-types` API endpoint.
791+
By default, datasets are given the type "dataset" but if your installation had added additional types (see :ref:`api-add-dataset-type`), you can specify the type.
792+
793+
Follow :ref:`api-create-dataset` as normal but include a line like ``"datasetType": "software"`` in your JSON. You can check which types are supported by your installation using the :ref:`api-list-dataset-types` API endpoint.
792794

793795
Here is an example JSON file for reference: :download:`dataset-create-software.json <../_static/api/dataset-create-software.json>`.
794796

@@ -841,6 +843,8 @@ Before calling the API, make sure the data files referenced by the ``POST``\ ed
841843
Import a Dataset with a Dataset Type (Software, etc.)
842844
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
843845

846+
By default, datasets are given the type "dataset" but if your installation had added additional types (see :ref:`api-add-dataset-type`), you can specify the type.
847+
844848
The same native JSON file as above under :ref:`api-create-dataset-with-type` can be used when importing a dataset.
845849

846850
A file like this is the only difference. Otherwise, follow :ref:`api-import-dataset` as normal.
@@ -3066,21 +3070,23 @@ The fully expanded example above (without environment variables) looks like this
30663070
Add Dataset Type
30673071
^^^^^^^^^^^^^^^^
30683072
3069-
Superuser only.
3073+
Note: Before you add any types of your own, there should be a single type called "dataset". If you add "software" or "workflow", these types will be sent to DataCite (if you use DataCite). Otherwise, the only functionality you gain currently from adding types is an entry in the "Dataset Type" facet but be advised that if you add a type other than "software" or "workflow", you will need to add your new type to your Bundle.properties file for it to appear in Title Case rather than lower case in the "Dataset Type" facet.
3074+
3075+
With all that said, we'll add a "software" type in the example below. This API endpoint is superuser only.
30703076
30713077
.. code-block:: bash
30723078
30733079
export API_TOKEN=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
30743080
export SERVER_URL=https://demo.dataverse.org
3075-
export JSON='{"name": "newType"}'
3081+
export JSON='{"name": "software"}'
30763082
30773083
curl -H "X-Dataverse-key:$API_TOKEN" -H "Content-Type: application/json" "$SERVER_URL/api/datasets/datasetTypes" -X POST -d $JSON
30783084
30793085
The fully expanded example above (without environment variables) looks like this:
30803086
30813087
.. code-block:: bash
30823088
3083-
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -H "Content-Type: application/json" "https://demo.dataverse.org/api/datasets/datasetTypes" -X POST -d '{"name": "newType"}'
3089+
curl -H "X-Dataverse-key:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -H "Content-Type: application/json" "https://demo.dataverse.org/api/datasets/datasetTypes" -X POST -d '{"name": "software"}'
30843090
30853091
.. _api-delete-dataset-type:
30863092

doc/sphinx-guides/source/developers/dataset-semantic-metadata-api.rst

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ An example jsonld file is available at :download:`dataset-create.jsonld <../_sta
112112
Create a Dataset with a Dataset Type
113113
------------------------------------
114114

115+
By default, datasets are given the type "dataset" but if your installation had added additional types (see :ref:`api-add-dataset-type`), you can specify the type.
116+
115117
An example JSON-LD file is available at :download:`dataset-create-software.jsonld <../_static/api/dataset-create-software.jsonld>`.
116118

117119
You can use this file with the normal :ref:`api-semantic-create-dataset` endpoint above.

doc/sphinx-guides/source/user/dataset-management.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -787,9 +787,9 @@ If you deaccession the most recently published version of the dataset but not al
787787
Dataset Types
788788
=============
789789

790-
Datasets can have a dataset type such as "dataset", "software", or "workflow".
790+
Out of the box, all datasets have a dataset type of "dataset". Superusers can add additional types such as "software" or "workflow" using the :ref:`api-add-dataset-type` API endpoint.
791791

792-
When browsing or searching, these types appear under a facet called "Dataset Type".
792+
Once more than one type appears in search results, a facet called "Dataset Type" will appear allowing you to filter down to a certain type.
793793

794794
If your installation is configured to use DataCite as a persistent ID (PID) provider, the appropriate type ("Dataset", "Software", "Workflow") will be sent to DataCite when the dataset is published for those three types.
795795

src/main/java/edu/harvard/iq/dataverse/dataset/DatasetType.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727

2828
public class DatasetType implements Serializable {
2929

30-
public static final String DEFAULT_DATASET_TYPE = "dataset";
30+
public static final String DATASET_TYPE_DATASET = "dataset";
31+
public static final String DATASET_TYPE_SOFTWARE = "software";
32+
public static final String DATASET_TYPE_WORKFLOW = "workflow";
33+
public static final String DEFAULT_DATASET_TYPE = DATASET_TYPE_DATASET;
3134

3235
@Id
3336
@GeneratedValue(strategy = GenerationType.IDENTITY)

src/main/java/edu/harvard/iq/dataverse/pidproviders/doi/XmlMetadataTemplate.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ public String generateXML(DvObject dvObject) {
203203
Dataset dataset = (Dataset) dvObject;
204204
String datasetTypeName = dataset.getDatasetType().getName();
205205
resourceTypeGeneral = switch (datasetTypeName) {
206-
case "dataset" ->
206+
case DatasetType.DATASET_TYPE_DATASET ->
207207
"Dataset";
208-
case "software" ->
208+
case DatasetType.DATASET_TYPE_SOFTWARE ->
209209
"Software";
210-
case "workflow" ->
210+
case DatasetType.DATASET_TYPE_WORKFLOW ->
211211
"Workflow";
212212
default ->
213213
"Dataset";

src/main/resources/db/migration/V6.3.0.2.sql

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
-- Dataset types have been added. See #10517 and #10694
22
--
3-
-- Insert some types (dataset is the default).
3+
-- Insert the default dataset type: dataset.
44
INSERT INTO datasettype (name) VALUES ('dataset');
5-
INSERT INTO datasettype (name) VALUES ('software');
6-
INSERT INTO datasettype (name) VALUES ('workflow');
75
--
86
-- Add the new column (if it doesn't exist).
97
ALTER TABLE dataset ADD COLUMN IF NOT EXISTS datasettype_id bigint;

src/test/java/edu/harvard/iq/dataverse/api/DatasetTypesIT.java

+22
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@ public class DatasetTypesIT {
2020
@BeforeAll
2121
public static void setUpClass() {
2222
RestAssured.baseURI = UtilIT.getRestAssuredBaseUri();
23+
24+
Response getSoftwareType = UtilIT.getDatasetTypeByName(DatasetType.DATASET_TYPE_SOFTWARE);
25+
getSoftwareType.prettyPrint();
26+
27+
String typeFound = JsonPath.from(getSoftwareType.getBody().asString()).getString("data.name");
28+
System.out.println("type found: " + typeFound);
29+
if (DatasetType.DATASET_TYPE_SOFTWARE.equals(typeFound)) {
30+
return;
31+
}
32+
33+
System.out.println("The \"software\" type wasn't found. Create it.");
34+
Response createUser = UtilIT.createRandomUser();
35+
createUser.then().assertThat().statusCode(OK.getStatusCode());
36+
String username = UtilIT.getUsernameFromResponse(createUser);
37+
String apiToken = UtilIT.getApiTokenFromResponse(createUser);
38+
UtilIT.setSuperuserStatus(username, true).then().assertThat().statusCode(OK.getStatusCode());
39+
40+
String jsonIn = Json.createObjectBuilder().add("name", DatasetType.DATASET_TYPE_SOFTWARE).build().toString();
41+
42+
Response typeAdded = UtilIT.addDatasetType(jsonIn, apiToken);
43+
typeAdded.prettyPrint();
44+
typeAdded.then().assertThat().statusCode(OK.getStatusCode());
2345
}
2446

2547
@Test

0 commit comments

Comments
 (0)