本文整理汇总了Java中org.springframework.transaction.annotation.Propagation.REQUIRES_NEW属性的典型用法代码示例。如果您正苦于以下问题:Java Propagation.REQUIRES_NEW属性的具体用法?Java Propagation.REQUIRES_NEW怎么用?Java Propagation.REQUIRES_NEW使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.transaction.annotation.Propagation
的用法示例。
在下文中一共展示了Propagation.REQUIRES_NEW属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLoadSmallScaleVcfFile
/**
* Tests vcfFileManager.loadVcfFile() behaviour on small scale factors.
* Should return a number of variations having type STATISTIC and variationsCount > 1
*/
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadSmallScaleVcfFile() throws IOException, InterruptedException, VcfReadingException {
VcfFile vcfFile = testSave(CLASSPATH_TEMPLATES_FELIS_CATUS_VCF);
VcfFile file = vcfFileManager.loadVcfFile(vcfFile.getId());
Assert.assertNotNull(file);
Track<Variation> trackResult = testLoad(vcfFile, TEST_SMALL_SCALE_FACTOR, true);
List<Variation> ambiguousVariations = trackResult.getBlocks().stream().filter((b) ->
b.getVariationsCount() != null && b.getVariationsCount() > 1).collect(Collectors.toList());
Assert.assertFalse(ambiguousVariations.isEmpty());
/// test not collapsed
trackResult = testLoad(vcfFile, TEST_SMALL_SCALE_FACTOR, true, false);
ambiguousVariations = trackResult.getBlocks().stream()
.filter((b) -> b.getVariationsCount() != null && b.getVariationsCount() > 1)
.collect(Collectors.toList());
Assert.assertTrue(ambiguousVariations.isEmpty());
}
示例2: testGetVariantsGA4GH
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testGetVariantsGA4GH() throws IOException, InterruptedException,
ExternalDbUnavailableException,
Ga4ghResourceUnavailableException {
String fetchRes1 = readFile("GA4GH_id10473_variant_2.json");
Mockito.when(
httpDataManager.fetchData(Mockito.any(), Mockito.any(JSONObject.class)))
.thenReturn(fetchRes1);
VcfGa4ghReader reader = new VcfGa4ghReader(httpDataManager, referenceGenomeManager);
List<VariantGA4GH> ghList = reader.getVariantsGA4GH(varSet, start.toString(), end.toString(),
testChrGA4GH.getName());
Assert.assertFalse(ghList.isEmpty());
Assert.assertNotNull(ghList.get(1).getNames());
Assert.assertFalse(ghList.get(1).getCalls().isEmpty());
}
示例3: testGeneIndexForFile
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testGeneIndexForFile() throws IOException {
IndexSearchResult searchResult = featureIndexDao.searchFeatures("", testGeneFile, null);
Assert.assertTrue(searchResult.getEntries().isEmpty());
searchResult = featureIndexDao.searchFeatures(TEST_GENE_PREFIX.toLowerCase(), testGeneFile, 10);
Assert.assertFalse(searchResult.getEntries().isEmpty());
Assert.assertTrue(searchResult.getEntries().size() <= 10);
Assert.assertTrue(searchResult.isExceedsLimit());
// ensfcag00000031547 and ccdc115
searchResult = featureIndexDao.searchFeatures("ensfcag00000031547", testGeneFile, null);
Assert.assertEquals(searchResult.getEntries().size(), 1);
searchResult = featureIndexDao.searchFeatures("ccdc115", testGeneFile, null);
Assert.assertEquals(searchResult.getEntries().size(), 2);
}
示例4: nibFileAndFastaFileIdenticalTest
@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void nibFileAndFastaFileIdenticalTest() throws ReferenceReadingException, IOException {
ReferenceSequenceFile referenceSequenceFile =
ReferenceSequenceFileFactory.getReferenceSequenceFile(resource.getFile());
//Go through all chromosomes if FASTA-file
Track<Sequence> track = new Track<>();
track.setType(TrackType.REF);
track.setScaleFactor(SCALE_FACTOR_4_BASE);
track.setId(reference.getId());
byte[] arrayOfNucleicAcids;
//Nucleicide frome FASTA-file
arrayOfNucleicAcids = referenceSequenceFile.nextSequence().getBases();
Chromosome chromosome = reference.getChromosomes().get(0);
track.setChromosome(chromosome);
track.setStartIndex(START_INDEX);
track.setEndIndex(END_INDEX);
//Nucleicide frome nib-file
track = referenceManager.getNucleotidesResultFromNib(track);
for (Sequence sequence : track.getBlocks()) {
assertTrue(String.valueOf((char) (arrayOfNucleicAcids[sequence.getStartIndex() - 1]))
.equals(sequence.getText()));
}
}
示例5: testCreateGeneIndex
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testCreateGeneIndex() throws IOException, InterruptedException, FeatureIndexException,
NoSuchAlgorithmException, VcfReadingException {
IndexSearchResult searchResult = featureIndexManager.searchFeaturesInProject("", testProject.getId());
Assert.assertTrue(searchResult.getEntries().isEmpty());
searchResult = featureIndexManager.searchFeaturesInProject("ens", testProject.getId());
Assert.assertFalse(searchResult.getEntries().isEmpty());
Assert.assertTrue(searchResult.getEntries().size() <= 10);
Assert.assertTrue(searchResult.isExceedsLimit());
// ensfcag00000031547 and ccdc115
searchResult = featureIndexManager.searchFeaturesInProject("ensfcag00000031547", testProject.getId());
Assert.assertEquals(searchResult.getEntries().size(), 1);
searchResult = featureIndexManager.searchFeaturesInProject("ccdc115", testProject.getId());
Assert.assertEquals(searchResult.getEntries().size(), 2);
}
示例6: generatePlain
/**
* Generates next non formatted number from {@link Sequence}.
*
* <p>
* For this method to be tread-safe and not generate same number for two calls, this method is synchronized
* and requires a new transaction explicitly.
* </p>
*
* @param id Id of the {@link Sequence}
* @return Non Formatted number
* @throws MissingObject If the {@link Sequence} does not exist
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
public synchronized long generatePlain(String id) throws MissingObject {
notNull(id, () -> new BadArgument("id"));
Sequence sequence = store.find(id);
notNull(sequence, () -> new MissingObject(Sequence.class, id));
Long counter = sequence.getCounter();
if (counter == null) {
counter = 1L;
}
sequence.setCounter(counter+1);
store.save(sequence);
return counter;
}
示例7: getOtherGCContentTest
@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void getOtherGCContentTest() throws ReferenceReadingException {
Track<Sequence> track = new Track<>();
Chromosome chromosome = new Chromosome();
chromosome.setId(idChrom);
track.setId(idRef);
track.setChromosome(chromosome);
track.setScaleFactor(SCALE_FACTOR_4_GC);
track.setStartIndex(START_INDEX);
track.setEndIndex(END_INDEX);
track = referenceManager.getNucleotidesResultFromNib(track);
assertNotNull(track);
track.setScaleFactor(SCALE_FACTOR_4_GC_NEW);
track = referenceManager.getNucleotidesResultFromNib(track);
assertNotNull(track);
}
示例8: add
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void add(AuditEvent event) {
if (!AUTHORIZATION_FAILURE.equals(event.getType()) &&
!Constants.ANONYMOUS_USER.equals(event.getPrincipal())) {
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
persistentAuditEvent.setPrincipal(event.getPrincipal());
persistentAuditEvent.setAuditEventType(event.getType());
persistentAuditEvent.setAuditEventDate(event.getTimestamp().toInstant());
persistentAuditEvent.setData(auditEventConverter.convertDataToStrings(event.getData()));
persistenceAuditEventRepository.save(persistentAuditEvent);
}
}
示例9: add
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void add(AuditEvent event) {
if (!AUTHORIZATION_FAILURE.equals(event.getType()) &&
!Constants.ANONYMOUS_USER.equals(event.getPrincipal())) {
PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
persistentAuditEvent.setPrincipal(event.getPrincipal());
persistentAuditEvent.setAuditEventType(event.getType());
persistentAuditEvent.setAuditEventDate(event.getTimestamp().toInstant());
Map<String, String> eventData = auditEventConverter.convertDataToStrings(event.getData());
persistentAuditEvent.setData(truncate(eventData));
persistenceAuditEventRepository.save(persistentAuditEvent);
}
}
示例10: testLoadAllReferenceGenomes
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testLoadAllReferenceGenomes() throws IOException {
Chromosome testChromosome = EntityHelper.createNewChromosome();
testChromosome.setSize(TEST_CHROMOSOME_SIZE);
Reference testReference = EntityHelper.createNewReference(testChromosome,
referenceGenomeManager.createReferenceId());
referenceGenomeManager.register(testReference);
Long referenceId = testReference.getId();
Resource resource = context.getResource(CLASSPATH_TEMPLATES_GENES_SORTED);
FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
request.setReferenceId(referenceId);
request.setPath(resource.getFile().getAbsolutePath());
GeneFile testGeneFile = gffManager.registerGeneFile(request);
referenceGenomeManager.updateReferenceGeneFileId(testReference.getId(), testGeneFile.getId());
Reference g38 = EntityHelper.createG38Reference(referenceGenomeManager.createReferenceId());
referenceGenomeManager.register(g38);
List<Reference> loaded = referenceGenomeManager.loadAllReferenceGenomes();
Assert.assertFalse(loaded.isEmpty());
Assert.assertEquals(1, loaded.stream().filter(r -> r.getGeneFile() != null &&
r.getGeneFile().getId() != null &&
r.getGeneFile().getName() != null).count());
}
示例11: testLoadSmallScaleVcfFileGa4GH
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testLoadSmallScaleVcfFileGa4GH() throws IOException, InterruptedException, NoSuchAlgorithmException,
ExternalDbUnavailableException, VcfReadingException {
String fetchRes1 = readFile("GA4GH_id10473.json");
String fetchRes2 = readFile("GA4GH_id10473_variant.json");
Mockito.when(
httpDataManager.fetchData(Mockito.any(), Mockito.any(JSONObject.class)))
.thenReturn(fetchRes1)
.thenReturn(fetchRes2);
String fetchRes3 = readFile("GA4GH_id10473_param.json");
Mockito.when(
httpDataManager.fetchData(Mockito.any(), Mockito.any(ParameterNameValue[].class)))
.thenReturn(fetchRes3);
VcfFile vcfFileGA4GH = regesterVcfGA4GH();
vcfFileGA4GH.setType(BiologicalDataItemResourceType.GA4GH);
List<VcfSample> vcfSamples = vcfFileGA4GH.getSamples();
Track<Variation> trackResult;
Long sampleId = 0L;
for (VcfSample sample : vcfSamples) {
if (sample.getName().equals(SAMPLE_NAME)) {
sampleId = sample.getId();
}
}
trackResult = testLoadGA4GH(vcfFileGA4GH, TEST_SMALL_SCALE_FACTOR, true, sampleId);
List<Variation> ambiguousVariations = trackResult.getBlocks().stream().filter((b) ->
b.getVariationsCount() != null && b.getVariationsCount() > 1).collect(Collectors.toList());
Assert.assertFalse(ambiguousVariations.isEmpty());
}
示例12: testGetNextFeature
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testGetNextFeature() throws IOException, InterruptedException, NoSuchAlgorithmException,
ExternalDbUnavailableException, VcfReadingException {
String fetchRes1 = readFile("GA4GH_id10473.json");
String fetchRes2 = readFile("GA4GH_id10473_variant.json");
String fetchRes3 = readFile("GA4GH_id10473_variant_2.json");
String fetchRes4 = readFile("GA4GH_id10473_variant_3.json");
Mockito.when(
httpDataManager.fetchData(Mockito.any(), Mockito.any(JSONObject.class)))
.thenReturn(fetchRes1)
.thenReturn(fetchRes2)
.thenReturn(fetchRes3)
.thenReturn(fetchRes4);
String fetchRes5 = readFile("GA4GH_id10473_param.json");
Mockito.when(
httpDataManager.fetchData(Mockito.any(), Mockito.any(ParameterNameValue[].class)))
.thenReturn(fetchRes5);
getNextFeature(referenceId, BiologicalDataItemResourceType.FILE);
logger.info("success, next feature variation for file");
//test getNextFeature for GA4GH
getNextFeature(referenceIdGA4GH, BiologicalDataItemResourceType.GA4GH);
logger.info("success, next feature variation for GA4GH");
}
示例13: saveWigTest
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void saveWigTest() throws IOException, NoSuchAlgorithmException {
final String path = resource.getFile().getAbsolutePath() + TEST_WIG;
FileRegistrationRequest request = new FileRegistrationRequest();
request.setPath(path);
request.setReferenceId(testReference.getId());
request.setName(TEST_WIG);
WigFile wigFile = wigManager.registerWigFile(request);
Assert.assertNotNull(wigFile);
WigFile loadWigFile = wigFileManager.loadWigFile(wigFile.getId());
Assert.assertNotNull(loadWigFile);
Assert.assertTrue(wigFile.getId().equals(loadWigFile.getId()));
Assert.assertTrue(wigFile.getName().equals(loadWigFile.getName()));
Assert.assertTrue(wigFile.getCreatedBy().equals(loadWigFile.getCreatedBy()));
Assert.assertTrue(wigFile.getCreatedDate().equals(loadWigFile.getCreatedDate()));
Assert.assertTrue(wigFile.getReferenceId().equals(loadWigFile.getReferenceId()));
Assert.assertTrue(wigFile.getPath().equals(loadWigFile.getPath()));
Track<Wig> wigTrack = new Track<>();
wigTrack.setChromosome(new Chromosome(testChromosomeId));
wigTrack.setStartIndex(TEST_START_INDEX);
wigTrack.setEndIndex(TEST_END_INDEX);
wigTrack.setScaleFactor(TEST_SCALE_FACTOR);
wigTrack.setId(loadWigFile.getId());
double time1 = Utils.getSystemTimeMilliseconds();
wigManager.getWigTrack(wigTrack);
double time2 = Utils.getSystemTimeMilliseconds();
Assert.assertFalse(wigTrack.getBlocks().isEmpty());
logger.debug("First Reading chromosome {} took {}", chromosomeName, time2 - time1);
wigTrack.setStartIndex(1);
wigTrack.setScaleFactor(TEST_SMALL_SCALE_FACTOR);
time1 = Utils.getSystemTimeMilliseconds();
wigManager.getWigTrack(wigTrack);
time2 = Utils.getSystemTimeMilliseconds();
logger.debug("Second Reading chromosome {} took {}", chromosomeName, time2 - time1);
wigManager.unregisterWigFile(loadWigFile.getId());
loadWigFile = wigFileManager.loadWigFile(wigFile.getId());
Assert.assertNull(loadWigFile);
}
示例14: testSaveLoadUrl
@Test
@Ignore
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testSaveLoadUrl() throws Exception {
final String path = "/Felis_catus.vcf";
String vcfUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + path;
String indexUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/Felis_catus.idx";
Server server = UrlTestingUtils.getFileServer(context);
try {
server.start();
FeatureIndexedFileRegistrationRequest request = new FeatureIndexedFileRegistrationRequest();
request.setReferenceId(referenceId);
request.setPath(vcfUrl);
request.setIndexPath(indexUrl);
request.setIndexType(BiologicalDataItemResourceType.URL);
request.setType(BiologicalDataItemResourceType.URL);
VcfFile vcfFile = vcfManager.registerVcfFile(request);
Assert.assertNotNull(vcfFile);
Assert.assertNotNull(vcfFile.getId());
Assert.assertEquals(BiologicalDataItemResourceType.URL, vcfFile.getType());
Assert.assertEquals(vcfUrl, vcfFile.getPath());
Assert.assertEquals(BiologicalDataItemResourceType.URL, vcfFile.getIndex().getType());
testLoad(vcfFile, 1D, true);
// index as file
Resource resource = context.getResource("classpath:templates/Felis_catus.idx");
request.setIndexPath(resource.getFile().getAbsolutePath());
request.setIndexType(null);
vcfFile = vcfManager.registerVcfFile(request);
Assert.assertEquals(BiologicalDataItemResourceType.FILE, vcfFile.getIndex().getType());
testLoad(vcfFile, 1D, true);
// Compressed file
vcfUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/Felis_catus.vcf.gz";
indexUrl = UrlTestingUtils.TEST_FILE_SERVER_URL + "/Felis_catus.tbi";
request = new FeatureIndexedFileRegistrationRequest();
request.setReferenceId(referenceId);
request.setPath(vcfUrl);
request.setIndexPath(indexUrl);
request.setIndexType(BiologicalDataItemResourceType.URL);
request.setType(BiologicalDataItemResourceType.URL);
vcfFile = vcfManager.registerVcfFile(request);
testLoad(vcfFile, 1D, true);
} finally {
server.stop();
}
}
示例15: testBookmarkCreateLoad
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testBookmarkCreateLoad()
throws IOException, InterruptedException, NoSuchAlgorithmException, VcfReadingException, FeatureIndexException {
VcfFile file = addVcfFile(TEST_VCF_FILE_NAME1, TEST_VCF_FILE_PATH);
BiologicalDataItem item = new BiologicalDataItem();
item.setId(file.getBioDataItemId());
Project project = new Project();
project.setName("testProject");
ArrayList<ProjectItem> items = new ArrayList<>();
items.add(new ProjectItem(new BiologicalDataItem(testReference.getBioDataItemId())));
items.add(new ProjectItem(item));
project.setItems(items);
projectManager.saveProject(project);
Resource resource = context.getResource("classpath:templates/genes_sorted.gtf");
FeatureIndexedFileRegistrationRequest geneRequest = new FeatureIndexedFileRegistrationRequest();
geneRequest.setReferenceId(referenceId);
geneRequest.setName("genes");
geneRequest.setPath(resource.getFile().getAbsolutePath());
GeneFile geneFile = gffManager.registerGeneFile(geneRequest);
referenceGenomeManager.updateReferenceGeneFileId(referenceId, geneFile.getId());
Bookmark bookmark = new Bookmark();
bookmark.setOpenedItems(Collections.singletonList(item));
bookmark.setStartIndex(1);
bookmark.setEndIndex(BOOKMARK_END_INDEX);
bookmark.setChromosome(testChromosome);
bookmark.setName("testBookmark");
bookmarkManager.saveBookmark(bookmark);
List<Bookmark> loadedBookmarks = bookmarkManager.loadBookmarksByProject();
Assert.assertNotNull(loadedBookmarks);
Assert.assertFalse(loadedBookmarks.isEmpty());
Assert.assertNull(loadedBookmarks.get(0).getOpenedItems());
Bookmark loadedBookmark = loadedBookmarks.get(0);
loadedBookmark = bookmarkManager.loadBookmark(loadedBookmark.getId());
Assert.assertFalse(loadedBookmark.getOpenedItems().isEmpty());
Assert.assertEquals(BiologicalDataItem.getBioDataItemId(loadedBookmark.getOpenedItems()
.get(0)), item.getId());
BiologicalDataItem item2 = new BiologicalDataItem();
item2.setId(testReference.getBioDataItemId());
loadedBookmark.getOpenedItems().add(item2);
loadedBookmark.setStartIndex(BOOKMARK_END_INDEX);
loadedBookmark.setEndIndex(BOOKMARK_END_INDEX2);
bookmarkManager.saveBookmark(loadedBookmark);
loadedBookmark = bookmarkManager.loadBookmark(loadedBookmark.getId());
Assert.assertEquals(loadedBookmark.getOpenedItems().size(), 2);
bookmarkManager.deleteBookmark(loadedBookmark.getId());
loadedBookmarks = bookmarkManager.loadBookmarksByProject();
Assert.assertTrue(loadedBookmarks.isEmpty());
}