@Override public List<SampleDraft> createNewHelpDNASampleDrafts( SampleDraft sampleDraft, List<String> librariesToCreateList) { List<SampleDraft> newSampleDrafts = new ArrayList<SampleDraft>(); for (String libraryTypeToCreate : librariesToCreateList) { SampleDraft clone = sampleService.cloneSampleDraft(sampleDraft); List<SampleDraftMeta> sampleDraftMetaList = clone.getSampleDraftMeta(); clone.setName(clone.getName() + "_" + libraryTypeToCreate); SampleDraft cloneDB = sampleService.getSampleDraftDao().save(clone); cloneDB.setSampleDraftMeta(sampleDraftMetaList); this.resetLibraryToCreateMetaData(cloneDB, libraryTypeToCreate); newSampleDrafts.add(cloneDB); } return newSampleDrafts; }
@Override public boolean isBetaGTMspI(Sample s) { String enzymeString; try { if (s.getParentId() != null) { // if it has a parent sample, which means it's a facility library, use its parent sample to // check for library type s = sampleService.getSampleById(s.getParentId()); } if (!s.getSampleType().getIName().equalsIgnoreCase("dna")) { // not dna, so must be library enzymeString = (String) MetaHelper.getMetaValue( HELPTAG_LIB_AREA, RESTRICTION_ENZYME_META_KEY, s.getSampleMeta()); } else { // genomic DNA enzymeString = (String) MetaHelper.getMetaValue( HELPTAG_DNA_AREA, TYPE_OF_HELP_LIBRARY_REQUESTED_META_KEY, s.getSampleMeta()); } if (enzymeString.equals("beta-GT-MspI")) { return true; } } catch (MetadataException e) { // not found logger.debug( "Restriction Enzyme Meta (and libraryToCreate meta) not found for Sample id = " + s.getId()); } return false; }
private void resetLibraryToCreateMetaData(SampleDraft clone, String libraryTypeToCreate) { for (SampleDraftMeta sdm : clone.getSampleDraftMeta()) { if (sdm.getK().endsWith("typeOfHelpLibraryRequested")) { sdm.setV(libraryTypeToCreate); } sdm.setSampleDraftId(clone.getId()); // must do this for every meta entry sampleService.getSampleDraftMetaDao().save(sdm); // then must do this for every meta entry } }