use of com.axelor.meta.db.MetaMenu in project axelor-open-suite by axelor.
the class StudioMetaService method removeMetaActions.
/**
* Removes MetaActions from comma separated names in string.
*
* @param actionNames Comma separated string of action names.
*/
@Transactional
public void removeMetaActions(String xmlIds) {
log.debug("Removing actions: {}", xmlIds);
if (xmlIds == null) {
return;
}
List<MetaAction> metaActions = metaActionRepo.all().filter("self.xmlId in ?1 OR self.name in ?1 ", Arrays.asList(xmlIds.split(","))).fetch();
for (MetaAction action : metaActions) {
List<MetaMenu> menus = metaMenuRepo.all().filter("self.action = ?1", action).fetch();
for (MetaMenu metaMenu : menus) {
metaMenu.setAction(null);
metaMenuRepo.save(metaMenu);
}
metaActionRepo.remove(action);
}
}
use of com.axelor.meta.db.MetaMenu in project axelor-open-suite by axelor.
the class StudioMetaService method createMenu.
public MetaMenu createMenu(MenuBuilder builder) {
// String xmlId = XML_ID_PREFIX + builder.getName();
String xmlId = builder.getXmlId();
MetaMenu menu = builder.getMetaMenu();
if (menu == null) {
menu = metaMenuRepo.findByID(xmlId);
} else {
menu.setXmlId(xmlId);
}
if (menu == null) {
menu = new MetaMenu(builder.getName());
menu.setXmlId(xmlId);
Integer priority = getPriority(MetaMenu.class.getSimpleName(), menu.getName());
menu.setPriority(priority);
menu.setTitle(builder.getTitle());
menu = metaMenuRepo.save(menu);
}
menu.setTitle(builder.getTitle());
menu.setIcon(builder.getIcon());
menu.setIconBackground(builder.getIconBackground());
menu.setOrder(builder.getOrder());
menu.setParent(builder.getParentMenu());
if (builder.getGroups() != null) {
Set<Group> groups = new HashSet<>();
groups.addAll(builder.getGroups());
menu.setGroups(groups);
}
if (builder.getRoles() != null) {
Set<Role> roles = new HashSet<>();
roles.addAll(builder.getRoles());
menu.setRoles(roles);
}
String condition = builder.getConditionToCheck();
if (builder.getAppBuilder() != null) {
if (condition != null) {
condition = "__config__.app.isApp('" + builder.getAppBuilder().getCode() + "') && (" + condition + ")";
} else {
condition = "__config__.app.isApp('" + builder.getAppBuilder().getCode() + "')";
}
}
menu.setConditionToCheck(condition);
menu.setModuleToCheck(builder.getModuleToCheck());
menu.setLeft(builder.getLeft());
menu.setTop(builder.getTop());
menu.setHidden(builder.getHidden());
menu.setMobile(builder.getMobile());
menu.setTag(builder.getTag());
menu.setTagCount(builder.getTagCount());
menu.setTagGet(builder.getTagGet());
menu.setTagStyle(builder.getTagStyle());
menu.setLink(builder.getLink());
if (builder.getMetaModule() != null) {
menu.setModule(builder.getMetaModule().getName());
}
return menu;
}
use of com.axelor.meta.db.MetaMenu in project axelor-open-suite by axelor.
the class CalendarConfigurationService method createMetaMenu.
public MetaMenu createMetaMenu(String name, String title, MetaAction metaAction, MetaMenu parentMenu) {
MetaMenu metaMenu = new MetaMenu();
metaMenu.setName(name);
metaMenu.setAction(metaAction);
metaMenu.setModule("axelor-base");
metaMenu.setTitle(title);
metaMenu.setParent(parentMenu);
return metaMenu;
}
use of com.axelor.meta.db.MetaMenu in project axelor-open-suite by axelor.
the class XmlHandler method generateMenuGraph.
private void generateMenuGraph(List<? extends MetaMenu> menuList) {
// log.debug("Checking menu list: {}",menuList);
for (MetaMenu menu : menuList) {
String model = menu.getAction() != null ? menu.getAction().getModel() : null;
// log.debug("Action model: ",model);
if (model != null && !objectList.contains(model)) {
updateFieldData(menu.getAction());
}
// List<? extends MetaMenu> childList = MetaMenu.all().filter("self.parent = ?1 AND self.left
// = true AND ?2 MEMBER OF self.groups", menu,group).order("-priority").order("id").fetch();
List<? extends MetaMenu> childList = Beans.get(MetaMenuRepository.class).all().filter("self.parent = ?1 AND self.left = true", menu).order("-priority").order("id").fetch();
generateMenuGraph(childList);
}
}
Aggregations