Search in sources :

Example 1 with SetDatasetCitationDateCommand

use of edu.harvard.iq.dataverse.engine.command.impl.SetDatasetCitationDateCommand in project dataverse by IQSS.

the class Datasets method setCitationDate.

@PUT
@Path("{id}/citationdate")
public Response setCitationDate(@PathParam("id") String id, String dsfTypeName) {
    return response(req -> {
        if (dsfTypeName.trim().isEmpty()) {
            return badRequest("Please provide a dataset field type in the requst body.");
        }
        DatasetFieldType dsfType = null;
        if (!":publicationDate".equals(dsfTypeName)) {
            dsfType = datasetFieldSvc.findByName(dsfTypeName);
            if (dsfType == null) {
                return badRequest("Dataset Field Type Name " + dsfTypeName + " not found.");
            }
        }
        execCommand(new SetDatasetCitationDateCommand(req, findDatasetOrDie(id), dsfType));
        return ok("Citation Date for dataset " + id + " set to: " + (dsfType != null ? dsfType.getDisplayName() : "default"));
    });
}
Also used : SetDatasetCitationDateCommand(edu.harvard.iq.dataverse.engine.command.impl.SetDatasetCitationDateCommand) DatasetFieldType(edu.harvard.iq.dataverse.DatasetFieldType) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Aggregations

DatasetFieldType (edu.harvard.iq.dataverse.DatasetFieldType)1 SetDatasetCitationDateCommand (edu.harvard.iq.dataverse.engine.command.impl.SetDatasetCitationDateCommand)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1