{"action":"created","comment":{"url":"https://api.github.com/repos/Talend/data-prep/pulls/comments/229765372","pull_request_review_id":170342784,"id":229765372,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyOTc2NTM3Mg==","diff_hunk":"@@ -0,0 +1,99 @@\n+package org.talend.dataprep.preparation.service;\n+\n+import java.util.concurrent.TimeUnit;\n+\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.stereotype.Component;\n+import org.talend.dataprep.dataset.adapter.DataCatalogClient;\n+import org.talend.dataprep.dataset.adapter.Dataset;\n+import org.talend.dataprep.exception.TDPException;\n+import org.talend.dataprep.exception.error.CommonErrorCodes;\n+import org.talend.dataprep.preparation.store.PersistentPreparation;\n+import org.talend.dataprep.preparation.store.PreparationRepository;\n+import org.talend.dataprep.security.Security;\n+import org.talend.dataprep.security.SecurityProxy;\n+\n+import com.github.benmanes.caffeine.cache.Cache;\n+import com.github.benmanes.caffeine.cache.Caffeine;\n+\n+/**\n+ * Inject dataset name into preparations to gain time in preparation listing.\n+ * This also migrate preparation in database to avoid listing again.\n+ */\n+@Component\n+public class DataSetNameInjection {\n+\n+    private static final Logger LOGGER = LoggerFactory.getLogger(DataSetNameInjection.class);\n+\n+    private final Cache<String, Cache<String, String>> cache = Caffeine\n+            .newBuilder() //\n+            .maximumSize(10) //\n+            .expireAfterAccess(1, TimeUnit.MINUTES) //\n+            .build();\n+\n+    @Autowired\n+    private Security security;\n+\n+    @Autowired\n+    private SecurityProxy securityProxy;\n+\n+    @Autowired\n+    private DataCatalogClient dataCatalogClient;\n+\n+    @Autowired\n+    protected PreparationRepository preparationRepository;\n+\n+    public PersistentPreparation injectDatasetNameBasedOnId(PersistentPreparation preparation) {\n+        String dataSetName = preparation.getDataSetName();\n+        if (dataSetName == null) {\n+            try {\n+                final String tenantId = security.getTenantId();\n+                final Cache<String, String> tenantCache = cache.get(tenantId, this::createTenantCache);\n+                assert tenantCache != null; // initTenant() cannot return a null value\n+                String dataSetId = preparation.getDataSetId();\n+                if (dataSetId != null) {","path":"dataprep-preparation/src/main/java/org/talend/dataprep/preparation/service/DataSetNameInjection.java","position":56,"original_position":56,"commit_id":"d4f3724e47de53841b760034d91a59521df905a5","original_commit_id":"d4f3724e47de53841b760034d91a59521df905a5","user":{"login":"hmdebenque","id":19857487,"node_id":"MDQ6VXNlcjE5ODU3NDg3","avatar_url":"https://avatars2.githubusercontent.com/u/19857487?v=4","gravatar_id":"","url":"https://api.github.com/users/hmdebenque","html_url":"https://github.com/hmdebenque","followers_url":"https://api.github.com/users/hmdebenque/followers","following_url":"https://api.github.com/users/hmdebenque/following{/other_user}","gists_url":"https://api.github.com/users/hmdebenque/gists{/gist_id}","starred_url":"https://api.github.com/users/hmdebenque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmdebenque/subscriptions","organizations_url":"https://api.github.com/users/hmdebenque/orgs","repos_url":"https://api.github.com/users/hmdebenque/repos","events_url":"https://api.github.com/users/hmdebenque/events{/privacy}","received_events_url":"https://api.github.com/users/hmdebenque/received_events","type":"User","site_admin":false},"body":"It shouldn't, really. But many tests will fail if not.\r\nI will see if it is possible to correct them instead of having this case.","created_at":"2018-10-31T16:15:04Z","updated_at":"2018-10-31T16:15:04Z","html_url":"https://github.com/Talend/data-prep/pull/1682#discussion_r229765372","pull_request_url":"https://api.github.com/repos/Talend/data-prep/pulls/1682","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Talend/data-prep/pulls/comments/229765372"},"html":{"href":"https://github.com/Talend/data-prep/pull/1682#discussion_r229765372"},"pull_request":{"href":"https://api.github.com/repos/Talend/data-prep/pulls/1682"}},"in_reply_to_id":229730387},"pull_request":{"url":"https://api.github.com/repos/Talend/data-prep/pulls/1682","id":224200241,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI0MjAwMjQx","html_url":"https://github.com/Talend/data-prep/pull/1682","diff_url":"https://github.com/Talend/data-prep/pull/1682.diff","patch_url":"https://github.com/Talend/data-prep/pull/1682.patch","issue_url":"https://api.github.com/repos/Talend/data-prep/issues/1682","number":1682,"state":"open","locked":false,"title":"fix(TDP-6195): fix configuration for on-the-fly update of dataset names in preps","user":{"login":"elogeart","id":30080022,"node_id":"MDQ6VXNlcjMwMDgwMDIy","avatar_url":"https://avatars3.githubusercontent.com/u/30080022?v=4","gravatar_id":"","url":"https://api.github.com/users/elogeart","html_url":"https://github.com/elogeart","followers_url":"https://api.github.com/users/elogeart/followers","following_url":"https://api.github.com/users/elogeart/following{/other_user}","gists_url":"https://api.github.com/users/elogeart/gists{/gist_id}","starred_url":"https://api.github.com/users/elogeart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elogeart/subscriptions","organizations_url":"https://api.github.com/users/elogeart/orgs","repos_url":"https://api.github.com/users/elogeart/repos","events_url":"https://api.github.com/users/elogeart/events{/privacy}","received_events_url":"https://api.github.com/users/elogeart/received_events","type":"User","site_admin":false},"body":"**Link to the JIRA issue**\r\nhttps://jira.talendforge.org/browse/TDP-6195\r\nSee also https://github.com/Talend/data-prep-ee/pull/1197\r\n\r\n**What problem this PR is trying to solve**\r\nFix the on-the-fly update of dataset names in preparations created before the optimization of the preparations listing on the \"exploded\" development version. This problem does not occur on the bundled on-prem version.\r\nWithout this configuration, the PreparationRepository bean in the API service is set to an InMemoryPreparationRepository, so the preparation is not found when the on-the-fly process tries to update the preparation in the database. This bean is used in the DataSetNameInjection which is meant to do the on-the-fly update.\r\n\r\n**Please check if the PR fulfills these requirements**\r\n- [ ] The commit(s) message(s) follows our [guidelines](https://github.com/talend/tools/blob/master/tools-root-github/CONTRIBUTING.md#commit-message-format)\r\n- [ ] Tests for the changes have been added (for bug fixes / features)\r\n- [ ] Docs have been added / updated (for bug fixes / features)\r\n- [ ] The code coverage on new code is > 75 % for backend and > 95% for frontend\r\n- [ ] The new code does not introduce new technical issues (sonar / eslint)\r\n- [ ] Functional tests have been performed\r\n- [ ] Docker configuration files for config-std or config-cloud profiles are impacted\r\n\r\n**Please check the browsers you've tested on**\r\n- [ ] Chrome, Firefox, Safari, Edge, IE11\r\n- [ ] No, that's bad, this PR should not be merged !\r\n- [ ] No, and no need to (backend changes only)\r\n","created_at":"2018-10-19T07:56:27Z","updated_at":"2018-10-31T16:15:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ff3724665b52b6b23096ea74d4156c8fc3fe4cb8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":463131803,"node_id":"MDU6TGFiZWw0NjMxMzE4MDM=","url":"https://api.github.com/repos/Talend/data-prep/labels/backend","name":"backend","color":"d4c5f9","default":false},{"id":147860692,"node_id":"MDU6TGFiZWwxNDc4NjA2OTI=","url":"https://api.github.com/repos/Talend/data-prep/labels/bug","name":"bug","color":"fc2929","default":true},{"id":447624534,"node_id":"MDU6TGFiZWw0NDc2MjQ1MzQ=","url":"https://api.github.com/repos/Talend/data-prep/labels/need%20review","name":"need review","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Talend/data-prep/pulls/1682/commits","review_comments_url":"https://api.github.com/repos/Talend/data-prep/pulls/1682/comments","review_comment_url":"https://api.github.com/repos/Talend/data-prep/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Talend/data-prep/issues/1682/comments","statuses_url":"https://api.github.com/repos/Talend/data-prep/statuses/d4f3724e47de53841b760034d91a59521df905a5","head":{"label":"Talend:elogeart/fix/fix_on_the_fly_update_for_dataset_names","ref":"elogeart/fix/fix_on_the_fly_update_for_dataset_names","sha":"d4f3724e47de53841b760034d91a59521df905a5","user":{"login":"Talend","id":459687,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1OTY4Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/459687?v=4","gravatar_id":"","url":"https://api.github.com/users/Talend","html_url":"https://github.com/Talend","followers_url":"https://api.github.com/users/Talend/followers","following_url":"https://api.github.com/users/Talend/following{/other_user}","gists_url":"https://api.github.com/users/Talend/gists{/gist_id}","starred_url":"https://api.github.com/users/Talend/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Talend/subscriptions","organizations_url":"https://api.github.com/users/Talend/orgs","repos_url":"https://api.github.com/users/Talend/repos","events_url":"https://api.github.com/users/Talend/events{/privacy}","received_events_url":"https://api.github.com/users/Talend/received_events","type":"Organization","site_admin":false},"repo":{"id":26644682,"node_id":"MDEwOlJlcG9zaXRvcnkyNjY0NDY4Mg==","name":"data-prep","full_name":"Talend/data-prep","private":false,"owner":{"login":"Talend","id":459687,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1OTY4Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/459687?v=4","gravatar_id":"","url":"https://api.github.com/users/Talend","html_url":"https://github.com/Talend","followers_url":"https://api.github.com/users/Talend/followers","following_url":"https://api.github.com/users/Talend/following{/other_user}","gists_url":"https://api.github.com/users/Talend/gists{/gist_id}","starred_url":"https://api.github.com/users/Talend/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Talend/subscriptions","organizations_url":"https://api.github.com/users/Talend/orgs","repos_url":"https://api.github.com/users/Talend/repos","events_url":"https://api.github.com/users/Talend/events{/privacy}","received_events_url":"https://api.github.com/users/Talend/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Talend/data-prep","description":"OS code of Data-prep project","fork":false,"url":"https://api.github.com/repos/Talend/data-prep","forks_url":"https://api.github.com/repos/Talend/data-prep/forks","keys_url":"https://api.github.com/repos/Talend/data-prep/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Talend/data-prep/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Talend/data-prep/teams","hooks_url":"https://api.github.com/repos/Talend/data-prep/hooks","issue_events_url":"https://api.github.com/repos/Talend/data-prep/issues/events{/number}","events_url":"https://api.github.com/repos/Talend/data-prep/events","assignees_url":"https://api.github.com/repos/Talend/data-prep/assignees{/user}","branches_url":"https://api.github.com/repos/Talend/data-prep/branches{/branch}","tags_url":"https://api.github.com/repos/Talend/data-prep/tags","blobs_url":"https://api.github.com/repos/Talend/data-prep/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Talend/data-prep/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Talend/data-prep/git/refs{/sha}","trees_url":"https://api.github.com/repos/Talend/data-prep/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Talend/data-prep/statuses/{sha}","languages_url":"https://api.github.com/repos/Talend/data-prep/languages","stargazers_url":"https://api.github.com/repos/Talend/data-prep/stargazers","contributors_url":"https://api.github.com/repos/Talend/data-prep/contributors","subscribers_url":"https://api.github.com/repos/Talend/data-prep/subscribers","subscription_url":"https://api.github.com/repos/Talend/data-prep/subscription","commits_url":"https://api.github.com/repos/Talend/data-prep/commits{/sha}","git_commits_url":"https://api.github.com/repos/Talend/data-prep/git/commits{/sha}","comments_url":"https://api.github.com/repos/Talend/data-prep/comments{/number}","issue_comment_url":"https://api.github.com/repos/Talend/data-prep/issues/comments{/number}","contents_url":"https://api.github.com/repos/Talend/data-prep/contents/{+path}","compare_url":"https://api.github.com/repos/Talend/data-prep/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Talend/data-prep/merges","archive_url":"https://api.github.com/repos/Talend/data-prep/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Talend/data-prep/downloads","issues_url":"https://api.github.com/repos/Talend/data-prep/issues{/number}","pulls_url":"https://api.github.com/repos/Talend/data-prep/pulls{/number}","milestones_url":"https://api.github.com/repos/Talend/data-prep/milestones{/number}","notifications_url":"https://api.github.com/repos/Talend/data-prep/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Talend/data-prep/labels{/name}","releases_url":"https://api.github.com/repos/Talend/data-prep/releases{/id}","deployments_url":"https://api.github.com/repos/Talend/data-prep/deployments","created_at":"2014-11-14T15:32:38Z","updated_at":"2018-10-31T15:15:38Z","pushed_at":"2018-10-31T15:34:51Z","git_url":"git://github.com/Talend/data-prep.git","ssh_url":"git@github.com:Talend/data-prep.git","clone_url":"https://github.com/Talend/data-prep.git","svn_url":"https://github.com/Talend/data-prep","homepage":"","size":69897,"stargazers_count":47,"watchers_count":47,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":23,"open_issues":18,"watchers":47,"default_branch":"master"}},"base":{"label":"Talend:master","ref":"master","sha":"43ebdaf79e56965b1d0ed64afcd67cc22fbf079b","user":{"login":"Talend","id":459687,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1OTY4Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/459687?v=4","gravatar_id":"","url":"https://api.github.com/users/Talend","html_url":"https://github.com/Talend","followers_url":"https://api.github.com/users/Talend/followers","following_url":"https://api.github.com/users/Talend/following{/other_user}","gists_url":"https://api.github.com/users/Talend/gists{/gist_id}","starred_url":"https://api.github.com/users/Talend/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Talend/subscriptions","organizations_url":"https://api.github.com/users/Talend/orgs","repos_url":"https://api.github.com/users/Talend/repos","events_url":"https://api.github.com/users/Talend/events{/privacy}","received_events_url":"https://api.github.com/users/Talend/received_events","type":"Organization","site_admin":false},"repo":{"id":26644682,"node_id":"MDEwOlJlcG9zaXRvcnkyNjY0NDY4Mg==","name":"data-prep","full_name":"Talend/data-prep","private":false,"owner":{"login":"Talend","id":459687,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1OTY4Nw==","avatar_url":"https://avatars2.githubusercontent.com/u/459687?v=4","gravatar_id":"","url":"https://api.github.com/users/Talend","html_url":"https://github.com/Talend","followers_url":"https://api.github.com/users/Talend/followers","following_url":"https://api.github.com/users/Talend/following{/other_user}","gists_url":"https://api.github.com/users/Talend/gists{/gist_id}","starred_url":"https://api.github.com/users/Talend/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Talend/subscriptions","organizations_url":"https://api.github.com/users/Talend/orgs","repos_url":"https://api.github.com/users/Talend/repos","events_url":"https://api.github.com/users/Talend/events{/privacy}","received_events_url":"https://api.github.com/users/Talend/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Talend/data-prep","description":"OS code of Data-prep project","fork":false,"url":"https://api.github.com/repos/Talend/data-prep","forks_url":"https://api.github.com/repos/Talend/data-prep/forks","keys_url":"https://api.github.com/repos/Talend/data-prep/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Talend/data-prep/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Talend/data-prep/teams","hooks_url":"https://api.github.com/repos/Talend/data-prep/hooks","issue_events_url":"https://api.github.com/repos/Talend/data-prep/issues/events{/number}","events_url":"https://api.github.com/repos/Talend/data-prep/events","assignees_url":"https://api.github.com/repos/Talend/data-prep/assignees{/user}","branches_url":"https://api.github.com/repos/Talend/data-prep/branches{/branch}","tags_url":"https://api.github.com/repos/Talend/data-prep/tags","blobs_url":"https://api.github.com/repos/Talend/data-prep/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Talend/data-prep/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Talend/data-prep/git/refs{/sha}","trees_url":"https://api.github.com/repos/Talend/data-prep/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Talend/data-prep/statuses/{sha}","languages_url":"https://api.github.com/repos/Talend/data-prep/languages","stargazers_url":"https://api.github.com/repos/Talend/data-prep/stargazers","contributors_url":"https://api.github.com/repos/Talend/data-prep/contributors","subscribers_url":"https://api.github.com/repos/Talend/data-prep/subscribers","subscription_url":"https://api.github.com/repos/Talend/data-prep/subscription","commits_url":"https://api.github.com/repos/Talend/data-prep/commits{/sha}","git_commits_url":"https://api.github.com/repos/Talend/data-prep/git/commits{/sha}","comments_url":"https://api.github.com/repos/Talend/data-prep/comments{/number}","issue_comment_url":"https://api.github.com/repos/Talend/data-prep/issues/comments{/number}","contents_url":"https://api.github.com/repos/Talend/data-prep/contents/{+path}","compare_url":"https://api.github.com/repos/Talend/data-prep/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Talend/data-prep/merges","archive_url":"https://api.github.com/repos/Talend/data-prep/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Talend/data-prep/downloads","issues_url":"https://api.github.com/repos/Talend/data-prep/issues{/number}","pulls_url":"https://api.github.com/repos/Talend/data-prep/pulls{/number}","milestones_url":"https://api.github.com/repos/Talend/data-prep/milestones{/number}","notifications_url":"https://api.github.com/repos/Talend/data-prep/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Talend/data-prep/labels{/name}","releases_url":"https://api.github.com/repos/Talend/data-prep/releases{/id}","deployments_url":"https://api.github.com/repos/Talend/data-prep/deployments","created_at":"2014-11-14T15:32:38Z","updated_at":"2018-10-31T15:15:38Z","pushed_at":"2018-10-31T15:34:51Z","git_url":"git://github.com/Talend/data-prep.git","ssh_url":"git@github.com:Talend/data-prep.git","clone_url":"https://github.com/Talend/data-prep.git","svn_url":"https://github.com/Talend/data-prep","homepage":"","size":69897,"stargazers_count":47,"watchers_count":47,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"archived":false,"open_issues_count":18,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":23,"open_issues":18,"watchers":47,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Talend/data-prep/pulls/1682"},"html":{"href":"https://github.com/Talend/data-prep/pull/1682"},"issue":{"href":"https://api.github.com/repos/Talend/data-prep/issues/1682"},"comments":{"href":"https://api.github.com/repos/Talend/data-prep/issues/1682/comments"},"review_comments":{"href":"https://api.github.com/repos/Talend/data-prep/pulls/1682/comments"},"review_comment":{"href":"https://api.github.com/repos/Talend/data-prep/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Talend/data-prep/pulls/1682/commits"},"statuses":{"href":"https://api.github.com/repos/Talend/data-prep/statuses/d4f3724e47de53841b760034d91a59521df905a5"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"hmdebenque"}}