use of webpiecesxxxxxpackage.db.UserDbo in project webpieces by deanhiller.
the class CrudUserController method userList.
public Action userList() {
EntityManager mgr = Em.get();
Query query = mgr.createNamedQuery("findAllUsers");
@SuppressWarnings("unchecked") List<UserDbo> users = query.getResultList();
return Actions.renderThis("users", users);
}
use of webpiecesxxxxxpackage.db.UserDbo in project webpieces by deanhiller.
the class CrudUserController method postDeleteUser.
public Redirect postDeleteUser(int id) {
UserDbo ref = Em.get().find(UserDbo.class, id);
List<UserRole> roles = ref.getRoles();
for (UserRole r : roles) {
Em.get().remove(r);
}
Em.get().remove(ref);
Em.get().flush();
Current.flash().setMessage("User deleted");
Current.flash().keep(true);
Current.validation().keep(false);
return Actions.redirect(CrudUserRouteId.LIST_USERS);
}
use of webpiecesxxxxxpackage.db.UserDbo in project webpieces by deanhiller.
the class CrudUserController method userAddEdit.
public Action userAddEdit(Integer id) {
if (id == null) {
return Actions.renderThis("entity", new UserDbo(), "levels", EducationEnum.values(), "roles", RoleEnum.values(), "selectedRoles", null, "password", null);
}
UserDbo user = UserDbo.findWithJoin(Em.get(), id);
List<UserRole> roles = user.getRoles();
List<RoleEnum> selectedRoles = roles.stream().map(r -> r.getRole()).collect(Collectors.toList());
return Actions.renderThis("entity", user, "levels", EducationEnum.values(), "roles", RoleEnum.values(), "selectedRoles", selectedRoles, "password", null);
}
use of webpiecesxxxxxpackage.db.UserDbo in project webpieces by deanhiller.
the class AjaxCrudUserController method postDeleteUser.
public Redirect postDeleteUser(int id) {
UserDbo ref = Em.get().find(UserDbo.class, id);
List<UserRole> roles = ref.getRoles();
for (UserRole r : roles) {
Em.get().remove(r);
}
Em.get().remove(ref);
Em.get().flush();
Current.flash().setMessage("User deleted");
Current.flash().keep(true);
Current.validation().keep(false);
return Actions.redirect(AjaxCrudUserRouteId.AJAX_LIST_USERS);
}
use of webpiecesxxxxxpackage.db.UserDbo in project webpieces by deanhiller.
the class AjaxCrudUserController method userList.
public Action userList() {
EntityManager mgr = Em.get();
Query query = mgr.createNamedQuery("findAllUsers");
@SuppressWarnings("unchecked") List<UserDbo> users = query.getResultList();
boolean showEditPopup = Current.flash().isShowEditPopup();
return Actions.renderThis("users", users, "showPopup", showEditPopup);
}
Aggregations