@Override @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true) public boolean isUnique(QualityForm qualityForm) { try { QualityForm result = findUniqueByName(qualityForm); return (result == null || result.getId().equals(qualityForm.getId())); } catch (Exception e) { e.printStackTrace(); return false; } }
@Override public void save(QualityForm entity) throws ValidationException { if (entity.isReportAdvance()) { String name = QualityForm.ADVANCE_TYPE_PREFIX + entity.getName(); AdvanceType advanceType = entity.getAdvanceType(); if (advanceType != null) { advanceTypeDAO.save(advanceType); advanceType.setUnitName(name); } else { advanceType = AdvanceType.create( name, new BigDecimal(100), false, new BigDecimal(0.01), true, true, true); advanceTypeDAO.save(advanceType); entity.setAdvanceType(advanceType); } } super.save(entity); }
@Override @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true) public QualityForm findUniqueByName(QualityForm qualityForm) throws InstanceNotFoundException { Validate.notNull(qualityForm); return findUniqueByName(qualityForm.getName()); }