Skip to content

Commit

Permalink
Data Capture Module: add dataType to citation IQSS#3145
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed May 31, 2016
1 parent 2935cde commit c717523
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 1 deletion.
2 changes: 2 additions & 0 deletions conf/solr/4.6.0/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@
<field name="dataCollectionSituation" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="dataCollector" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="dataSources" type="text_en" multiValued="true" stored="true" indexed="true"/>
<field name="dataType" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="datadePublicao" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="datasetContact" type="text_en" multiValued="true" stored="true" indexed="true"/>
<field name="datasetContactAffiliation" type="text_en" multiValued="true" stored="true" indexed="true"/>
Expand Down Expand Up @@ -683,6 +684,7 @@
<copyField source="dataCollectionSituation" dest="text" maxChars="3000"/>
<copyField source="dataCollector" dest="text" maxChars="3000"/>
<copyField source="dataSources" dest="text" maxChars="3000"/>
<copyField source="dataType" dest="text" maxChars="3000"/>
<copyField source="datadePublicao" dest="text" maxChars="3000"/>
<copyField source="datasetContact" dest="text" maxChars="3000"/>
<copyField source="datasetContactAffiliation" dest="text" maxChars="3000"/>
Expand Down
7 changes: 6 additions & 1 deletion scripts/api/data/metadatablocks/citation.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
originOfSources Origin of Sources For historical materials, information about the origin of the sources and the rules followed in establishing the sources should be specified. textbox 74 FALSE FALSE FALSE FALSE FALSE FALSE citation
characteristicOfSources Characteristic of Sources Noted Assessment of characteristics and source material. textbox 75 FALSE FALSE FALSE FALSE FALSE FALSE citation
accessToSources Documentation and Access to Sources Level of documentation of the original sources. textbox 76 FALSE FALSE FALSE FALSE FALSE FALSE citation
dataType Data Type We currently support X-ray diffraction datasets. If you would like to deposit any other dataset type please contact us first at help@sbgrid.org. text 1 TRUE TRUE FALSE TRUE FALSE FALSE citation

This comment has been minimized.

Copy link
@pdurbin

pdurbin May 31, 2016

Author Owner

Whoops, we can't leave the SBGrid email address in here.

#controlledVocabulary DatasetField Value identifier displayOrder
subject Agricultural Sciences D01 0
subject Arts and Humanities D0 1
Expand Down Expand Up @@ -314,4 +315,8 @@
language Yoruba 181
language Zhuang, Chuang 182
language Zulu 183
language Not applicable 184
language Not applicable 184
dataType X-Ray Diffraction xray 0
dataType Structural Model sm 1

This comment has been minimized.

Copy link
@pdurbin

pdurbin Jun 9, 2016

Author Owner

The "Structural Model" dataType may have data that changes: http://irclog.iq.harvard.edu/dataverse/2016-06-09#i_36529

dataType Micro-Electron Diffraction me 2
dataType Lattice Light-Sheet Microscopy llsm 3
52 changes: 52 additions & 0 deletions src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
import org.junit.AfterClass;
import static com.jayway.restassured.RestAssured.given;
import static junit.framework.Assert.assertEquals;
import com.jayway.restassured.path.json.JsonPath;
import java.util.List;
import java.util.Map;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

public class DatasetsIT {

Expand Down Expand Up @@ -40,6 +46,52 @@ public void testCreateDataset() {

}

@Test
public void testCreateDatasetWithDcmDependency() {

Response createUser = UtilIT.createRandomUser();
createUser.prettyPrint();
String username = UtilIT.getUsernameFromResponse(createUser);
String apiToken = UtilIT.getApiTokenFromResponse(createUser);

Response createDataverseResponse = UtilIT.createRandomDataverse(apiToken);
createDataverseResponse.prettyPrint();
String dataverseAlias = UtilIT.getAliasFromResponse(createDataverseResponse);

Response createDatasetResponse = UtilIT.createDatasetWithDcmDependency(dataverseAlias, apiToken);
createDatasetResponse.prettyPrint();
Integer datasetId = UtilIT.getDatasetIdFromResponse(createDatasetResponse);

Response getDatasetResponse = given()
.header(UtilIT.API_TOKEN_HTTP_HEADER, apiToken)
.get("/api/datasets/" + datasetId);
getDatasetResponse.prettyPrint();
getDatasetResponse.then().assertThat()
.statusCode(200);

final List<Map<String, ?>> dataTypeField = JsonPath.with(getDatasetResponse.body().asString())
.get("data.latestVersion.metadataBlocks.citation.fields.findAll { it.typeName == 'dataType' }");
logger.fine("dataTypeField: " + dataTypeField);
assertThat(dataTypeField.size(), equalTo(1));
assertEquals("dataType", dataTypeField.get(0).get("typeName"));
assertEquals("controlledVocabulary", dataTypeField.get(0).get("typeClass"));
assertEquals("X-Ray Diffraction", dataTypeField.get(0).get("value"));
assertTrue(dataTypeField.get(0).get("multiple").equals(false));

Response deleteDatasetResponse = UtilIT.deleteDatasetViaNativeApi(datasetId, apiToken);
deleteDatasetResponse.prettyPrint();
assertEquals(200, deleteDatasetResponse.getStatusCode());

Response deleteDataverseResponse = UtilIT.deleteDataverse(dataverseAlias, apiToken);
deleteDataverseResponse.prettyPrint();
assertEquals(200, deleteDataverseResponse.getStatusCode());

Response deleteUserResponse = UtilIT.deleteUser(username);
deleteUserResponse.prettyPrint();
assertEquals(200, deleteUserResponse.getStatusCode());

}

@Test
public void testGetDdi() {
String persistentIdentifier = "FIXME";
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/edu/harvard/iq/dataverse/api/UtilIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,27 @@ private static String getDatasetJson() {
}
}

static Response createDatasetWithDcmDependency(String dataverseAlias, String apiToken) {
String jsonIn = getDatasetJsonWithDcmDependency();
Response createDatasetResponse = given()
.header(API_TOKEN_HTTP_HEADER, apiToken)
.body(jsonIn)
.contentType("application/json")
.post("/api/dataverses/" + dataverseAlias + "/datasets");
return createDatasetResponse;
}

private static String getDatasetJsonWithDcmDependency() {
File datasetVersionJson = new File("src/test/java/edu/harvard/iq/dataverse/api/x-ray-diffraction.json");
try {
String datasetVersionAsJson = new String(Files.readAllBytes(Paths.get(datasetVersionJson.getAbsolutePath())));
return datasetVersionAsJson;
} catch (IOException ex) {
Logger.getLogger(UtilIT.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}

static Response createRandomDatasetViaSwordApi(String dataverseToCreateDatasetIn, String apiToken) {
String xmlIn = getDatasetXml(getRandomIdentifier(), getRandomIdentifier(), getRandomIdentifier());
return createDatasetViaSwordApiFromXML(dataverseToCreateDatasetIn, xmlIn, apiToken);
Expand Down
173 changes: 173 additions & 0 deletions src/test/java/edu/harvard/iq/dataverse/api/x-ray-diffraction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
{
"datasetVersion": {
"metadataBlocks": {
"citation": {
"displayName": "Citation Metadata",
"fields": [
{
"typeName": "title",
"multiple": false,
"typeClass": "primitive",
"value": "X-Ray Diffraction data from Lin28A/let-7g microRNA complex, source of 3TS2 structure"
},
{
"typeName": "dataType",
"multiple": false,
"typeClass": "controlledVocabulary",
"value": "X-Ray Diffraction"
},
{
"typeName": "author",
"multiple": true,
"typeClass": "compound",
"value": [
{
"authorName": {
"typeName": "authorName",
"multiple": false,
"typeClass": "primitive",
"value": "Sliz, Piotr"
},
"authorAffiliation": {
"typeName": "authorAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "Harvard Medical School"
},
"authorIdentifierScheme": {
"typeName": "authorIdentifierScheme",
"multiple": false,
"typeClass": "controlledVocabulary",
"value": "ORCID"
},
"authorIdentifier": {
"typeName": "authorIdentifier",
"multiple": false,
"typeClass": "primitive",
"value": "0000-0002-6522-0835"
}
}
]
},
{
"typeName": "datasetContact",
"multiple": true,
"typeClass": "compound",
"value": [
{
"datasetContactName": {
"typeName": "datasetContactName",
"multiple": false,
"typeClass": "primitive",
"value": "Admin, Dataverse"
},
"datasetContactAffiliation": {
"typeName": "datasetContactAffiliation",
"multiple": false,
"typeClass": "primitive",
"value": "sbgrid.org / SBDG"
},
"datasetContactEmail": {
"typeName": "datasetContactEmail",
"multiple": false,
"typeClass": "primitive",
"value": "generic@mailinator.com"
}
}
]
},
{
"typeName": "dsDescription",
"multiple": true,
"typeClass": "compound",
"value": [
{
"dsDescriptionValue": {
"typeName": "dsDescriptionValue",
"multiple": false,
"typeClass": "primitive",
"value": "Native Dataset"
}
}
]
},
{
"typeName": "subject",
"multiple": true,
"typeClass": "controlledVocabulary",
"value": [
"Medicine, Health and Life Sciences"
]
},
{
"typeName": "publication",
"multiple": true,
"typeClass": "compound",
"value": [
{
"publicationCitation": {
"typeName": "publicationCitation",
"multiple": false,
"typeClass": "primitive",
"value": "Nam Y, Chen C, Gregory RI, Chou JJ, Sliz P. Molecular Basis for Interaction of let-7 MicroRNAs with Lin28. Cell 2011; 147:1080–1091."
},
"publicationIDType": {
"typeName": "publicationIDType",
"multiple": false,
"typeClass": "controlledVocabulary",
"value": "doi"
},
"publicationIDNumber": {
"typeName": "publicationIDNumber",
"multiple": false,
"typeClass": "primitive",
"value": "10.1016/j.cell.2011.10.020"
},
"publicationURL": {
"typeName": "publicationURL",
"multiple": false,
"typeClass": "primitive",
"value": "http://dx.doi.org/10.1016/j.cell.2011.10.020"
}
}
]
},
{
"typeName": "contributor",
"multiple": true,
"typeClass": "compound",
"value": [
{
"contributorType": {
"typeName": "contributorType",
"multiple": false,
"typeClass": "controlledVocabulary",
"value": "Data Collector"
},
"contributorName": {
"typeName": "contributorName",
"multiple": false,
"typeClass": "primitive",
"value": "Nam, Yunsun"
}
}
]
},
{
"typeName": "depositor",
"multiple": false,
"typeClass": "primitive",
"value": "Sliz, Piotr"
},
{
"typeName": "dateOfDeposit",
"multiple": false,
"typeClass": "primitive",
"value": "2015-04-10T14:45:03Z"
}
]
}
},
"files": []
}
}

0 comments on commit c717523

Please sign in to comment.