Search in sources :

Example 6 with Wizard

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());
    }
}
Also used : AppProject(com.axelor.apps.base.db.AppProject) Project(com.axelor.apps.project.db.Project) AxelorException(com.axelor.exception.AxelorException) AppProject(com.axelor.apps.base.db.AppProject) AppProjectService(com.axelor.apps.project.service.app.AppProjectService) Wizard(com.axelor.apps.base.db.Wizard) ProjectTemplate(com.axelor.apps.project.db.ProjectTemplate)

Example 7 with Wizard

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);
    }
}
Also used : Model(com.axelor.db.Model) Wizard(com.axelor.apps.base.db.Wizard) IOException(java.io.IOException) AxelorException(com.axelor.exception.AxelorException)

Example 8 with Wizard

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);
    }
}
Also used : List(java.util.List) Wizard(com.axelor.apps.base.db.Wizard) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) ValidationException(javax.validation.ValidationException)

Example 9 with Wizard

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);
    }
}
Also used : Print(com.axelor.apps.base.db.Print) PrintTemplate(com.axelor.apps.base.db.PrintTemplate) Model(com.axelor.db.Model) Wizard(com.axelor.apps.base.db.Wizard) AxelorException(com.axelor.exception.AxelorException)

Aggregations

Wizard (com.axelor.apps.base.db.Wizard)9 AxelorException (com.axelor.exception.AxelorException)4 List (java.util.List)3 Model (com.axelor.db.Model)2 ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)2 AppProject (com.axelor.apps.base.db.AppProject)1 Partner (com.axelor.apps.base.db.Partner)1 Print (com.axelor.apps.base.db.Print)1 PrintTemplate (com.axelor.apps.base.db.PrintTemplate)1 DuplicateObjectsService (com.axelor.apps.base.service.DuplicateObjectsService)1 WkfModel (com.axelor.apps.bpm.db.WkfModel)1 Project (com.axelor.apps.project.db.Project)1 ProjectTemplate (com.axelor.apps.project.db.ProjectTemplate)1 AppProjectService (com.axelor.apps.project.service.app.AppProjectService)1 SaleOrder (com.axelor.apps.sale.db.SaleOrder)1 StockMove (com.axelor.apps.stock.db.StockMove)1 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)1 StockMoveRepository (com.axelor.apps.stock.db.repo.StockMoveRepository)1 Property (com.axelor.db.mapper.Property)1 Context (com.axelor.rpc.Context)1