use of com.axelor.auth.db.Role in project axelor-open-suite by axelor.
the class MetaGroupMenuAssistantService method getGroupRow.
private String[] getGroupRow(String[] row, MetaGroupMenuAssistant groupMenuAssistant) {
List<String> groupList = new ArrayList<>();
if (row != null) {
groupList.addAll(Arrays.asList(row));
} else {
groupList.add(getBundle().getString("Name"));
groupList.add(getBundle().getString("Title"));
}
for (Group group : groupMenuAssistant.getGroupSet()) {
String code = group.getCode();
if (!groupList.contains(code)) {
groupList.add(code);
}
}
for (Role role : groupMenuAssistant.getRoleSet()) {
String name = role.getName();
if (!groupList.contains(name)) {
groupList.add(name);
}
}
return groupList.toArray(new String[groupList.size()]);
}
use of com.axelor.auth.db.Role 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;
}
Aggregations