Search in sources :

Example 1 with ActionBuilder

use of com.axelor.studio.db.ActionBuilder in project axelor-open-suite by axelor.

the class MenuBuilderService method build.

@Transactional
public MetaMenu build(MenuBuilder builder) {
    MetaMenu menu = metaService.createMenu(builder);
    ActionBuilder actionBuilder = builder.getActionBuilder();
    if (actionBuilder != null) {
        if (actionBuilder.getName() == null) {
            actionBuilder.setName(menu.getName());
        }
        actionBuilder.setXmlId(builder.getXmlId());
        actionBuilder.setTitle(menu.getTitle());
        actionBuilder.setAppBuilder(builder.getAppBuilder());
        menu.setAction(actionBuilderService.build(actionBuilder));
    }
    MetaStore.clear();
    return menu;
}
Also used : ActionBuilder(com.axelor.studio.db.ActionBuilder) MetaMenu(com.axelor.meta.db.MetaMenu) Transactional(com.google.inject.persist.Transactional)

Example 2 with ActionBuilder

use of com.axelor.studio.db.ActionBuilder in project axelor-open-suite by axelor.

the class MenuBuilderService method updateMenuBuilder.

@Transactional
public MenuBuilder updateMenuBuilder(MenuBuilder menuBuilder, String objectName, String menuName, AppBuilder appBuilder, String objectClass, Boolean isJson, String domain) {
    if (StringUtils.isBlank(menuBuilder.getName())) {
        menuBuilder.setName(this.generateMenuBuilderName(menuName));
    }
    if (StringUtils.isBlank(menuBuilder.getXmlId())) {
        menuBuilder.setXmlId(menuBuilder.getName());
    }
    menuBuilder.setAppBuilder(appBuilder);
    menuBuilder.setShowAction(true);
    ActionBuilder actionBuilder = menuBuilder.getActionBuilder();
    if (actionBuilder == null) {
        actionBuilder = new ActionBuilder();
        actionBuilder.setXmlId(menuBuilder.getName());
        actionBuilder.setName(menuBuilder.getName());
    }
    actionBuilder.setTypeSelect(ActionBuilderRepository.TYPE_SELECT_VIEW);
    actionBuilder.setIsJson(isJson);
    actionBuilder.setModel(objectName);
    if (!Strings.isNullOrEmpty(domain)) {
        actionBuilder.setDomainCondition(domain);
    }
    List<ActionBuilderView> views = getActionViews(actionBuilder, isJson, objectName, objectClass);
    if (views != null && views.size() > 0) {
        actionBuilder.setActionBuilderViews(views);
    }
    menuBuilder.setActionBuilder(actionBuilder);
    return Beans.get(MenuBuilderRepo.class).save(menuBuilder);
}
Also used : ActionBuilder(com.axelor.studio.db.ActionBuilder) MenuBuilderRepo(com.axelor.studio.db.repo.MenuBuilderRepo) ActionBuilderView(com.axelor.studio.db.ActionBuilderView) Transactional(com.google.inject.persist.Transactional)

Example 3 with ActionBuilder

use of com.axelor.studio.db.ActionBuilder in project axelor-open-suite by axelor.

the class ExportService method exportActionBuilderLines.

@SuppressWarnings("deprecation")
public static String exportActionBuilderLines(List<ActionBuilderLine> lines, int count) {
    String xml = "";
    String indent = "\n" + Strings.repeat("\t", count);
    String indentPlus = "\n" + Strings.repeat("\t", count + 1);
    for (ActionBuilderLine line : lines) {
        String source = "";
        String target = "";
        if (line.getParent() == null) {
            ActionBuilder builder = line.getActionBuilder();
            if (builder != null) {
                target = builder.getTargetModel();
                source = builder.getModel();
                if (builder.getTypeSelect() == ActionBuilderRepository.TYPE_SELECT_UPDATE) {
                    target = builder.getModel();
                }
            }
        } else {
            ActionBuilderLine parent = line.getParent();
            if (parent.getMetaField() != null)
                target = parent.getMetaField().getTypeName();
            if (parent.getMetaJsonField() != null && parent.getMetaJsonField().getTargetModel() != null)
                target = parent.getMetaJsonField().getTargetModel();
            if (parent.getMetaJsonField() != null && parent.getMetaJsonField().getTargetJsonModel() != null)
                target = parent.getMetaJsonField().getTargetJsonModel().getName();
            if (parent.getValueField() != null)
                source = parent.getValueField().getMetaModel().getFullName();
            if (parent.getValueJson() != null && parent.getValueJson().getTargetModel() != null)
                source = parent.getValueJson().getTargetModel();
            if (parent.getValueJson() != null && parent.getValueJson().getTargetJsonModel() != null)
                source = parent.getValueJson().getTargetJsonModel().getName();
        }
        xml += indent + "<line>" + indentPlus + "<target>" + target + "</target>" + indentPlus + "<source>" + source + "</source>" + indentPlus + "<metaJsonField>" + (line.getMetaJsonField() != null ? line.getMetaJsonField().getName() : "") + "</metaJsonField>" + indentPlus + "<metaField>" + (line.getMetaField() != null ? line.getMetaField().getName() : "") + "</metaField>" + indentPlus + "<valueJson>" + (line.getValueJson() != null ? line.getValueJson().getName() : "") + "</valueJson>" + indentPlus + "<valueField>" + (line.getValueField() != null ? line.getValueField().getName() : "") + "</valueField>" + indentPlus + "<value>" + (line.getValue() != null ? line.getValue() : "") + "</value>" + indentPlus + "<conditionText>" + (line.getConditionText() != null ? StringEscapeUtils.escapeXml(StringEscapeUtils.escapeXml(line.getConditionText())) : "") + "</conditionText>" + indentPlus + "<filter>" + (line.getFilter() != null ? line.getFilter() : "") + "</filter>" + indentPlus + "<validationTypeSelect>" + (line.getValidationTypeSelect() != null ? line.getValidationTypeSelect() : "") + "</validationTypeSelect>" + indentPlus + "<validationMsg>" + (line.getValidationMsg() != null ? line.getValidationMsg() : "") + "</validationMsg>" + indentPlus + "<name>" + (line.getName() != null ? line.getName() : "") + "</name>" + indentPlus + "<dummy>" + (line.getDummy() != null ? line.getDummy() : "") + "</dummy>" + indentPlus + "<subLines>" + exportActionBuilderLines(line.getSubLines(), count + 2) + indentPlus + "</subLines>" + indent + "</line>";
    }
    return StringEscapeUtils.unescapeXml(xml);
}
Also used : ActionBuilderLine(com.axelor.studio.db.ActionBuilderLine) ActionBuilder(com.axelor.studio.db.ActionBuilder)

Example 4 with ActionBuilder

use of com.axelor.studio.db.ActionBuilder in project axelor-open-suite by axelor.

the class MenuBuilderRepo method copy.

@Override
public MenuBuilder copy(MenuBuilder menuBuilder, boolean deep) {
    ActionBuilder actionBuilder = menuBuilder.getActionBuilder();
    menuBuilder.setActionBuilder(null);
    menuBuilder = super.copy(menuBuilder, deep);
    if (actionBuilder != null) {
        menuBuilder.setActionBuilder(actionBuilderRepo.copy(actionBuilder, deep));
    }
    return menuBuilder;
}
Also used : ActionBuilder(com.axelor.studio.db.ActionBuilder)

Example 5 with ActionBuilder

use of com.axelor.studio.db.ActionBuilder in project axelor-open-suite by axelor.

the class MenuBuilderRepo method remove.

@Override
public void remove(MenuBuilder menuBuilder) {
    MetaMenu metaMenu = menuBuilder.getMetaMenu();
    menuBuilder.setMetaMenu(null);
    if (metaMenu != null) {
        metaService.removeMetaMenu(metaMenu);
    }
    ActionBuilder actionBuilder = menuBuilder.getActionBuilder();
    menuBuilder.setActionBuilder(null);
    if (actionBuilder != null) {
        try {
            actionBuilderRepo.remove(actionBuilder);
        } catch (RuntimeException e) {
            TraceBackService.trace(e);
            throw e;
        }
    }
    MetaStore.clear();
    super.remove(menuBuilder);
}
Also used : ActionBuilder(com.axelor.studio.db.ActionBuilder) MetaMenu(com.axelor.meta.db.MetaMenu)

Aggregations

ActionBuilder (com.axelor.studio.db.ActionBuilder)7 ActionBuilderView (com.axelor.studio.db.ActionBuilderView)3 MetaMenu (com.axelor.meta.db.MetaMenu)2 ActionBuilderLine (com.axelor.studio.db.ActionBuilderLine)2 Transactional (com.google.inject.persist.Transactional)2 ArrayList (java.util.ArrayList)2 MetaAction (com.axelor.meta.db.MetaAction)1 ObjectViews (com.axelor.meta.schema.ObjectViews)1 Action (com.axelor.meta.schema.actions.Action)1 ActionView (com.axelor.meta.schema.actions.ActionView)1 MenuBuilderRepo (com.axelor.studio.db.repo.MenuBuilderRepo)1 List (java.util.List)1 JAXBException (javax.xml.bind.JAXBException)1