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

adding publication statuses to search api response #10738

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Search API (/api/search) response will now include publicationStatuses in the Json response as long as the list is not empty

Example:
```javascript
"items": [
{
"name": "Darwin's Finches",
...
"publicationStatuses": [
"Unpublished",
"Draft"
],
(etc, etc)
```
16 changes: 16 additions & 0 deletions doc/sphinx-guides/source/api/search.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ https://demo.dataverse.org/api/search?q=trees
"identifier_of_dataverse":"dvbe69f5e1",
"name_of_dataverse":"dvbe69f5e1",
"citation":"Finch, Fiona; Spruce, Sabrina; Poe, Edgar Allen; Mulligan, Hercules, 2019, \"Darwin's Finches\", https://doi.org/10.70122/FK2/MB5VGR, Root, V3",
"publicationStatuses": [
"Published"
],
"storageIdentifier":"file://10.70122/FK2/MB5VGR",
"subjects":[
"Astronomy and Astrophysics",
Expand Down Expand Up @@ -207,6 +210,9 @@ In this example, ``show_relevance=true`` matches per field are shown. Available
"published_at":"2016-05-10T12:57:45Z",
"citationHtml":"Finch, Fiona, 2016, \"Darwin's Finches\", <a href=\"http://dx.doi.org/10.5072/FK2/G2VPE7\" target=\"_blank\">http://dx.doi.org/10.5072/FK2/G2VPE7</a>, Root Dataverse, V1",
"citation":"Finch, Fiona, 2016, \"Darwin's Finches\", http://dx.doi.org/10.5072/FK2/G2VPE7, Root Dataverse, V1",
"publicationStatuses": [
"Published"
],
"matches":[
{
"authorName":{
Expand Down Expand Up @@ -297,6 +303,9 @@ The above example ``fq=publicationStatus:Published`` retrieves only "RELEASED" v
"identifier_of_dataverse": "rahman",
"name_of_dataverse": "mdmizanur rahman Dataverse collection",
"citation": "Finch, Fiona, 2019, \"Darwin's Finches\", https://doi.org/10.70122/FK2/GUAS41, Demo Dataverse, V1",
"publicationStatuses": [
"Published"
],
"storageIdentifier": "file://10.70122/FK2/GUAS41",
"subjects": [
"Medicine, Health and Life Sciences"
Expand Down Expand Up @@ -330,6 +339,9 @@ The above example ``fq=publicationStatus:Published`` retrieves only "RELEASED" v
"identifier_of_dataverse": "demo",
"name_of_dataverse": "Demo Dataverse",
"citation": "Finch, Fiona, 2020, \"Darwin's Finches\", https://doi.org/10.70122/FK2/7ZXYRH, Demo Dataverse, V1",
"publicationStatuses": [
"Published"
],
"storageIdentifier": "file://10.70122/FK2/7ZXYRH",
"subjects": [
"Medicine, Health and Life Sciences"
Expand Down Expand Up @@ -386,6 +398,10 @@ The above example ``metadata_fields=citation:*`` returns under "metadataBlocks"
"identifier_of_dataverse": "Sample_data",
"name_of_dataverse": "Sample Data",
"citation": "Métropole, 2021, \"JDD avec GeoJson 2021-07-13T10:23:46.409Z\", https://doi.org/10.5072/FK2/GIWCKB, Root, DRAFT VERSION",
"publicationStatuses": [
"Unpublished",
"Draft"
],
"storageIdentifier": "file://10.5072/FK2/GIWCKB",
"subjects": [
"Other"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ public JsonObjectBuilder json(boolean showRelevance, boolean showEntityIds, bool
nullSafeJsonBuilder.add("entity_id", this.entityId);
}
}
if (!getPublicationStatuses().isEmpty()) {
nullSafeJsonBuilder.add("publicationStatuses", getPublicationStatusesAsJSON());
}

if (this.entity == null) {

Expand Down
1 change: 1 addition & 0 deletions src/test/java/edu/harvard/iq/dataverse/api/SearchIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public void testSearchPermisions() throws InterruptedException {
.body("data.total_count", CoreMatchers.is(1))
.body("data.count_in_response", CoreMatchers.is(1))
.body("data.items[0].name", CoreMatchers.is("Darwin's Finches"))
.body("data.items[0].publicationStatuses", CoreMatchers.hasItems("Unpublished", "Draft"))
.statusCode(OK.getStatusCode());

Response publishDataverse = UtilIT.publishDataverseViaSword(dataverseAlias, apiToken1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,29 @@ public void testSetPublicationStatuses14() {
assertTrue(this.solrSearchResult.isDeaccessionedState());
}

@Test
public void testSetPublicationStatusesJson() {

boolean showRelevance = false;
boolean showEntityIds = false;
boolean showApiUrls = false;

SolrSearchResult result01 = new SolrSearchResult("myQuery", "myName");
result01.setType(SearchConstants.DATAVERSES);
result01.setPublicationStatuses(List.of("Unpublished", "Draft"));
JsonObjectBuilder actual01 = result01.json(showRelevance, showEntityIds, showApiUrls);
JsonObject actual = actual01.build();
System.out.println("actual: " + actual);

JsonObjectBuilder expResult = Json.createObjectBuilder();
expResult.add("type", SearchConstants.DATAVERSE);
expResult.add("publicationStatuses", Json.createArrayBuilder().add("Unpublished").add("Draft").build());
JsonObject expected = expResult.build();
System.out.println("expect: " + expected);

assertEquals(expected, actual);
}

@Test
public void testJson() {

Expand Down
Loading