use of com.axelor.apps.base.db.Wizard in project axelor-open-suite by axelor.
the class ProjectTemplateController method createProjectFromTemplate.
public void createProjectFromTemplate(ActionRequest request, ActionResponse response) {
ProjectTemplate projectTemplate = request.getContext().asType(ProjectTemplate.class);
AppProject appProject = Beans.get(AppProjectService.class).getAppProject();
if (appProject.getGenerateProjectSequence() && !projectTemplate.getIsBusinessProject()) {
Project project;
try {
project = Beans.get(ProjectService.class).createProjectFromTemplate(projectTemplate, null, null);
response.setView(ActionView.define(I18n.get("Project")).model(Project.class.getName()).add("form", "project-form").add("grid", "project-grid").param("search-filters", "project-filters").context("_showRecord", project.getId()).map());
} catch (AxelorException e) {
TraceBackService.trace(response, e);
}
} else {
response.setView(ActionView.define(I18n.get("Create project from this template")).model(Wizard.class.getName()).add("form", "project-template-wizard-form").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("width", "large").param("popup-save", "false").context("_projectTemplate", projectTemplate).context("_businessProject", projectTemplate.getIsBusinessProject()).map());
}
}
use of com.axelor.apps.base.db.Wizard in project axelor-open-suite by axelor.
the class GenerateMessageController method callMessageWizard.
public void callMessageWizard(ActionRequest request, ActionResponse response) {
Model context = request.getContext().asType(Model.class);
String model = request.getModel();
LOG.debug("Call message wizard for model : {} ", model);
String[] decomposeModel = model.split("\\.");
String simpleModel = decomposeModel[decomposeModel.length - 1];
Query<? extends Template> templateQuery = Beans.get(TemplateRepository.class).all().filter("self.metaModel.fullName = ?1 AND self.isSystem != true", model);
try {
long templateNumber = templateQuery.count();
LOG.debug("Template number : {} ", templateNumber);
if (templateNumber == 0) {
response.setView(ActionView.define(I18n.get(IExceptionMessage.MESSAGE_3)).model(Message.class.getName()).add("form", "message-form").param("forceEdit", "true").context("_mediaTypeSelect", MessageRepository.MEDIA_TYPE_EMAIL).context("_templateContextModel", model).context("_objectId", context.getId().toString()).map());
} else if (templateNumber > 1) {
response.setView(ActionView.define(I18n.get(IExceptionMessage.MESSAGE_2)).model(Wizard.class.getName()).add("form", "generate-message-wizard-form").param("show-confirm", "false").context("_objectId", context.getId().toString()).context("_templateContextModel", model).context("_tag", simpleModel).map());
} else {
response.setView(generateMessage(context.getId(), model, simpleModel, templateQuery.fetchOne()));
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.base.db.Wizard in project axelor-open-suite by axelor.
the class UserController method openGenerateRandomPasswordsWizard.
@SuppressWarnings("unchecked")
public void openGenerateRandomPasswordsWizard(ActionRequest request, ActionResponse response) {
try {
List<Long> userIds = (List<Long>) request.getContext().get("_ids");
if (ObjectUtils.isEmpty(userIds)) {
response.setError(I18n.get(IExceptionMessage.RECORD_NONE_SELECTED));
return;
}
ActionViewBuilder view = ActionView.define(I18n.get("Generate random passwords")).model(Wizard.class.getName()).add("form", "generate-random-passwords-wizard").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("popup-save", "false").context("_userIds", userIds);
response.setView(view.map());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.base.db.Wizard in project axelor-open-suite by axelor.
the class PrintTemplateController method openPrint.
public void openPrint(ActionRequest request, ActionResponse response) {
Model context = request.getContext().asType(Model.class);
String model = request.getModel();
LOG.debug("Print template wizard call for model : {}", model);
Query<PrintTemplate> printTemplateQuery = Beans.get(PrintTemplateRepository.class).all().filter("self.metaModel.fullName = ?", model);
try {
long templatesCount = printTemplateQuery.count();
LOG.debug("Print templates count : {} ", templatesCount);
if (templatesCount == 0) {
response.setError(I18n.get("Please define a print template for the model :" + model));
} else if (templatesCount == 1) {
Print print = Beans.get(PrintTemplateService.class).generatePrint(context.getId(), printTemplateQuery.fetchOne());
response.setView(getPrintView(print));
} else if (templatesCount >= 2) {
response.setView(ActionView.define(I18n.get("Select template")).model(Wizard.class.getName()).add("form", "select-print-template-wizard-form").param("show-confirm", "false").context("_objectId", context.getId().toString()).context("_templateContextModel", model).map());
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations