CCM NG/ccm-core: Fixed Role#hashCode and Role#equals which were giving inconsitent results due to use of lazily fetched attribute.
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4864 8810af33-2d31-482b-a856-94f89814c4df
Former-commit-id: a2e014dbe8
pull/2/head
parent
36f19d6f53
commit
4100f4557b
|
|
@ -77,6 +77,7 @@ public class LoginView extends CustomComponent implements View {
|
|||
|
||||
formLayout = new FormLayout();
|
||||
formLayout.setSizeFull();
|
||||
formLayout.setMargin(true);
|
||||
|
||||
userName = new TextField();
|
||||
userName.setCaption("User name");
|
||||
|
|
@ -126,7 +127,6 @@ public class LoginView extends CustomComponent implements View {
|
|||
// submitButton.removeClickShortcut();
|
||||
// }
|
||||
// });
|
||||
|
||||
password.addFocusListener(event -> {
|
||||
submitButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);
|
||||
});
|
||||
|
|
@ -136,15 +136,13 @@ public class LoginView extends CustomComponent implements View {
|
|||
|
||||
loginPanel = new Panel("Login", formLayout);
|
||||
|
||||
loginPanel.setWidth(
|
||||
"24em");
|
||||
loginPanel.setWidth("24em");
|
||||
|
||||
final VerticalLayout viewLayout = new VerticalLayout(loginPanel);
|
||||
|
||||
viewLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
|
||||
|
||||
setCompositionRoot(viewLayout);
|
||||
|
||||
super.setCompositionRoot(viewLayout);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ public class GroupSelectorDataProvider extends AbstractDataProvider<Group, Strin
|
|||
criteriaQuery.where(builder.not(from.in(excludedGroups)));
|
||||
}
|
||||
|
||||
criteriaQuery.orderBy(builder.asc(from.get("name")));
|
||||
|
||||
return entityManager
|
||||
.createQuery(criteriaQuery)
|
||||
.setMaxResults(query.getLimit())
|
||||
|
|
|
|||
|
|
@ -18,23 +18,19 @@
|
|||
*/
|
||||
package org.libreccm.admin.ui.usersgroupsroles;
|
||||
|
||||
import com.arsdigita.ui.admin.AdminUiConstants;
|
||||
|
||||
import com.vaadin.icons.VaadinIcons;
|
||||
import com.vaadin.ui.Button;
|
||||
|
||||
import com.vaadin.ui.Grid;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.Window;
|
||||
import com.vaadin.ui.components.grid.HeaderCell;
|
||||
import com.vaadin.ui.components.grid.HeaderRow;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.Role;
|
||||
import org.libreccm.security.RoleRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -42,14 +38,9 @@ import java.util.ResourceBundle;
|
|||
*/
|
||||
public class RoleSelector extends Window {
|
||||
|
||||
private static final long serialVersionUID = -1437536052155383270L;
|
||||
private static final long serialVersionUID = -6893510634359633368L;
|
||||
|
||||
private static final String COL_NAME = "rolename";
|
||||
private static final String COL_OTHER = "other";
|
||||
|
||||
private final RoleRepository roleRepo;
|
||||
|
||||
private final RoleSelectionAction roleSelectionAction;
|
||||
|
||||
public RoleSelector(final String caption,
|
||||
final String actionLabel,
|
||||
|
|
@ -57,10 +48,6 @@ public class RoleSelector extends Window {
|
|||
final List<Role> excludedRoles,
|
||||
final RoleSelectionAction action) {
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
roleRepo = cdiUtil.findBean(RoleRepository.class);
|
||||
this.roleSelectionAction = action;
|
||||
|
||||
addWidgets(caption, actionLabel, excludedRoles, action);
|
||||
}
|
||||
|
||||
|
|
@ -71,9 +58,9 @@ public class RoleSelector extends Window {
|
|||
|
||||
setCaption(caption);
|
||||
|
||||
final ResourceBundle bundle = ResourceBundle
|
||||
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
||||
UI.getCurrent().getLocale());
|
||||
// final ResourceBundle bundle = ResourceBundle
|
||||
// .getBundle(AdminUiConstants.ADMIN_BUNDLE,
|
||||
// UI.getCurrent().getLocale());
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
|
||||
|
|
@ -82,10 +69,6 @@ public class RoleSelector extends Window {
|
|||
.addColumn(Role::getName)
|
||||
.setId(COL_NAME)
|
||||
.setCaption("Role");
|
||||
rolesGrid
|
||||
.addColumn(role -> " ")
|
||||
.setId(COL_OTHER)
|
||||
.setCaption(" ");
|
||||
|
||||
rolesGrid.setSelectionMode(Grid.SelectionMode.MULTI);
|
||||
rolesGrid.setWidth("100%");
|
||||
|
|
@ -95,7 +78,6 @@ public class RoleSelector extends Window {
|
|||
action.action(rolesGrid.getSelectedItems());
|
||||
close();
|
||||
});
|
||||
|
||||
actionButton.setIcon(VaadinIcons.PLUS_CIRCLE_O);
|
||||
actionButton.setStyleName(ValoTheme.BUTTON_TINY);
|
||||
|
||||
|
|
@ -107,8 +89,7 @@ public class RoleSelector extends Window {
|
|||
clearButton.setStyleName(ValoTheme.BUTTON_TINY);
|
||||
|
||||
final HeaderRow actions = rolesGrid.prependHeaderRow();
|
||||
final HeaderCell actionsCell = actions.join(COL_NAME,
|
||||
COL_OTHER);
|
||||
final HeaderCell actionsCell = actions.getCell(COL_NAME);
|
||||
actionsCell.setComponent(new HorizontalLayout(actionButton,
|
||||
clearButton));
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import javax.transaction.Transactional;
|
|||
@ViewScoped
|
||||
public class RoleSelectorDataProvider extends AbstractDataProvider<Role, String> {
|
||||
|
||||
private static final long serialVersionUID = 3915041291561733758L;
|
||||
private static final long serialVersionUID = 6142912046579055420L;
|
||||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
|
@ -58,14 +58,13 @@ public class RoleSelectorDataProvider extends AbstractDataProvider<Role, String>
|
|||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@Override
|
||||
public int size(final Query<Role, String> query) {
|
||||
|
||||
final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
|
||||
final CriteriaQuery<Long> criteriaQuery = builder
|
||||
.createQuery(Long.class);
|
||||
final Root<Role> from = criteriaQuery.from(Role.class);
|
||||
|
||||
criteriaQuery
|
||||
.select(builder.count(from))
|
||||
.distinct(true);
|
||||
criteriaQuery.select(builder.count(from));
|
||||
criteriaQuery.distinct(true);
|
||||
|
||||
if (roleNameFilter != null && !roleNameFilter.trim().isEmpty()) {
|
||||
criteriaQuery
|
||||
|
|
@ -86,11 +85,11 @@ public class RoleSelectorDataProvider extends AbstractDataProvider<Role, String>
|
|||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
@Override
|
||||
public Stream<Role> fetch(final Query<Role, String> query) {
|
||||
|
||||
final CriteriaBuilder builder = entityManager.getCriteriaBuilder();
|
||||
final CriteriaQuery<Role> criteriaQuery = builder
|
||||
.createQuery(Role.class);
|
||||
.createQuery(Role.class);
|
||||
final Root<Role> from = criteriaQuery.from(Role.class);
|
||||
|
||||
criteriaQuery.distinct(true);
|
||||
|
||||
if (roleNameFilter != null && !roleNameFilter.trim().isEmpty()) {
|
||||
|
|
@ -115,11 +114,12 @@ public class RoleSelectorDataProvider extends AbstractDataProvider<Role, String>
|
|||
|
||||
public void setRoleNameFilter(final String roleNameFilter) {
|
||||
this.roleNameFilter = roleNameFilter;
|
||||
refreshAll();
|
||||
// refreshAll();
|
||||
}
|
||||
|
||||
public void setExcludedRoles(final List<Role> excluededRoles) {
|
||||
this.excludedRoles = new ArrayList<>(excluededRoles);
|
||||
refreshAll();
|
||||
public void setExcludedRoles(final List<Role> excludedRoles) {
|
||||
this.excludedRoles = new ArrayList<>(excludedRoles);
|
||||
// refreshAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ public class Role implements Serializable, Portable {
|
|||
int hash = 7;
|
||||
hash = 53 * hash + (int) (roleId ^ (roleId >>> 32));
|
||||
hash = 53 * hash + Objects.hashCode(name);
|
||||
hash = 53 * hash + Objects.hashCode(permissions);
|
||||
// hash = 53 * hash + Objects.hashCode(permissions);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
|
@ -319,10 +319,12 @@ public class Role implements Serializable, Portable {
|
|||
if (roleId != other.getRoleId()) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(name, other.getName())) {
|
||||
return false;
|
||||
}
|
||||
return Objects.equals(permissions, other.getPermissions());
|
||||
|
||||
return Objects.equals(name, other.getName());
|
||||
// if (!Objects.equals(name, other.getName())) {
|
||||
// return false;
|
||||
// }
|
||||
// return Objects.equals(permissions, other.getPermissions());
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object obj) {
|
||||
|
|
|
|||
|
|
@ -612,3 +612,4 @@ ui.admin.importexport.import.current_status=Import current status
|
|||
ui.admin.importexport.import.report=Report from last import process
|
||||
ui.groups.roles.remove=Remove
|
||||
ui.user.groups.remove=Remove
|
||||
ui.user.roles.remove=Remove
|
||||
|
|
|
|||
|
|
@ -616,3 +616,4 @@ ui.admin.importexport.import.current_status=Aktueller Status des Import-Prozesse
|
|||
ui.admin.importexport.import.report=Bericht des letzten Import-Prozesses
|
||||
ui.groups.roles.remove=Entfernen
|
||||
ui.user.groups.remove=Entfernen
|
||||
ui.user.roles.remove=Entfernen
|
||||
|
|
|
|||
|
|
@ -609,3 +609,4 @@ ui.admin.importexport.import.current_status=Import current status
|
|||
ui.admin.importexport.import.report=Report from last import process
|
||||
ui.groups.roles.remove=Remove
|
||||
ui.user.groups.remove=Remove
|
||||
ui.user.roles.remove=Remove
|
||||
|
|
|
|||
|
|
@ -600,3 +600,4 @@ ui.admin.importexport.import.current_status=Import current status
|
|||
ui.admin.importexport.import.report=Report from last import process
|
||||
ui.groups.roles.remove=Remove
|
||||
ui.user.groups.remove=Remove
|
||||
ui.user.roles.remove=Remove
|
||||
|
|
|
|||
Loading…
Reference in New Issue