private Run save(Run run) throws IOException { try { Long id = runDao.save(run); Run saved = runDao.get(id); // post-save field generation boolean needsUpdate = false; if (hasTemporaryName(run)) { saved.setName(namingScheme.generateNameFor(saved)); validateNameOrThrow(saved, namingScheme); needsUpdate = true; } if (needsUpdate) { runDao.save(saved); saved = runDao.get(saved.getId()); } return saved; } catch (MisoNamingException e) { throw new IllegalArgumentException("Name generator failed to generate a valid name", e); } catch (ConstraintViolationException e) { // Send the nested root cause message to the user, since it contains the actual error. throw new ConstraintViolationException(e.getMessage() + " " + ExceptionUtils.getRootCauseMessage(e), e.getSQLException(), e.getConstraintName()); } }
private LibraryDilution save(LibraryDilution dilution) throws IOException { validateTargetedSequencing(dilution); dilution.setLastModifier(authorizationManager.getCurrentUser()); try { Long newId = dilutionDao.save(dilution); LibraryDilution managed = dilutionDao.get(newId); // post-save field generation boolean needsUpdate = false; if (hasTemporaryName(dilution)) { managed.setName(namingScheme.generateNameFor(managed)); validateNameOrThrow(managed, namingScheme); needsUpdate = true; } if (autoGenerateIdBarcodes && isStringEmptyOrNull(managed.getIdentificationBarcode())) { // if !autoGenerateIdBarcodes then the identificationBarcode is set by the user generateAndSetIdBarcode(managed); needsUpdate = true; } if (needsUpdate) dilutionDao.save(managed); return managed; } catch (MisoNamingException e) { throw new IllegalArgumentException("Name generator failed to generate valid name for library"); } catch (ConstraintViolationException e) { // Send the nested root cause message to the user, since it contains the actual error. throw new ConstraintViolationException(e.getMessage() + " " + ExceptionUtils.getRootCauseMessage(e), e.getSQLException(), e.getConstraintName()); } }
if (hasTemporaryName(sample)) { created.setName(namingScheme.generateNameFor(created)); validateNameOrThrow(created, namingScheme);
if (hasTemporaryName(library)) { managed.setName(namingScheme.generateNameFor(managed)); validateNameOrThrow(managed, namingScheme);