Search in sources :

Example 11 with Action

use of com.developmentontheedge.be5.model.Action 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)

Example 12 with Action

use of com.developmentontheedge.be5.model.Action in project be5 by DevelopmentOnTheEdge.

the class MenuTest method testDefaultActionAdmin.

@Test
public void testDefaultActionAdmin() {
    initUserWithRoles(RoleType.ROLE_ADMINISTRATOR, RoleType.ROLE_SYSTEM_DEVELOPER);
    Response response = mock(Response.class);
    component.generate(getMockRequest("defaultAction"), response, injector);
    verify(response).sendAsRawJson(eq(new Action("call", "table/testtableAdmin/All records")));
    initUserWithRoles(RoleType.ROLE_GUEST);
}
Also used : Response(com.developmentontheedge.be5.api.Response) Action(com.developmentontheedge.be5.model.Action) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Example 13 with Action

use of com.developmentontheedge.be5.model.Action in project be5 by DevelopmentOnTheEdge.

the class MenuTest method testDefaultActionTestUser2.

@Test
public void testDefaultActionTestUser2() {
    initUserWithRoles("TestUser2");
    Response response = mock(Response.class);
    component.generate(getMockRequest("defaultAction"), response, injector);
    verify(response).sendAsRawJson(eq(new Action("call", "table/atest/Test1")));
    initUserWithRoles(RoleType.ROLE_GUEST);
}
Also used : Response(com.developmentontheedge.be5.api.Response) Action(com.developmentontheedge.be5.model.Action) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Aggregations

Action (com.developmentontheedge.be5.model.Action)10 Be5ProjectTest (com.developmentontheedge.be5.test.Be5ProjectTest)7 Test (org.junit.Test)7 Response (com.developmentontheedge.be5.api.Response)4 Operation (com.developmentontheedge.be5.metadata.model.Operation)2 Query (com.developmentontheedge.be5.metadata.model.Query)2 UserAwareMeta (com.developmentontheedge.be5.api.helpers.UserAwareMeta)1 TableOperationPresentation (com.developmentontheedge.be5.model.TableOperationPresentation)1 Operation (com.developmentontheedge.be5.operation.Operation)1 TransactionalOperation (com.developmentontheedge.be5.operation.TransactionalOperation)1 TableBuilder (com.developmentontheedge.be5.query.TableBuilder)1 ArrayList (java.util.ArrayList)1