@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void deleteTest() throws IOException { Chromosome testChromosome = EntityHelper.createNewChromosome(); testChromosome.setSize(TEST_CHROMOSOME_SIZE); Reference testReference = EntityHelper.createNewReference(testChromosome, referenceGenomeManager.createReferenceId()); File tmp = File.createTempFile(TMP_FILE_NAME, TMP_FILE_NAME); testReference.setPath(tmp.getAbsolutePath()); referenceGenomeManager.create(testReference); Resource resource = context.getResource(CLASSPATH_TEMPLATES_FELIS_CATUS_VCF); FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest(); request.setReferenceId(testReference.getId()); request.setPath(resource.getFile().getAbsolutePath()); VcfFile vcfFile = vcfManager.registerVcfFile(request); dataItemManager.deleteFileByBioItemId(vcfFile.getBioDataItemId()); VcfFile loadedVcfFile = vcfFileManager.load(vcfFile.getId()); Assert.assertNull(loadedVcfFile); }
@Transactional(propagation = Propagation.REQUIRED) public BiologicalDataItem deleteFileByBioItemId(Long id) throws IOException { List<BiologicalDataItem> items = biologicalDataItemDao.loadBiologicalDataItemsByIds( Collections.singletonList(id)); Assert.notNull(items, getMessage(ERROR_BIO_ID_NOT_FOUND, id)); Assert.isTrue(!items.isEmpty(), getMessage(ERROR_BIO_ID_NOT_FOUND, id)); final BiologicalDataItem item = items.get(0); final Long itemId = item.getId(); if (item.getId() == null || item.getId() == 0) { biologicalDataItemDao.deleteBiologicalDataItem(id); return item; } switch (item.getFormat()) { case BAM: bamManager.unregisterBamFile(itemId); break; case BED: bedManager.unregisterBedFile(itemId); break; case GENE: geneManager.unregisterGeneFile(itemId); break; case WIG: facadeWigManager.unregisterWigFile(itemId); break; case SEG: segManager.unregisterSegFile(itemId); break; case MAF: mafManager.unregisterMafFile(itemId); break; case VCF: vcfManager.unregisterVcfFile(itemId); break; default: throw new IllegalArgumentException(getMessage(ERROR_UNSUPPORTED_FILE_FORMAT, item.getFormat())); } return item; }
DataItemManager { @Transactional(propagation = Propagation.REQUIRED) public BiologicalDataItem deleteFileByBioItemId(Long id) throws IOException { List<BiologicalDataItem> items = biologicalDataItemDao.loadBiologicalDataItemsByIds( Collections.singletonList(id)); Assert.notNull(items, getMessage(ERROR_BIO_ID_NOT_FOUND, id)); Assert.isTrue(!items.isEmpty(), getMessage(ERROR_BIO_ID_NOT_FOUND, id)); final BiologicalDataItem item = items.get(0); final Long itemId = item.getId(); if (item.getId() == null || item.getId() == 0) { biologicalDataItemDao.deleteBiologicalDataItem(id); return item; } switch (item.getFormat()) { case BAM: bamManager.unregisterBamFile(itemId); break; case BED: bedManager.unregisterBedFile(itemId); break; case GENE: geneManager.unregisterGeneFile(itemId); break; case WIG: facadeWigManager.unregisterWigFile(itemId); break; case SEG: segManager.unregisterSegFile(itemId); break; case MAF: mafManager.unregisterMafFile(itemId); break; case VCF: vcfManager.unregisterVcfFile(itemId); break; default: throw new IllegalArgumentException(getMessage(ERROR_UNSUPPORTED_FILE_FORMAT, item.getFormat())); } return item; } }
DataItemManager { @Transactional(propagation = Propagation.REQUIRED) public BiologicalDataItem deleteFileByBioItemId(Long id) throws IOException { List<BiologicalDataItem> items = biologicalDataItemDao.loadBiologicalDataItemsByIds( Collections.singletonList(id)); Assert.notNull(items, getMessage(ERROR_BIO_ID_NOT_FOUND, id)); Assert.isTrue(!items.isEmpty(), getMessage(ERROR_BIO_ID_NOT_FOUND, id)); final BiologicalDataItem item = items.get(0); final Long itemId = item.getId(); if (item.getId() == null || item.getId() == 0) { biologicalDataItemDao.deleteBiologicalDataItem(id); return item; } switch (item.getFormat()) { case BAM: bamManager.unregisterBamFile(itemId); break; case BED: bedManager.unregisterBedFile(itemId); break; case GENE: geneManager.unregisterGeneFile(itemId); break; case WIG: facadeWigManager.unregisterWigFile(itemId); break; case SEG: segManager.unregisterSegFile(itemId); break; case MAF: mafManager.unregisterMafFile(itemId); break; case VCF: vcfManager.unregisterVcfFile(itemId); break; default: throw new IllegalArgumentException(getMessage(ERROR_UNSUPPORTED_FILE_FORMAT, item.getFormat())); } return item; }  }
DataItemManager { @Transactional(propagation = Propagation.REQUIRED) public BiologicalDataItem deleteFileByBioItemId(Long id) throws IOException { List<BiologicalDataItem> items = biologicalDataItemDao.loadBiologicalDataItemsByIds( Collections.singletonList(id)); Assert.notNull(items, getMessage(ERROR_BIO_ID_NOT_FOUND, id)); Assert.isTrue(!items.isEmpty(), getMessage(ERROR_BIO_ID_NOT_FOUND, id)); final BiologicalDataItem item = items.get(0); final Long itemId = item.getId(); if (item.getId() == null || item.getId() == 0) { biologicalDataItemDao.deleteBiologicalDataItem(id); return item; } switch (item.getFormat()) { case BAM: bamManager.unregisterBamFile(itemId); break; case BED: bedManager.unregisterBedFile(itemId); break; case GENE: geneManager.unregisterGeneFile(itemId); break; case WIG: facadeWigManager.unregisterWigFile(itemId); break; case SEG: segManager.unregisterSegFile(itemId); break; case MAF: mafManager.unregisterMafFile(itemId); break; case VCF: vcfManager.unregisterVcfFile(itemId); break; default: throw new IllegalArgumentException(getMessage(ERROR_UNSUPPORTED_FILE_FORMAT, item.getFormat())); } return item; }  @Transactional(propagation = Propagation.SUPPORTS) List<BiologicalDataItem> findFilesByName(final String name, boolean strict); @Transactional(propagation = Propagation.REQUIRED) BiologicalDataItem findFileByBioItemId(Long id); @Transactional(propagation = Propagation.REQUIRED) BiologicalDataItem deleteFileByBioItemId(Long id); }
DataItemManager { @Transactional(propagation = Propagation.REQUIRED) public BiologicalDataItem deleteFileByBioItemId(Long id) throws IOException { List<BiologicalDataItem> items = biologicalDataItemDao.loadBiologicalDataItemsByIds( Collections.singletonList(id)); Assert.notNull(items, getMessage(ERROR_BIO_ID_NOT_FOUND, id)); Assert.isTrue(!items.isEmpty(), getMessage(ERROR_BIO_ID_NOT_FOUND, id)); final BiologicalDataItem item = items.get(0); final Long itemId = item.getId(); if (item.getId() == null || item.getId() == 0) { biologicalDataItemDao.deleteBiologicalDataItem(id); return item; } switch (item.getFormat()) { case BAM: bamManager.unregisterBamFile(itemId); break; case BED: bedManager.unregisterBedFile(itemId); break; case GENE: geneManager.unregisterGeneFile(itemId); break; case WIG: facadeWigManager.unregisterWigFile(itemId); break; case SEG: segManager.unregisterSegFile(itemId); break; case MAF: mafManager.unregisterMafFile(itemId); break; case VCF: vcfManager.unregisterVcfFile(itemId); break; default: throw new IllegalArgumentException(getMessage(ERROR_UNSUPPORTED_FILE_FORMAT, item.getFormat())); } return item; }  @Transactional(propagation = Propagation.SUPPORTS) List<BiologicalDataItem> findFilesByName(final String name, boolean strict); @Transactional(propagation = Propagation.REQUIRED) BiologicalDataItem findFileByBioItemId(Long id); @Transactional(propagation = Propagation.REQUIRED) BiologicalDataItem deleteFileByBioItemId(Long id);  }