Search in sources :

Example 1 with Role

use of org.webpieces.plugins.hibernate.app.dbo.Role in project webpieces by deanhiller.

the class CrudTestController method multiSelect.

public Render multiSelect(Integer id) {
    if (id == null) {
        return Actions.renderThis("entity", new UserTestDbo(), "levels", LevelEducation.values(), "roles", Role.values(), "selectedRoles", new ArrayList<>());
    }
    UserTestDbo user = UserTestDbo.findWithJoin(Em.get(), id);
    List<UserRoleDbo> roles = user.getRoles();
    List<Role> selectedRoles = roles.stream().map(r -> r.getRole()).collect(Collectors.toList());
    return Actions.renderThis("entity", user, "levels", LevelEducation.values(), "roles", Role.values(), "selectedRoles", selectedRoles);
}
Also used : Logger(org.webpieces.util.logging.Logger) EDIT_USER_PAGE(org.webpieces.plugins.hibernate.app.HibernateRouteId.EDIT_USER_PAGE) FlashAndRedirect(org.webpieces.router.api.actions.FlashAndRedirect) Redirect(org.webpieces.router.api.actions.Redirect) Render(org.webpieces.router.api.actions.Render) EntityManager(javax.persistence.EntityManager) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) Role(org.webpieces.plugins.hibernate.app.dbo.Role) ArrayList(java.util.ArrayList) ADD_USER_PAGE(org.webpieces.plugins.hibernate.app.HibernateRouteId.ADD_USER_PAGE) List(java.util.List) Query(javax.persistence.Query) Em(org.webpieces.plugins.hibernate.Em) UserRoleDbo(org.webpieces.plugins.hibernate.app.dbo.UserRoleDbo) LevelEducation(org.webpieces.plugins.hibernate.app.dbo.LevelEducation) UserTestDbo(org.webpieces.plugins.hibernate.app.dbo.UserTestDbo) LoggerFactory(org.webpieces.util.logging.LoggerFactory) Current(org.webpieces.ctx.api.Current) Actions(org.webpieces.router.api.actions.Actions) Role(org.webpieces.plugins.hibernate.app.dbo.Role) UserTestDbo(org.webpieces.plugins.hibernate.app.dbo.UserTestDbo) UserRoleDbo(org.webpieces.plugins.hibernate.app.dbo.UserRoleDbo)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Singleton (javax.inject.Singleton)1 EntityManager (javax.persistence.EntityManager)1 Query (javax.persistence.Query)1 Current (org.webpieces.ctx.api.Current)1 Em (org.webpieces.plugins.hibernate.Em)1 ADD_USER_PAGE (org.webpieces.plugins.hibernate.app.HibernateRouteId.ADD_USER_PAGE)1 EDIT_USER_PAGE (org.webpieces.plugins.hibernate.app.HibernateRouteId.EDIT_USER_PAGE)1 LevelEducation (org.webpieces.plugins.hibernate.app.dbo.LevelEducation)1 Role (org.webpieces.plugins.hibernate.app.dbo.Role)1 UserRoleDbo (org.webpieces.plugins.hibernate.app.dbo.UserRoleDbo)1 UserTestDbo (org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)1 Actions (org.webpieces.router.api.actions.Actions)1 FlashAndRedirect (org.webpieces.router.api.actions.FlashAndRedirect)1 Redirect (org.webpieces.router.api.actions.Redirect)1 Render (org.webpieces.router.api.actions.Render)1 Logger (org.webpieces.util.logging.Logger)1 LoggerFactory (org.webpieces.util.logging.LoggerFactory)1