public AppRoleVo getAppRoleByTaxonomyType(String extId, TaxonomyType taxonomyType) { if (extId == null || taxonomyType == null) return null; DomainFactory factory = (DomainFactory) this.getDomainFactory(); String hql = " from AppRole ar join ar.codeMappings as cm where cm.taxonomyName = :taxType and cm.taxonomyCode = :extId "; List appRole = factory.find(hql,new String[]{"taxType", "extId"}, new Object[]{getDomLookup(taxonomyType),extId}); if (appRole != null && appRole.size() == 1) return AppRoleVoAssembler.create((AppRole) appRole.get(0)); else if (appRole != null && appRole.size() > 1) throw new DomainRuntimeException("Non unique hit on AppRole by TaxonomyType " + taxonomyType.getText() + " and code " + extId); return null; }
public IAppRole getRole(int roleId) { DomainFactory factory = getDomainFactory(); AppRole domRole = (AppRole)factory.getDomainObject(AppRole.class, roleId); return AppRoleVoAssembler.create(domRole); }
public AppRoleVo saveRole(AppRoleVo voRole) throws StaleObjectException, UniqueKeyViolationException { if (!voRole.isValidated()) { throw new DomainRuntimeException("Role ValueObject has not been validated"); } DomainFactory factory = getDomainFactory(); AppRole domRole = AppRoleVoAssembler.extractAppRole(factory, voRole); try { if (voRole.getCodeMappingsIsNotNull()) { boolean found = false; StringBuilder errors = new StringBuilder(); for (int i = 0; i < voRole.getCodeMappings().size(); i++) { TaxonomyMap code = voRole.getCodeMappings().get(i); AppRole appRole = getAppRoleByTaxonomy(code.getTaxonomyCode(), code.getTaxonomyName()); if (appRole != null && appRole.getId() != voRole.getId()) { found = true; errors.append("\nRole '" + appRole.getName() + "' aleady have mapped :"); errors.append(" TaxonomyType '" + code.getTaxonomyName() + "' and code '" + code.getTaxonomyCode() + "'"); } } if(found) throw new UniqueKeyViolationException(errors.toString()); } factory.save(domRole); } catch(UnqViolationUncheckedException e) { throw new UniqueKeyViolationException("A role with this name already exists within the system, please change", e); } return AppRoleVoAssembler.create(domRole); }
public AppRoleVo getRole(AppRoleShortVo roleVo) { DomainFactory factory = getDomainFactory(); return AppRoleVoAssembler.create((AppRole)factory.getDomainObject(AppRole.class, roleVo.getID_AppRole())); }
public AppRoleVo saveRole(AppRoleVo voRole) throws StaleObjectException, UniqueKeyViolationException { if (!voRole.isValidated()) { throw new DomainRuntimeException("Role ValueObject has not been validated"); } DomainFactory factory = getDomainFactory(); AppRole domRole = AppRoleVoAssembler.extractAppRole(factory, voRole); try { if (voRole.getCodeMappingsIsNotNull()) { boolean found = false; StringBuilder errors = new StringBuilder(); for (int i = 0; i < voRole.getCodeMappings().size(); i++) { TaxonomyMap code = voRole.getCodeMappings().get(i); AppRole appRole = getAppRoleByTaxonomy(code.getTaxonomyCode(), code.getTaxonomyName()); if (appRole != null && appRole.getId() != voRole.getId()) { found = true; errors.append("\nRole '" + appRole.getName() + "' aleady have mapped :"); errors.append(" TaxonomyType '" + code.getTaxonomyName() + "' and code '" + code.getTaxonomyCode() + "'"); } } if(found) throw new UniqueKeyViolationException(errors.toString()); } factory.save(domRole); } catch(UnqViolationUncheckedException e) { throw new UniqueKeyViolationException("A role with this name already exists within the system, please change", e); } //Map role to client ID SessionData sessData = (SessionData)factory.getDomainSession().getAttribute(SessionConstants.SESSION_DATA); sessData.clientAutolockTimer.get().put(sessData.uniqueClientId.get(), voRole); return AppRoleVoAssembler.create(domRole); }