@Test public void copyBetweenAssets() throws InterruptedException, ExecutionException, RepositoryNameAlreadyUsedException, RepositoryLocaleCreationException, AssetWithIdNotFoundException, RepositoryWithIdNotFoundException { Locale frFR = localeService.findByBcp47Tag("fr-FR"); logger.debug("Create the source repository"); Repository sourceRepository = repositoryService.createRepository(testIdWatcher.getEntityName("sourceRepository")); repositoryService.addRepositoryLocale(sourceRepository, frFR.getBcp47Tag()); Asset sourceAsset = assetService.createAssetWithContent(sourceRepository.getId(), "fake_for_test_1", "fake for test"); Long sourceAssetId = sourceAsset.getId(); TMTextUnit addTMTextUnit = tmService.addTMTextUnit(sourceRepository.getTm().getId(), sourceAssetId, "TEST3", "Content3", "Comment3"); tmService.addCurrentTMTextUnitVariant(addTMTextUnit.getId(), frFR.getId(), "Content3 fr-FR from source"); Asset sourceAsset2 = assetService.createAssetWithContent(sourceRepository.getId(), "fake_for_test2", "fake for test"); Long sourceAssetId2 = sourceAsset2.getId(); TMTextUnit addTMTextUnit2 = tmService.addTMTextUnit(sourceRepository.getTm().getId(), sourceAssetId2, "TEST3", "Content3", "Comment3"); tmService.addCurrentTMTextUnitVariant(addTMTextUnit2.getId(), frFR.getId(), "Content3 fr-FR from source2"); logger.debug("Create the target repository"); Repository targetRepository = repositoryService.createRepository(testIdWatcher.getEntityName("targetRepository")); Asset targetAsset = assetService.createAssetWithContent(targetRepository.getId(), "fake_for_test", "fake for test"); Long targetAssetId = targetAsset.getId(); tmService.addTMTextUnit(targetRepository.getTm().getId(), targetAssetId, "TEST3", "Content3", "Comment3"); Asset targetAsset2 = assetService.createAssetWithContent(targetRepository.getId(), "fake_for_test2", "fake for test"); Long targetAssetId2 = targetAsset2.getId(); tmService.addTMTextUnit(targetRepository.getTm().getId(), targetAssetId2, "TEST3", "Content3", "Comment3"); CopyTmConfig copyTmConfig = new CopyTmConfig(); copyTmConfig.setSourceAssetId(sourceAssetId); copyTmConfig.setTargetAssetId(targetAssetId); copyTmConfig.setMode(CopyTmConfig.Mode.MD5); leveragingService.copyTm(copyTmConfig).get(); List<TMTextUnitVariant> targetTranslations = tmTextUnitVariantRepository.findByTmTextUnitTmRepositoriesAndLocale_Bcp47TagNotOrderByContent(targetRepository, "en"); Assert.assertEquals("Content3 fr-FR from source", targetTranslations.get(0).getContent()); Assert.assertEquals(targetAsset.getId(), targetTranslations.get(0).getTmTextUnit().getAsset().getId()); Assert.assertEquals(1, targetTranslations.size()); CopyTmConfig copyTmConfig2 = new CopyTmConfig(); copyTmConfig2.setSourceAssetId(sourceAssetId2); copyTmConfig2.setTargetAssetId(targetAssetId2); copyTmConfig2.setMode(CopyTmConfig.Mode.MD5); leveragingService.copyTm(copyTmConfig2).get(); List<TMTextUnitVariant> targetTranslations2 = tmTextUnitVariantRepository.findByTmTextUnitTmRepositoriesAndLocale_Bcp47TagNotOrderByContent(targetRepository, "en"); Assert.assertEquals("Content3 fr-FR from source", targetTranslations2.get(0).getContent()); Assert.assertEquals(targetAsset.getId(), targetTranslations2.get(0).getTmTextUnit().getAsset().getId()); Assert.assertEquals("Content3 fr-FR from source2", targetTranslations2.get(1).getContent()); Assert.assertEquals(targetAsset2.getId(), targetTranslations2.get(1).getTmTextUnit().getAsset().getId()); Assert.assertEquals(2, targetTranslations2.size()); }
@Pollable(async = true, message = "Start copying translations between repository") public PollableFuture copyTm(CopyTmConfig copyTmConfig) throws AssetWithIdNotFoundException, RepositoryWithIdNotFoundException { if (CopyTmConfig.Mode.TUIDS.equals(copyTmConfig.getMode())) { copyTranslationBetweenTextUnits(copyTmConfig.getSourceToTargetTmTextUnitIds()); } else { copyTmBetweenRepositories(copyTmConfig); } return new PollableFutureTaskResult(); }
LeveragingService { @Pollable(async = true, message = "Start copying translations between repository") public PollableFuture copyTm(CopyTmConfig copyTmConfig) throws AssetWithIdNotFoundException, RepositoryWithIdNotFoundException { if (CopyTmConfig.Mode.TUIDS.equals(copyTmConfig.getMode())) { copyTranslationBetweenTextUnits(copyTmConfig.getSourceToTargetTmTextUnitIds()); } else { copyTmBetweenRepositories(copyTmConfig); } return new PollableFutureTaskResult(); } }
LeveragingService { @Pollable(async = true, message = "Start copying translations between repository") public PollableFuture copyTm(CopyTmConfig copyTmConfig) throws AssetWithIdNotFoundException, RepositoryWithIdNotFoundException { if (CopyTmConfig.Mode.TUIDS.equals(copyTmConfig.getMode())) { copyTranslationBetweenTextUnits(copyTmConfig.getSourceToTargetTmTextUnitIds()); } else { copyTmBetweenRepositories(copyTmConfig); } return new PollableFutureTaskResult(); }  }
LeveragingService { @Pollable(async = true, message = "Start copying translations between repository") public PollableFuture copyTm(CopyTmConfig copyTmConfig) throws AssetWithIdNotFoundException, RepositoryWithIdNotFoundException { if (CopyTmConfig.Mode.TUIDS.equals(copyTmConfig.getMode())) { copyTranslationBetweenTextUnits(copyTmConfig.getSourceToTargetTmTextUnitIds()); } else { copyTmBetweenRepositories(copyTmConfig); } return new PollableFutureTaskResult(); }  void performSourceLeveraging(List<TMTextUnit> tmTextUnits); @Pollable(async = true, message = "Start copying translations between repository") PollableFuture copyTm(CopyTmConfig copyTmConfig); }
LeveragingService { @Pollable(async = true, message = "Start copying translations between repository") public PollableFuture copyTm(CopyTmConfig copyTmConfig) throws AssetWithIdNotFoundException, RepositoryWithIdNotFoundException { if (CopyTmConfig.Mode.TUIDS.equals(copyTmConfig.getMode())) { copyTranslationBetweenTextUnits(copyTmConfig.getSourceToTargetTmTextUnitIds()); } else { copyTmBetweenRepositories(copyTmConfig); } return new PollableFutureTaskResult(); }  void performSourceLeveraging(List<TMTextUnit> tmTextUnits); @Pollable(async = true, message = "Start copying translations between repository") PollableFuture copyTm(CopyTmConfig copyTmConfig);  }