Search in sources :

Example 1 with DeaccessionDatasetVersionCommand

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

the class DatasetPage method deaccessionVersions.

public String deaccessionVersions() {
    Command<DatasetVersion> cmd;
    try {
        if (selectedDeaccessionVersions == null) {
            for (DatasetVersion dv : this.dataset.getVersions()) {
                if (dv.isReleased()) {
                    DatasetVersion deaccession = datasetVersionService.find(dv.getId());
                    cmd = new DeaccessionDatasetVersionCommand(dvRequestService.getDataverseRequest(), setDatasetVersionDeaccessionReasonAndURL(deaccession), true);
                    DatasetVersion datasetv = commandEngine.submit(cmd);
                }
            }
        } else {
            for (DatasetVersion dv : selectedDeaccessionVersions) {
                DatasetVersion deaccession = datasetVersionService.find(dv.getId());
                cmd = new DeaccessionDatasetVersionCommand(dvRequestService.getDataverseRequest(), setDatasetVersionDeaccessionReasonAndURL(deaccession), false);
                DatasetVersion datasetv = commandEngine.submit(cmd);
            }
        }
    } catch (CommandException ex) {
        logger.severe(ex.getMessage());
        JH.addMessage(FacesMessage.SEVERITY_FATAL, JH.localize("dataset.message.deaccessionFailure"));
    }
    JsfHelper.addSuccessMessage(JH.localize("datasetVersion.message.deaccessionSuccess"));
    return returnToDatasetOnly();
}
Also used : CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) IllegalCommandException(edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException) DeaccessionDatasetVersionCommand(edu.harvard.iq.dataverse.engine.command.impl.DeaccessionDatasetVersionCommand)

Aggregations

CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)1 IllegalCommandException (edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException)1 DeaccessionDatasetVersionCommand (edu.harvard.iq.dataverse.engine.command.impl.DeaccessionDatasetVersionCommand)1