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()); } }
private long saveNewBox(Box box) throws IOException { authorizationManager.throwIfNotWritable(box); try { box.setName(generateTemporaryName()); box.setSecurityProfile(securityProfileStore.get(securityProfileStore.save(box.getSecurityProfile()))); box.setChangeDetails(authorizationManager.getCurrentUser()); box.setIdentificationBarcode(LimsUtils.nullifyStringIfBlank(box.getIdentificationBarcode())); validateChange(box, null); boxStore.save(box); if (autoGenerateIdBarcodes) { box.setIdentificationBarcode(box.getName() + "::" + box.getAlias()); } box.setName(namingScheme.generateNameFor(box)); validateNameOrThrow(box, namingScheme); if (box.getStorageLocation() != null) { addStorageChangeLog(getFreezer(box), box, true); } return boxStore.save(box); } catch (MisoNamingException e) { throw new IOException("Invalid name for box", e); } }
validateNameOrThrow(pool, namingScheme); } catch (MisoNamingException e) { throw new IOException("Invalid name for pool", e);
throw new IOException("Cannot save Project - issue with naming scheme", e); LimsUtils.validateNameOrThrow(project, namingScheme); } else { Project original = projectStore.get(project.getId());
if (hasTemporaryName(sample)) { created.setName(namingScheme.generateNameFor(created)); validateNameOrThrow(created, namingScheme); needsUpdate = true;
if (hasTemporaryName(library)) { managed.setName(namingScheme.generateNameFor(managed)); validateNameOrThrow(managed, namingScheme); needsUpdate = true;
@Override public long save(Study study) throws IOException { if (study.getId() == StudyImpl.UNSAVED_ID) { study.setChangeDetails(authorizationManager.getCurrentUser()); study.setStudyType(studyStore.getType(study.getStudyType().getId())); study.setProject(projectStore.get(study.getProject().getId())); study.setName(LimsUtils.generateTemporaryName()); study.setSecurityProfile(study.getProject().getSecurityProfile()); long id = studyStore.save(study); try { study.setName(namingScheme.generateNameFor(study)); LimsUtils.validateNameOrThrow(study, namingScheme); studyStore.save(study); } catch (MisoNamingException e) { throw new IOException(e); } return id; } else { Study original = studyStore.get(study.getId()); authorizationManager.throwIfNotWritable(original); original.setAccession(study.getAccession()); original.setAlias(study.getAlias()); original.setDescription(study.getDescription()); original.setChangeDetails(authorizationManager.getCurrentUser()); // project is immutable original.setStudyType(studyStore.getType(study.getStudyType().getId())); return studyStore.save(original); } }