@Transactional public String addNewRole() { String returnString = ""; try { if (roleSysHome != null) { String entityAction = roleSysHome.persist(); if (entityAction.equalsIgnoreCase("persisted")) { // returnString = "role-loaded"; addNew = false; facesMessages.clear(); facesMessages.clearGlobalMessages(); } } } catch (Exception e) { log.error(e.getMessage()); System.out.println(e.getMessage()); } return returnString; }
// Ajax Callback @Transactional public void activateRole(RoleSys role, Boolean active) { try { if (roleSysHome != null) { roleSysHome.setInstance(role); roleSysHome.wire(); if (active) { roleSysHome.getInstance().setActive(true); } else { roleSysHome.getInstance().setActive(false); } String entityAction = roleSysHome.update(); if (entityAction.equalsIgnoreCase("updated")) { facesMessages.clear(); facesMessages.clearGlobalMessages(); } roleSysHome.clearInstance(); roleSysHome.clearDirty(); } } catch (Exception e) { System.out.println(e.getMessage()); } }
public String loadRole(RoleSys role) { String returnString = ""; try { if (role != null && role.getRoleId() != 0) { roleSysHome.clearInstance(); roleSysHome.setRoleHomeId(role.getRoleId()); roleSysHome.wire(); returnString = "role-loaded"; } } catch (Exception e) { log.error(e.getMessage()); System.out.println(e.getMessage()); } return returnString; }
@Transactional public void deleteFunction(RoleSys role, Function function) { try { if (role != null && function != null) { roleSysHome.clearInstance(); roleSysHome.setRoleHomeId(role.getRoleId()); roleSysHome.wire(); roleSysHome.getInstance().getFunctions().remove(function); String entityAction = roleSysHome.update(); if (entityAction.equalsIgnoreCase("updated")) { facesMessages.clear(); facesMessages.clearGlobalMessages(); } roleSysHome.createInstance(); } } catch (Exception e) { System.out.println(e.getMessage()); } }
// Ajax Callback @Transactional public void updateRole() { try { if (roleSysHome != null) { String entityAction = roleSysHome.update(); if (entityAction.equalsIgnoreCase("updated")) { facesMessages.clear(); facesMessages.clearGlobalMessages(); } } } catch (Exception e) { log.error(e.getMessage()); System.out.println(e.getMessage()); } }
@Transactional public String addFunction() { String returnString = ""; try { if (roleSysHome.isLoaded()) { // delete permission if (!roleSysHome.getInstance().getPermissions().isEmpty()) { for (Permission p : roleSysHome.getInstance().getPermissions()) { if (p != null && p.getFunction() != null) { Boolean selectedFunction = false; for (Function f : roleSysHome.getInstance().getFunctions()) { if (f != null && p.getFunction().equals(f)) { selectedFunction = true; } } if (!selectedFunction) { p.setDeleted(true); p.setUpdateDate(new Date()); } } } } // add permission if (!roleSysHome.getInstance().getFunctions().isEmpty()) { for (Function f : roleSysHome.getInstance().getFunctions()) { if (f != null) { Boolean functionExist = false; for (Permission p : roleSysHome.getInstance().getPermissions()) { if (p != null && !p.getDeleted() && p.getFunction() != null && p.getFunction().equals(f)) { functionExist = true; } } if (!functionExist) { Permission permission = new Permission(); permission.setFunction(f); permission.setRole(roleSysHome.getInstance()); roleSysHome.getInstance().addPermission(permission); } } } } roleSysHome.getInstance().setUpdateDate(new Date()); String entityAction = roleSysHome.update(); if (entityAction.equalsIgnoreCase("updated")) { facesMessages.clear(); facesMessages.clearGlobalMessages(); init(); } } } catch (Exception e) { log.error(e.getMessage()); System.out.println(e.getMessage()); } return returnString; }
// Ajax Callback public void changeLetterCasing() { /*if(lookupItemHome != null && lookupItemHome.getInstance().getName() != null && !lookupItemHome.getInstance().getName().equalsIgnoreCase("")){ lookupItemHome.getInstance().setName(toCamelCase(lookupItemHome.getInstance().getName())); }*/ if (roleSysHome != null && roleSysHome.getInstance().getInternalCode() != null && !roleSysHome.getInstance().getInternalCode().equalsIgnoreCase("")) { String tempGroupCode = roleSysHome.getInstance().getInternalCode().toUpperCase(); tempGroupCode = tempGroupCode.replaceAll("\\s+", ""); roleSysHome.getInstance().setInternalCode(tempGroupCode); } if (roleSysHome != null && roleSysHome.getInstance().getGroupCode() != null && !roleSysHome.getInstance().getGroupCode().equalsIgnoreCase("")) { String tempGroupCode = roleSysHome.getInstance().getGroupCode().toUpperCase(); tempGroupCode = tempGroupCode.replaceAll("\\s+", ""); roleSysHome.getInstance().setGroupCode(tempGroupCode); } if (roleSysHome != null && roleSysHome.getInstance().getRoleType() != null && !roleSysHome.getInstance().getRoleType().equalsIgnoreCase("")) { String tempRoleType = roleSysHome.getInstance().getRoleType().toUpperCase(); tempRoleType = tempRoleType.replaceAll("\\s+", ""); roleSysHome.getInstance().setRoleType(tempRoleType); } }
public String cancelAddFunction() { init(); roleSysHome.refresh(); return "cancel"; }
public void prepareNewRole() { roleSysHome.clearInstance(); roleSysHome.wire(); addNew = true; }