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