@Override public boolean existsByName(TypeOfWorkHours typeOfWorkHours) { Criteria c = getSession() .createCriteria(TypeOfWorkHours.class) .add(Restrictions.eq("name", typeOfWorkHours.getName())); return c.uniqueResult() != null; }
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); } } }