@Override public TypeOfWorkHours findUniqueByCode(TypeOfWorkHours typeOfWorkHours) throws InstanceNotFoundException { Validate.notNull(typeOfWorkHours); return findUniqueByCode(typeOfWorkHours.getCode()); }
@Override public boolean existsByName(TypeOfWorkHours typeOfWorkHours) { Criteria c = getSession() .createCriteria(TypeOfWorkHours.class) .add(Restrictions.eq("name", typeOfWorkHours.getName())); return c.uniqueResult() != null; }
private void checkIsPersonalTimesheetsTypeOfWorkHours(TypeOfWorkHours type) { Configuration configuration = configurationDAO.getConfiguration(); if (configuration.getPersonalTimesheetsTypeOfWorkHours().getId().equals(type.getId())) { throw ValidationException.invalidValueException( "Cannot delete the type of work hours. It is configured as type of work hours for personal timesheets.", type); } }
private void checkIsJiraConnectorTypeOfWorkHours(TypeOfWorkHours type) { Connector connector = connectorDAO.findUniqueByName(PredefinedConnectors.JIRA.getName()); if (connector != null) { String name = connector.getPropertiesAsMap().get(PredefinedConnectorProperties.JIRA_HOURS_TYPE); if (name.equals(type.getName())) { throw ValidationException.invalidValueException( "Cannot delete the type of work hours. It is configured as type of work hours for JIRA connector.", type); } } }