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);
}
}
Aggregations