Search in sources :

Example 6 with UserAwareMeta

use of com.developmentontheedge.be5.api.helpers.UserAwareMeta in project be5 by DevelopmentOnTheEdge.

the class Menu method getDefaultAction.

private Action getDefaultAction(Injector injector, EntityType entityType) {
    UserAwareMeta userAwareMeta = injector.get(UserAwareMeta.class);
    List<String> roles = UserInfoHolder.getCurrentRoles();
    String language = UserInfoHolder.getLanguage();
    List<RootNode> entities = collectEntities(injector.getMeta(), userAwareMeta, language, roles, false, entityType);
    for (RootNode rootNode : entities) {
        if (rootNode.action != null) {
            if (rootNode.isDefault)
                return rootNode.action;
        } else if (rootNode.children != null) {
            for (QueryNode node : rootNode.children) {
                if (node.isDefault)
                    return node.action;
            }
        }
    }
    for (RootNode rootNode : entities) {
        if (rootNode.action != null) {
            return rootNode.action;
        } else if (rootNode.children != null) {
            for (QueryNode node : rootNode.children) {
                return node.action;
            }
        }
    }
    return null;
}
Also used : UserAwareMeta(com.developmentontheedge.be5.api.helpers.UserAwareMeta)

Aggregations

UserAwareMeta (com.developmentontheedge.be5.api.helpers.UserAwareMeta)4 Query (com.developmentontheedge.be5.metadata.model.Query)3 Action (com.developmentontheedge.be5.model.Action)2 Be5Exception (com.developmentontheedge.be5.api.exceptions.Be5Exception)1 Operation (com.developmentontheedge.be5.metadata.model.Operation)1 JsonApiModel (com.developmentontheedge.be5.model.jsonapi.JsonApiModel)1 DocumentGenerator (com.developmentontheedge.be5.query.DocumentGenerator)1 MoreRowsGenerator (com.developmentontheedge.be5.query.impl.MoreRowsGenerator)1 HashUrl (com.developmentontheedge.be5.util.HashUrl)1 ArrayList (java.util.ArrayList)1 ServletContext (javax.servlet.ServletContext)1 Context (org.thymeleaf.context.Context)1