private boolean isUniqueTitle(DistributionProtocol newDp, DistributionProtocol existingDp) { if (existingDp != null && newDp.getTitle().equals(existingDp.getTitle())) { return true; } DistributionProtocol existing = daoFactory.getDistributionProtocolDao().getDistributionProtocol(newDp.getTitle()); if (existing != null) { return false; } return true; }
private void ensureUniqueConstraints( DistributionProtocol newDp, DistributionProtocol existingDp) { OpenSpecimenException ose = new OpenSpecimenException(ErrorType.USER_ERROR); if (!isUniqueTitle(newDp, existingDp)) { ose.addError(DistributionProtocolErrorCode.DUP_TITLE, newDp.getTitle()); } if (!isUniqueShortTitle(newDp, existingDp)) { ose.addError(DistributionProtocolErrorCode.DUP_SHORT_TITLE, newDp.getShortTitle()); } ose.checkAndThrow(); }