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