Search in sources :

Example 11 with Role

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()]);
}
Also used : Role(com.axelor.auth.db.Role) Group(com.axelor.auth.db.Group) ArrayList(java.util.ArrayList)

Example 12 with Role

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;
}
Also used : Role(com.axelor.auth.db.Role) Group(com.axelor.auth.db.Group) MetaMenu(com.axelor.meta.db.MetaMenu) HashSet(java.util.HashSet)

Aggregations

Role (com.axelor.auth.db.Role)12 Group (com.axelor.auth.db.Group)8 MetaMenu (com.axelor.meta.db.MetaMenu)6 Transactional (com.google.inject.persist.Transactional)5 RoleRepository (com.axelor.auth.db.repo.RoleRepository)3 ArrayList (java.util.ArrayList)3 MetaAction (com.axelor.meta.db.MetaAction)2 MetaMenuRepository (com.axelor.meta.db.repo.MetaMenuRepository)2 Permission (com.axelor.auth.db.Permission)1 User (com.axelor.auth.db.User)1 GroupRepository (com.axelor.auth.db.repo.GroupRepository)1 UserRepository (com.axelor.auth.db.repo.UserRepository)1 MetaField (com.axelor.meta.db.MetaField)1 MetaModel (com.axelor.meta.db.MetaModel)1 MetaActionRepository (com.axelor.meta.db.repo.MetaActionRepository)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 ResourceBundle (java.util.ResourceBundle)1