Search in sources :

Example 6 with MetaView

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

the class AppController method configure.

public void configure(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    MetaView formView = null;
    String code = (String) context.get("code");
    String appName = Inflector.getInstance().camelize(code);
    Model config = (Model) context.get("app" + appName);
    String model = "com.axelor.apps.base.db.App" + appName;
    if (config != null) {
        formView = Beans.get(MetaViewRepository.class).all().filter("self.type = 'form' AND self.model = ? AND self.name like '%-config-form'", model).fetchOne();
    }
    if (formView == null) {
        response.setFlash(I18n.get(IExceptionMessages.NO_CONFIG_REQUIRED));
    } else {
        response.setView(ActionView.define(I18n.get("Configure") + ": " + context.get("name")).add("form", formView.getName()).model(model).context("_showRecord", config.getId()).param("forceEdit", "true").map());
    }
}
Also used : Context(com.axelor.rpc.Context) Model(com.axelor.db.Model) MetaView(com.axelor.meta.db.MetaView)

Example 7 with MetaView

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

the class StudioMetaService method generateMetaView.

/**
 * Creates or Updates metaView from AbstractView.
 *
 * @param viewIterator ViewBuilder iterator
 */
@Transactional
public MetaView generateMetaView(AbstractView view) {
    String name = view.getName();
    String xmlId = view.getXmlId();
    String model = view.getModel();
    String viewType = view.getType();
    log.debug("Search view name: {}, xmlId: {}", name, xmlId);
    MetaView metaView;
    if (xmlId != null) {
        metaView = metaViewRepo.all().filter("self.name = ?1 and self.xmlId = ?2 and self.type = ?3", name, xmlId, viewType).fetchOne();
    } else {
        metaView = metaViewRepo.all().filter("self.name = ?1 and self.type = ?2", name, viewType).fetchOne();
    }
    log.debug("Meta view found: {}", metaView);
    if (metaView == null) {
        metaView = metaViewRepo.all().filter("self.name = ?1 and self.type = ?2", name, viewType).order("-priority").fetchOne();
        Integer priority = 20;
        if (metaView != null) {
            priority = metaView.getPriority() + 1;
        }
        metaView = new MetaView();
        metaView.setName(name);
        metaView.setXmlId(xmlId);
        metaView.setModel(model);
        metaView.setPriority(priority);
        metaView.setType(viewType);
        metaView.setTitle(view.getTitle());
    }
    String viewXml = XMLViews.toXml(view, true);
    metaView.setXml(viewXml);
    return metaViewRepo.save(metaView);
}
Also used : MetaView(com.axelor.meta.db.MetaView) Transactional(com.google.inject.persist.Transactional)

Example 8 with MetaView

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

the class ActionBuilderController method addActionBuilderView.

private void addActionBuilderView(List<ActionBuilderView> views, String model, String type, boolean isJson, int sequence) {
    String viewName = model + "-" + type;
    if (isJson) {
        viewName = "custom-model-" + model + "-" + type;
    }
    MetaView view = Beans.get(MetaViewRepository.class).findByName(viewName);
    if (view == null) {
        return;
    }
    ActionBuilderView builderView = new ActionBuilderView();
    builderView.setViewName(view.getName());
    builderView.setViewType(view.getType());
    builderView.setSequence(sequence);
    views.add(builderView);
}
Also used : MetaViewRepository(com.axelor.meta.db.repo.MetaViewRepository) MetaView(com.axelor.meta.db.MetaView) ActionBuilderView(com.axelor.studio.db.ActionBuilderView)

Example 9 with MetaView

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

the class DashboardBuilderRepo method remove.

@Override
public void remove(DashboardBuilder dashboardBuilder) {
    MetaView metaView = dashboardBuilder.getMetaViewGenerated();
    if (metaView != null) {
        metaViewRepo.remove(metaView);
    }
    super.remove(dashboardBuilder);
}
Also used : MetaView(com.axelor.meta.db.MetaView)

Aggregations

MetaView (com.axelor.meta.db.MetaView)9 ObjectViews (com.axelor.meta.schema.ObjectViews)2 AbstractWidget (com.axelor.meta.schema.views.AbstractWidget)2 Model (com.axelor.db.Model)1 AxelorException (com.axelor.exception.AxelorException)1 MetaAction (com.axelor.meta.db.MetaAction)1 MetaViewRepository (com.axelor.meta.db.repo.MetaViewRepository)1 Dashboard (com.axelor.meta.schema.views.Dashboard)1 Dashlet (com.axelor.meta.schema.views.Dashlet)1 GridView (com.axelor.meta.schema.views.GridView)1 Context (com.axelor.rpc.Context)1 ActionBuilderView (com.axelor.studio.db.ActionBuilderView)1 ChartBuilder (com.axelor.studio.db.ChartBuilder)1 DashletBuilder (com.axelor.studio.db.DashletBuilder)1 Transactional (com.google.inject.persist.Transactional)1 ArrayList (java.util.ArrayList)1 JAXBException (javax.xml.bind.JAXBException)1