{"action":"created","comment":{"url":"https://api.github.com/repos/motech/modules/pulls/comments/65074050","id":65074050,"diff_hunk":"@@ -0,0 +1,53 @@\n+package org.motechproject.commcare.events.imports;\n+\n+import org.joda.time.DateTime;\n+import org.motechproject.commcare.events.constants.EventSubjects;\n+import org.motechproject.commcare.pull.CommcareFormImporterImpl;\n+import org.motechproject.commcare.service.CommcareFormService;\n+import org.motechproject.commons.api.Range;\n+import org.motechproject.event.MotechEvent;\n+import org.motechproject.event.listener.EventRelay;\n+import org.motechproject.event.listener.annotations.MotechListener;\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+\n+import static org.motechproject.commcare.events.constants.EventDataKeys.END_DATE;\n+import static org.motechproject.commcare.events.constants.EventDataKeys.START_DATE;\n+\n+/**\n+ * Class responsible for handling \"Import Forms\" action in tasks.\n+ */\n+@Component\n+public class ImportFormActionEventHandler {\n+\n+    @Autowired\n+    private EventRelay eventRelay;\n+\n+    @Autowired\n+    private CommcareFormService formService;\n+\n+    private static final Logger LOGGER = LoggerFactory.getLogger(ImportFormActionEventHandler.class);\n+\n+    /**\n+     * Handles the {@code EventSubjects.IMPORT_FORMS} events. This will import commcare forms for specific configuration\n+     *\n+     * @param event  the event to be handled\n+     */\n+    @MotechListener(subjects = EventSubjects.IMPORT_FORMS + \".*\")\n+    public void handleEvent(MotechEvent event) {\n+\n+        String configName = EventSubjects.getConfigName(event.getSubject());\n+        DateTime startDate = (DateTime) event.getParameters().get(START_DATE);\n+        DateTime endDate = (DateTime) event.getParameters().get(END_DATE);\n+        Range<DateTime> dateRange = new Range<>(startDate, endDate);\n+\n+        CommcareFormImporterImpl importer = new CommcareFormImporterImpl(eventRelay, formService);","path":"commcare/src/main/java/org/motechproject/commcare/events/imports/ImportFormActionEventHandler.java","position":46,"original_position":46,"commit_id":"4f96d001b77cad1af95f0ad38ed2d4d1563a4ba0","original_commit_id":"4f96d001b77cad1af95f0ad38ed2d4d1563a4ba0","user":{"login":"sebbrudzinski","id":8852946,"avatar_url":"https://avatars.githubusercontent.com/u/8852946?v=3","gravatar_id":"","url":"https://api.github.com/users/sebbrudzinski","html_url":"https://github.com/sebbrudzinski","followers_url":"https://api.github.com/users/sebbrudzinski/followers","following_url":"https://api.github.com/users/sebbrudzinski/following{/other_user}","gists_url":"https://api.github.com/users/sebbrudzinski/gists{/gist_id}","starred_url":"https://api.github.com/users/sebbrudzinski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebbrudzinski/subscriptions","organizations_url":"https://api.github.com/users/sebbrudzinski/orgs","repos_url":"https://api.github.com/users/sebbrudzinski/repos","events_url":"https://api.github.com/users/sebbrudzinski/events{/privacy}","received_events_url":"https://api.github.com/users/sebbrudzinski/received_events","type":"User","site_admin":false},"body":"We should make this a class field, so only one importer is used for all task-triggered imports","created_at":"2016-05-30T13:46:36Z","updated_at":"2016-05-30T13:46:36Z","html_url":"https://github.com/motech/modules/pull/303#discussion_r65074050","pull_request_url":"https://api.github.com/repos/motech/modules/pulls/303","_links":{"self":{"href":"https://api.github.com/repos/motech/modules/pulls/comments/65074050"},"html":{"href":"https://github.com/motech/modules/pull/303#discussion_r65074050"},"pull_request":{"href":"https://api.github.com/repos/motech/modules/pulls/303"}}},"pull_request":{"url":"https://api.github.com/repos/motech/modules/pulls/303","id":71896228,"html_url":"https://github.com/motech/modules/pull/303","diff_url":"https://github.com/motech/modules/pull/303.diff","patch_url":"https://github.com/motech/modules/pull/303.patch","issue_url":"https://api.github.com/repos/motech/modules/issues/303","number":303,"state":"open","locked":false,"title":"MOTECH-2559 Commcare tasks, import forms action","user":{"login":"lkukielka","id":17404322,"avatar_url":"https://avatars.githubusercontent.com/u/17404322?v=3","gravatar_id":"","url":"https://api.github.com/users/lkukielka","html_url":"https://github.com/lkukielka","followers_url":"https://api.github.com/users/lkukielka/followers","following_url":"https://api.github.com/users/lkukielka/following{/other_user}","gists_url":"https://api.github.com/users/lkukielka/gists{/gist_id}","starred_url":"https://api.github.com/users/lkukielka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lkukielka/subscriptions","organizations_url":"https://api.github.com/users/lkukielka/orgs","repos_url":"https://api.github.com/users/lkukielka/repos","events_url":"https://api.github.com/users/lkukielka/events{/privacy}","received_events_url":"https://api.github.com/users/lkukielka/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-30T12:39:23Z","updated_at":"2016-05-30T13:46:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"225b867dfdcf003420c3daf9497296672859cef1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/motech/modules/pulls/303/commits","review_comments_url":"https://api.github.com/repos/motech/modules/pulls/303/comments","review_comment_url":"https://api.github.com/repos/motech/modules/pulls/comments{/number}","comments_url":"https://api.github.com/repos/motech/modules/issues/303/comments","statuses_url":"https://api.github.com/repos/motech/modules/statuses/4f96d001b77cad1af95f0ad38ed2d4d1563a4ba0","head":{"label":"lkukielka:MOTECH-2559","ref":"MOTECH-2559","sha":"4f96d001b77cad1af95f0ad38ed2d4d1563a4ba0","user":{"login":"lkukielka","id":17404322,"avatar_url":"https://avatars.githubusercontent.com/u/17404322?v=3","gravatar_id":"","url":"https://api.github.com/users/lkukielka","html_url":"https://github.com/lkukielka","followers_url":"https://api.github.com/users/lkukielka/followers","following_url":"https://api.github.com/users/lkukielka/following{/other_user}","gists_url":"https://api.github.com/users/lkukielka/gists{/gist_id}","starred_url":"https://api.github.com/users/lkukielka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lkukielka/subscriptions","organizations_url":"https://api.github.com/users/lkukielka/orgs","repos_url":"https://api.github.com/users/lkukielka/repos","events_url":"https://api.github.com/users/lkukielka/events{/privacy}","received_events_url":"https://api.github.com/users/lkukielka/received_events","type":"User","site_admin":false},"repo":{"id":52283427,"name":"modules","full_name":"lkukielka/modules","owner":{"login":"lkukielka","id":17404322,"avatar_url":"https://avatars.githubusercontent.com/u/17404322?v=3","gravatar_id":"","url":"https://api.github.com/users/lkukielka","html_url":"https://github.com/lkukielka","followers_url":"https://api.github.com/users/lkukielka/followers","following_url":"https://api.github.com/users/lkukielka/following{/other_user}","gists_url":"https://api.github.com/users/lkukielka/gists{/gist_id}","starred_url":"https://api.github.com/users/lkukielka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lkukielka/subscriptions","organizations_url":"https://api.github.com/users/lkukielka/orgs","repos_url":"https://api.github.com/users/lkukielka/repos","events_url":"https://api.github.com/users/lkukielka/events{/privacy}","received_events_url":"https://api.github.com/users/lkukielka/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lkukielka/modules","description":" Mobile Technology for Community Health - Modules","fork":true,"url":"https://api.github.com/repos/lkukielka/modules","forks_url":"https://api.github.com/repos/lkukielka/modules/forks","keys_url":"https://api.github.com/repos/lkukielka/modules/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lkukielka/modules/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lkukielka/modules/teams","hooks_url":"https://api.github.com/repos/lkukielka/modules/hooks","issue_events_url":"https://api.github.com/repos/lkukielka/modules/issues/events{/number}","events_url":"https://api.github.com/repos/lkukielka/modules/events","assignees_url":"https://api.github.com/repos/lkukielka/modules/assignees{/user}","branches_url":"https://api.github.com/repos/lkukielka/modules/branches{/branch}","tags_url":"https://api.github.com/repos/lkukielka/modules/tags","blobs_url":"https://api.github.com/repos/lkukielka/modules/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lkukielka/modules/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lkukielka/modules/git/refs{/sha}","trees_url":"https://api.github.com/repos/lkukielka/modules/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lkukielka/modules/statuses/{sha}","languages_url":"https://api.github.com/repos/lkukielka/modules/languages","stargazers_url":"https://api.github.com/repos/lkukielka/modules/stargazers","contributors_url":"https://api.github.com/repos/lkukielka/modules/contributors","subscribers_url":"https://api.github.com/repos/lkukielka/modules/subscribers","subscription_url":"https://api.github.com/repos/lkukielka/modules/subscription","commits_url":"https://api.github.com/repos/lkukielka/modules/commits{/sha}","git_commits_url":"https://api.github.com/repos/lkukielka/modules/git/commits{/sha}","comments_url":"https://api.github.com/repos/lkukielka/modules/comments{/number}","issue_comment_url":"https://api.github.com/repos/lkukielka/modules/issues/comments{/number}","contents_url":"https://api.github.com/repos/lkukielka/modules/contents/{+path}","compare_url":"https://api.github.com/repos/lkukielka/modules/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lkukielka/modules/merges","archive_url":"https://api.github.com/repos/lkukielka/modules/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lkukielka/modules/downloads","issues_url":"https://api.github.com/repos/lkukielka/modules/issues{/number}","pulls_url":"https://api.github.com/repos/lkukielka/modules/pulls{/number}","milestones_url":"https://api.github.com/repos/lkukielka/modules/milestones{/number}","notifications_url":"https://api.github.com/repos/lkukielka/modules/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lkukielka/modules/labels{/name}","releases_url":"https://api.github.com/repos/lkukielka/modules/releases{/id}","deployments_url":"https://api.github.com/repos/lkukielka/modules/deployments","created_at":"2016-02-22T15:32:07Z","updated_at":"2016-02-22T15:32:14Z","pushed_at":"2016-05-30T12:46:06Z","git_url":"git://github.com/lkukielka/modules.git","ssh_url":"git@github.com:lkukielka/modules.git","clone_url":"https://github.com/lkukielka/modules.git","svn_url":"https://github.com/lkukielka/modules","homepage":"http://modules.motechproject.org","size":33232,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"motech:master","ref":"master","sha":"8738ea26b4414ddcb91f4d74fa6bbd6b05b0f94b","user":{"login":"motech","id":477919,"avatar_url":"https://avatars.githubusercontent.com/u/477919?v=3","gravatar_id":"","url":"https://api.github.com/users/motech","html_url":"https://github.com/motech","followers_url":"https://api.github.com/users/motech/followers","following_url":"https://api.github.com/users/motech/following{/other_user}","gists_url":"https://api.github.com/users/motech/gists{/gist_id}","starred_url":"https://api.github.com/users/motech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/motech/subscriptions","organizations_url":"https://api.github.com/users/motech/orgs","repos_url":"https://api.github.com/users/motech/repos","events_url":"https://api.github.com/users/motech/events{/privacy}","received_events_url":"https://api.github.com/users/motech/received_events","type":"Organization","site_admin":false},"repo":{"id":19785525,"name":"modules","full_name":"motech/modules","owner":{"login":"motech","id":477919,"avatar_url":"https://avatars.githubusercontent.com/u/477919?v=3","gravatar_id":"","url":"https://api.github.com/users/motech","html_url":"https://github.com/motech","followers_url":"https://api.github.com/users/motech/followers","following_url":"https://api.github.com/users/motech/following{/other_user}","gists_url":"https://api.github.com/users/motech/gists{/gist_id}","starred_url":"https://api.github.com/users/motech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/motech/subscriptions","organizations_url":"https://api.github.com/users/motech/orgs","repos_url":"https://api.github.com/users/motech/repos","events_url":"https://api.github.com/users/motech/events{/privacy}","received_events_url":"https://api.github.com/users/motech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/motech/modules","description":" Mobile Technology for Community Health - Modules","fork":false,"url":"https://api.github.com/repos/motech/modules","forks_url":"https://api.github.com/repos/motech/modules/forks","keys_url":"https://api.github.com/repos/motech/modules/keys{/key_id}","collaborators_url":"https://api.github.com/repos/motech/modules/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/motech/modules/teams","hooks_url":"https://api.github.com/repos/motech/modules/hooks","issue_events_url":"https://api.github.com/repos/motech/modules/issues/events{/number}","events_url":"https://api.github.com/repos/motech/modules/events","assignees_url":"https://api.github.com/repos/motech/modules/assignees{/user}","branches_url":"https://api.github.com/repos/motech/modules/branches{/branch}","tags_url":"https://api.github.com/repos/motech/modules/tags","blobs_url":"https://api.github.com/repos/motech/modules/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/motech/modules/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/motech/modules/git/refs{/sha}","trees_url":"https://api.github.com/repos/motech/modules/git/trees{/sha}","statuses_url":"https://api.github.com/repos/motech/modules/statuses/{sha}","languages_url":"https://api.github.com/repos/motech/modules/languages","stargazers_url":"https://api.github.com/repos/motech/modules/stargazers","contributors_url":"https://api.github.com/repos/motech/modules/contributors","subscribers_url":"https://api.github.com/repos/motech/modules/subscribers","subscription_url":"https://api.github.com/repos/motech/modules/subscription","commits_url":"https://api.github.com/repos/motech/modules/commits{/sha}","git_commits_url":"https://api.github.com/repos/motech/modules/git/commits{/sha}","comments_url":"https://api.github.com/repos/motech/modules/comments{/number}","issue_comment_url":"https://api.github.com/repos/motech/modules/issues/comments{/number}","contents_url":"https://api.github.com/repos/motech/modules/contents/{+path}","compare_url":"https://api.github.com/repos/motech/modules/compare/{base}...{head}","merges_url":"https://api.github.com/repos/motech/modules/merges","archive_url":"https://api.github.com/repos/motech/modules/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/motech/modules/downloads","issues_url":"https://api.github.com/repos/motech/modules/issues{/number}","pulls_url":"https://api.github.com/repos/motech/modules/pulls{/number}","milestones_url":"https://api.github.com/repos/motech/modules/milestones{/number}","notifications_url":"https://api.github.com/repos/motech/modules/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/motech/modules/labels{/name}","releases_url":"https://api.github.com/repos/motech/modules/releases{/id}","deployments_url":"https://api.github.com/repos/motech/modules/deployments","created_at":"2014-05-14T15:41:17Z","updated_at":"2016-03-01T02:21:35Z","pushed_at":"2016-05-30T12:49:28Z","git_url":"git://github.com/motech/modules.git","ssh_url":"git@github.com:motech/modules.git","clone_url":"https://github.com/motech/modules.git","svn_url":"https://github.com/motech/modules","homepage":"http://modules.motechproject.org","size":39433,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":37,"mirror_url":null,"open_issues_count":11,"forks":37,"open_issues":11,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/motech/modules/pulls/303"},"html":{"href":"https://github.com/motech/modules/pull/303"},"issue":{"href":"https://api.github.com/repos/motech/modules/issues/303"},"comments":{"href":"https://api.github.com/repos/motech/modules/issues/303/comments"},"review_comments":{"href":"https://api.github.com/repos/motech/modules/pulls/303/comments"},"review_comment":{"href":"https://api.github.com/repos/motech/modules/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/motech/modules/pulls/303/commits"},"statuses":{"href":"https://api.github.com/repos/motech/modules/statuses/4f96d001b77cad1af95f0ad38ed2d4d1563a4ba0"}}}}
{"actor":{"display_login":"sebbrudzinski"}}