@Override public Long create(Run run) throws IOException { authorizationManager.throwIfNotWritable(run); validateChanges(null, run); saveContainers(run); run.setChangeDetails(authorizationManager.getCurrentUser()); loadChildEntities(run); run.setSecurityProfile(securityProfileStore.get(securityProfileStore.save(run.getSecurityProfile()))); run.setName(generateTemporaryName()); Run saved = save(run); makeContainerChangesChangeLog(saved, Collections.emptyList(), saved.getSequencerPartitionContainers()); return saved.getId(); }
private SampleIdentity createParentIdentity(DetailedSample sample, SampleIdentity identity) throws IOException, MisoNamingException, SQLException { log.debug("Creating a new Identity to use as a parent."); List<SampleClass> identityClasses = sampleClassService.listByCategory(SampleIdentity.CATEGORY_NAME); if (identityClasses.size() != 1) { throw new IllegalStateException("Found more or less than one SampleClass of category " + SampleIdentity.CATEGORY_NAME + ". Cannot choose which to use as root sample class."); } SampleClass rootSampleClass = identityClasses.get(0); confirmExternalNameUniqueForProjectIfRequired(identity.getExternalName(), sample); Sample identitySample = new IdentityBuilder().project(sample.getProject()) .sampleType(sample.getSampleType()).scientificName(sample.getScientificName()).name(generateTemporaryName()) .rootSampleClass(rootSampleClass).volume(0D).externalName(identity.getExternalName()) .donorSex(identity.getDonorSex()).consentLevel(identity.getConsentLevel()).build(); identitySample.setAlias(namingScheme.generateSampleAlias(identitySample)); identitySample.setChangeDetails(authorizationManager.getCurrentUser()); identitySample.inheritPermissions(sample.getProject()); return (SampleIdentity) save(identitySample, true); }
target.setCreationTime(now); target.setCreator(user); target.setName(generateTemporaryName()); target.setAlias(source.getAlias()); isNew = true; target.setName(generateTemporaryName());
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); } }
pool.setName(generateTemporaryName()); loadSecurityProfile(pool); loadPoolDilutions(pool.getPoolDilutions(), pool);
@Override public Long create(Library library) throws IOException { if (library.getSample() != null && library.getSample().getId() == Sample.UNSAVED_ID) { Long sampleId = sampleService.create(library.getSample()); library.getSample().setId(sampleId); } loadChildEntities(library); boxService.throwIfBoxPositionIsFilled(library); library.setChangeDetails(authorizationManager.getCurrentUser()); if (library.getSecurityProfile() == null) { library.inheritPermissions(sampleService.get(library.getSample().getId())); } authorizationManager.throwIfNotWritable(library); validateParentOrThrow(library); // pre-save field generation library.setName(generateTemporaryName()); if (isStringEmptyOrNull(library.getAlias()) && namingScheme.hasLibraryAliasGenerator()) { library.setAlias(generateTemporaryName()); } if (library.getConcentration() == null) { library.setConcentrationUnits(null); } if (library.getVolume() == null) { library.setVolumeUnits(null); } validateChange(library, null); long savedId = save(library, true).getId(); boxService.updateBoxableLocation(library); return savedId; }
sample.setName(generateTemporaryName()); if (isStringEmptyOrNull(sample.getAlias()) && namingScheme.hasSampleAliasGenerator()) { sample.setAlias(generateTemporaryName());
project.setName(generateTemporaryName()); projectStore.save(project); try {
@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); } }
@Override public Long create(LibraryDilution dilution) throws IOException { loadChildEntities(dilution); dilution.setCreator(authorizationManager.getCurrentUser()); if (dilution.getSecurityProfile() == null) { dilution.inheritPermissions(libraryService.get(dilution.getLibrary().getId())); } authorizationManager.throwIfNotWritable(dilution); boxService.throwIfBoxPositionIsFilled(dilution); if (dilution.getConcentration() == null) { dilution.setConcentrationUnits(null); } if (dilution.getVolume() == null) { dilution.setVolumeUnits(null); } Library library = dilution.getLibrary(); if (dilution.getVolumeUsed() != null && library.getVolume() != null) { library.setVolume(library.getVolume() - dilution.getVolumeUsed()); } dilution.setChangeDetails(authorizationManager.getCurrentUser()); // pre-save field generation dilution.setName(generateTemporaryName()); validateChange(dilution, null); long savedId = save(dilution).getId(); libraryService.update(library); boxService.updateBoxableLocation(dilution); return savedId; }