Search in sources :

Example 6 with MetaJsonModel

use of com.axelor.meta.db.MetaJsonModel in project axelor-open-suite by axelor.

the class MetaJsonModelController method removeMenuBuilder.

@Transactional
public void removeMenuBuilder(ActionRequest request, ActionResponse response) {
    MetaJsonModel metaJsonModel = request.getContext().asType(MetaJsonModel.class);
    if (metaJsonModel.getMenuBuilder() != null && metaJsonModel.getMenuBuilder().getId() != null && metaJsonModel.getMenuBuilder().getMetaMenu() != null) {
        MenuBuilder menuBuilder = Beans.get(MenuBuilderRepository.class).find(metaJsonModel.getMenuBuilder().getId());
        metaJsonModel = Beans.get(MetaJsonModelRepo.class).find(metaJsonModel.getId());
        metaJsonModel.setMenuBuilder(null);
        Beans.get(MetaJsonModelRepo.class).save(metaJsonModel);
        Beans.get(MenuBuilderRepo.class).remove(menuBuilder);
        response.setReload(true);
    }
}
Also used : MetaJsonModel(com.axelor.meta.db.MetaJsonModel) MenuBuilderRepo(com.axelor.studio.db.repo.MenuBuilderRepo) MetaJsonModelRepo(com.axelor.studio.db.repo.MetaJsonModelRepo) MenuBuilder(com.axelor.studio.db.MenuBuilder) MenuBuilderRepository(com.axelor.studio.db.repo.MenuBuilderRepository) Transactional(com.google.inject.persist.Transactional)

Example 7 with MetaJsonModel

use of com.axelor.meta.db.MetaJsonModel in project axelor-open-suite by axelor.

the class WkfModelController method openRecordView.

@SuppressWarnings("unchecked")
private void openRecordView(ActionRequest request, ActionResponse response, String statusKey, String modelKey, String recordkey) {
    LinkedHashMap<String, Object> _map = (LinkedHashMap<String, Object>) request.getData().get("context");
    String status = "";
    if (statusKey != null) {
        status = _map.get("title").toString();
    }
    String modelName = _map.get(modelKey).toString();
    boolean isMetaModel = (boolean) _map.get("isMetaModel");
    List<Long> recordIds = (List<Long>) _map.get(recordkey);
    ActionViewBuilder actionViewBuilder = null;
    if (isMetaModel) {
        MetaModel metaModel = Beans.get(MetaModelRepository.class).findByName(modelName);
        actionViewBuilder = this.createActionBuilder(status, metaModel);
    } else {
        MetaJsonModel metaJsonModel = Beans.get(MetaJsonModelRepository.class).findByName(modelName);
        actionViewBuilder = this.createActionBuilder(status, metaJsonModel);
    }
    response.setView(actionViewBuilder.context("ids", !recordIds.isEmpty() ? recordIds : 0).map());
}
Also used : MetaJsonModel(com.axelor.meta.db.MetaJsonModel) MetaModelRepository(com.axelor.meta.db.repo.MetaModelRepository) MetaJsonModelRepository(com.axelor.meta.db.repo.MetaJsonModelRepository) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) LinkedHashMap(java.util.LinkedHashMap) MetaModel(com.axelor.meta.db.MetaModel) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with MetaJsonModel

use of com.axelor.meta.db.MetaJsonModel in project axelor-open-suite by axelor.

the class ChartRecordViewServiceImpl method getJsonModelActionView.

protected Map<String, Object> getJsonModelActionView(ChartBuilder chartBuilder, Map<String, Object> context) throws AxelorException {
    MetaJsonModel jsonModel = metaJsonModelRepository.findByName(chartBuilder.getModel());
    String title = jsonModel.getTitle();
    if (Strings.isNullOrEmpty(title)) {
        title = chartBuilder.getModel();
    }
    String formView = "custom-model-" + jsonModel.getName() + "-form";
    String gridView = "custom-model-" + jsonModel.getName() + "-grid";
    ActionViewBuilder builder = ActionView.define(I18n.get(title)).model(MetaJsonRecord.class.getName()).add("grid", gridView).add("form", formView);
    String filter = "self.jsonModel = :jsonModel";
    builder.context("jsonModel", jsonModel.getName());
    filter += " AND " + getDomainFilter(chartBuilder, context);
    builder.domain(filter);
    return builder.map();
}
Also used : MetaJsonModel(com.axelor.meta.db.MetaJsonModel) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder) MetaJsonRecord(com.axelor.meta.db.MetaJsonRecord)

Aggregations

MetaJsonModel (com.axelor.meta.db.MetaJsonModel)8 MetaJsonRecord (com.axelor.meta.db.MetaJsonRecord)4 MetaModel (com.axelor.meta.db.MetaModel)4 ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)4 MetaModelRepository (com.axelor.meta.db.repo.MetaModelRepository)3 MetaJsonModelRepository (com.axelor.meta.db.repo.MetaJsonModelRepository)2 LinkedHashMap (java.util.LinkedHashMap)2 Template (com.axelor.apps.message.db.Template)1 Mapper (com.axelor.db.mapper.Mapper)1 AxelorException (com.axelor.exception.AxelorException)1 Context (com.axelor.rpc.Context)1 MenuBuilder (com.axelor.studio.db.MenuBuilder)1 MenuBuilderRepo (com.axelor.studio.db.repo.MenuBuilderRepo)1 MenuBuilderRepository (com.axelor.studio.db.repo.MenuBuilderRepository)1 MetaJsonModelRepo (com.axelor.studio.db.repo.MetaJsonModelRepo)1 Transactional (com.google.inject.persist.Transactional)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Table (javax.persistence.Table)1