-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added backend support for alternate citation dates #2606
- Loading branch information
1 parent
e27d3d6
commit 2a6d274
Showing
6 changed files
with
155 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Add new foreign ket to dataset for citation date (from datasetfieldtype) | ||
ALTER TABLE dataset ADD COLUMN citationdatedatasetfieldtype_id bigint; | ||
|
||
ALTER TABLE dataset | ||
ADD CONSTRAINT fk_dataset_citationdatedatasetfieldtype_id FOREIGN KEY (citationdatedatasetfieldtype_id) | ||
REFERENCES datasetfieldtype (id) MATCH SIMPLE | ||
ON UPDATE NO ACTION ON DELETE NO ACTION; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...main/java/edu/harvard/iq/dataverse/engine/command/impl/SetDatasetCitationDateCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package edu.harvard.iq.dataverse.engine.command.impl; | ||
|
||
import edu.harvard.iq.dataverse.Dataset; | ||
import edu.harvard.iq.dataverse.DatasetFieldType; | ||
import edu.harvard.iq.dataverse.DatasetFieldType.FieldType; | ||
import edu.harvard.iq.dataverse.authorization.Permission; | ||
import edu.harvard.iq.dataverse.engine.command.AbstractCommand; | ||
import edu.harvard.iq.dataverse.engine.command.CommandContext; | ||
import edu.harvard.iq.dataverse.engine.command.DataverseRequest; | ||
import edu.harvard.iq.dataverse.engine.command.RequiredPermissions; | ||
import edu.harvard.iq.dataverse.engine.command.exception.CommandException; | ||
import edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException; | ||
import java.util.concurrent.Future; | ||
|
||
/** | ||
* | ||
* @author gdurand | ||
*/ | ||
@RequiredPermissions( Permission.PublishDataset ) | ||
public class SetDatasetCitationDateCommand extends AbstractCommand<Dataset>{ | ||
|
||
|
||
private final DatasetFieldType dsfType; | ||
private final Dataset dataset; | ||
|
||
public SetDatasetCitationDateCommand( DataverseRequest aRequest, Dataset dataset, DatasetFieldType dsfType ) { | ||
super( aRequest, dataset ); | ||
this.dataset = dataset; | ||
this.dsfType = dsfType; | ||
} | ||
|
||
@Override | ||
public Dataset execute(CommandContext ctxt) throws CommandException { | ||
if ( dsfType == null || dsfType.getFieldType().equals(FieldType.DATE) ) { | ||
dataset.setCitationDateDatasetFieldType(dsfType); | ||
} else { | ||
throw new IllegalCommandException("Provided DatasetFieldtype is not a Date", this); | ||
} | ||
|
||
Dataset savedDataset = ctxt.em().merge(dataset); | ||
ctxt.index().indexDataset(savedDataset, false); | ||
return savedDataset; | ||
} | ||
|
||
} | ||
|