Search in sources :

Example 1 with DeleteTemplateCommand

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

the class ManageTemplatesPage method deleteTemplate.

public void deleteTemplate() {
    List<Dataverse> dataverseWDefaultTemplate = null;
    if (selectedTemplate != null) {
        templates.remove(selectedTemplate);
        if (dataverse.getDefaultTemplate() != null && dataverse.getDefaultTemplate().equals(selectedTemplate)) {
            dataverse.setDefaultTemplate(null);
        }
        dataverse.getTemplates().remove(selectedTemplate);
        dataverseWDefaultTemplate = templateService.findDataversesByDefaultTemplateId(selectedTemplate.getId());
    } else {
        System.out.print("selected template is null");
    }
    try {
        engineService.submit(new DeleteTemplateCommand(dvRequestService.getDataverseRequest(), getDataverse(), selectedTemplate, dataverseWDefaultTemplate));
        JsfHelper.addFlashMessage("The template has been deleted");
    } catch (CommandException ex) {
        String failMessage = "The dataset template cannot be deleted.";
        JH.addMessage(FacesMessage.SEVERITY_FATAL, failMessage);
    }
}
Also used : DeleteTemplateCommand(edu.harvard.iq.dataverse.engine.command.impl.DeleteTemplateCommand) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException)

Aggregations

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