private void extendTrialByGuid(TrialInstanceUpdateDto trialInstanceUpdateDto) { TrialInstance trialInstance = trialInstanceDao.findByGuid(trialInstanceUpdateDto.getGuid()); if (trialInstance == null || !trialInstanceDao.exists(trialInstance.getId())) { throw new CSWebApplicationException(StringDefs.GENERAL_ERROR_CODE, "GUID does not exist!"); } extendSingleTrialInstanceExpiration(trialInstance, daysToExtendFromDto(trialInstanceUpdateDto)); trialInstance.setUpdatedAt(trialInstanceUpdateDto.getUpdatedAt()); trialInstanceDao.save(trialInstance); trialInstanceDao.flush(); }
// will update full list and then save with DAO in bulk private void extendTrialInstanceExpiration( List<TrialInstance> trialInstances, TrialInstanceUpdateDto trialInstanceUpdateDto) { if (trialInstances == null) { return; } Integer days = daysToExtendFromDto(trialInstanceUpdateDto); for (TrialInstance trialInstance : trialInstances) { extendSingleTrialInstanceExpiration(trialInstance, days); trialInstance.setUpdatedAt(trialInstanceUpdateDto.getUpdatedAt()); } trialInstanceDao.save(trialInstances); }