-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3000 from IQSS/2606-citation-date
added backend support for alternate citation dates #2606
- Loading branch information
Showing
8 changed files
with
220 additions
and
24 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
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
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
45 changes: 45 additions & 0 deletions
45
...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,45 @@ | ||
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; | ||
|
||
/** | ||
* | ||
* @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.datasets().merge(dataset); | ||
ctxt.index().indexDataset(savedDataset, false); | ||
return savedDataset; | ||
} | ||
|
||
} | ||
|