Search in sources :

Example 16 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class WkfModelController method newRecord.

@SuppressWarnings("unchecked")
public void newRecord(ActionRequest request, ActionResponse response) {
    try {
        LinkedHashMap<String, Object> _map = (LinkedHashMap<String, Object>) request.getData().get("context");
        String modelName = _map.get("modelName").toString();
        boolean isMetaModel = (boolean) _map.get("isMetaModel");
        ActionViewBuilder actionViewBuilder = this.viewNewRecord(modelName, isMetaModel);
        response.setView(actionViewBuilder.map());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) AxelorException(com.axelor.exception.AxelorException) LinkedHashMap(java.util.LinkedHashMap)

Example 17 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class WkfModelController method newInstance.

@SuppressWarnings({ "unchecked", "rawtypes" })
public void newInstance(ActionRequest request, ActionResponse response) {
    try {
        LinkedHashMap<String, Object> _map = (LinkedHashMap<String, Object>) request.getData().get("context");
        WkfProcessConfig config = Beans.get(WkfProcessConfigRepository.class).find(Long.valueOf(((Map) _map.get("processConfig")).get("id").toString()));
        boolean isMetaModel = config.getMetaModel() != null;
        String modelName = isMetaModel ? config.getMetaModel().getName() : config.getMetaJsonModel().getName();
        ActionViewBuilder actionViewBuilder = this.viewNewRecord(modelName, isMetaModel);
        response.setView(actionViewBuilder.map());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : WkfProcessConfig(com.axelor.apps.bpm.db.WkfProcessConfig) WkfProcessConfigRepository(com.axelor.apps.bpm.db.repo.WkfProcessConfigRepository) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) AxelorException(com.axelor.exception.AxelorException) LinkedHashMap(java.util.LinkedHashMap)

Example 18 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class WkfModelController method viewNewRecord.

private ActionViewBuilder viewNewRecord(String modelName, boolean isMetaModel) {
    ActionViewBuilder actionViewBuilder = null;
    if (isMetaModel) {
        MetaModel metaModel = Beans.get(MetaModelRepository.class).findByName(modelName);
        String viewPrefix = Inflector.getInstance().dasherize(metaModel.getName());
        actionViewBuilder = ActionView.define(metaModel.getName()).model(metaModel.getFullName()).add("form", viewPrefix + "-form");
    } else {
        MetaJsonModel metaJsonModel = Beans.get(MetaJsonModelRepository.class).findByName(modelName);
        actionViewBuilder = ActionView.define(metaJsonModel.getTitle()).model(MetaJsonRecord.class.getName()).add("form", metaJsonModel.getFormView().getName()).domain("self.jsonModel = :jsonModel").context("jsonModel", modelName);
    }
    return actionViewBuilder;
}
Also used : MetaJsonModel(com.axelor.meta.db.MetaJsonModel) MetaModel(com.axelor.meta.db.MetaModel) MetaModelRepository(com.axelor.meta.db.repo.MetaModelRepository) MetaJsonModelRepository(com.axelor.meta.db.repo.MetaJsonModelRepository) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) MetaJsonRecord(com.axelor.meta.db.MetaJsonRecord)

Example 19 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class WkfModelController method createActionBuilder.

private ActionViewBuilder createActionBuilder(String status, MetaModel metaModel) {
    String viewPrefix = Inflector.getInstance().dasherize(metaModel.getName());
    String title = Strings.isNullOrEmpty(status) ? metaModel.getName() : metaModel.getName() + "-" + status;
    ActionViewBuilder actionViewBuilder = ActionView.define(title).model(metaModel.getFullName()).add("grid", viewPrefix + "-grid").add("form", viewPrefix + "-form").domain("self.id IN (:ids)");
    return actionViewBuilder;
}
Also used : ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 20 with ActionViewBuilder

use of com.axelor.meta.schema.actions.ActionView.ActionViewBuilder in project axelor-open-suite by axelor.

the class AccountingReportController method showMoveExported.

public void showMoveExported(ActionRequest request, ActionResponse response) {
    AccountingReport accountingReport = request.getContext().asType(AccountingReport.class);
    ActionViewBuilder actionViewBuilder = ActionView.define(I18n.get(IExceptionMessage.ACCOUNTING_REPORT_6));
    actionViewBuilder.model(Move.class.getName());
    actionViewBuilder.add("grid", "move-grid");
    actionViewBuilder.param("search-filters", "move-filters");
    actionViewBuilder.domain("self.accountingReport.id = :_accountingReportId");
    actionViewBuilder.context("_accountingReportId", accountingReport.getId());
    response.setView(actionViewBuilder.map());
}
Also used : AccountingReport(com.axelor.apps.account.db.AccountingReport) Move(com.axelor.apps.account.db.Move) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Aggregations

ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)54 AxelorException (com.axelor.exception.AxelorException)18 User (com.axelor.auth.db.User)17 List (java.util.List)15 Employee (com.axelor.apps.hr.db.Employee)14 Map (java.util.Map)14 ArrayList (java.util.ArrayList)13 Company (com.axelor.apps.base.db.Company)10 Partner (com.axelor.apps.base.db.Partner)9 Wizard (com.axelor.apps.base.db.Wizard)9 Invoice (com.axelor.apps.account.db.Invoice)8 Currency (com.axelor.apps.base.db.Currency)7 PriceList (com.axelor.apps.base.db.PriceList)7 LinkedHashMap (java.util.LinkedHashMap)6 SaleOrder (com.axelor.apps.sale.db.SaleOrder)5 StockMove (com.axelor.apps.stock.db.StockMove)5 MetaJsonRecord (com.axelor.meta.db.MetaJsonRecord)5 HRMenuValidateService (com.axelor.apps.hr.service.HRMenuValidateService)4 StockMoveMultiInvoiceService (com.axelor.apps.supplychain.service.StockMoveMultiInvoiceService)4 MetaJsonModel (com.axelor.meta.db.MetaJsonModel)4