{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/comments/131973172","pull_request_review_id":55005041,"id":131973172,"diff_hunk":"@@ -0,0 +1,71 @@\n+// Copyright (c) Microsoft. All rights reserved.\n+\n+package com.microsoft.azure.iotsolutions.devicetelemetry.webservice.v1.models;\n+\n+import com.fasterxml.jackson.annotation.JsonProperty;\n+import com.microsoft.azure.iotsolutions.devicetelemetry.services.models.AlarmServiceModel;\n+import com.microsoft.azure.iotsolutions.devicetelemetry.webservice.v1.Version;\n+import org.joda.time.DateTime;\n+\n+import java.util.*;\n+\n+public class AlarmByRuleListApiModel {\n+    private final ArrayList<AlarmByRuleApiModel> items;\n+\n+    public enum Status {\n+        open  (3),\n+        acknowledged(2),\n+        closed   (1)\n+        ;\n+\n+        private final int statusCode;\n+\n+        private Status(int statusCode) {\n+            this.statusCode = statusCode;\n+        }\n+    }\n+\n+    public AlarmByRuleListApiModel(final ArrayList<AlarmServiceModel> alarms) {\n+        this.items = new ArrayList<>();\n+        if (alarms != null) {\n+            HashMap<String, AlarmByRuleApiModel> map = new HashMap<>();\n+            for (AlarmServiceModel alarm : alarms) {\n+                String id = alarm.getRuleId();\n+                if(!map.containsKey(id)) {\n+                    map.put(id, new AlarmByRuleApiModel(1, alarm.getStatus(), alarm.getDateModified(), alarm));\n+                } else {\n+                    AlarmByRuleApiModel alarmByRule = map.get(id);\n+                    alarmByRule.setTotalCount(alarmByRule.getTotalCount() + 1);\n+                    DateTime occurred = alarm.getDateCreated();\n+                    if(DateTime.parse(alarmByRule.getLastOccurred()).isBefore(occurred)) {\n+                        alarmByRule.setLastOccurred(occurred);\n+                    }\n+\n+                    String savedStatus = alarmByRule.getStatus();\n+                    String newStatus = alarm.getStatus();\n+                    if(Status.valueOf(savedStatus).statusCode < Status.valueOf(newStatus).statusCode) {","path":"app/com/microsoft/azure/iotsolutions/devicetelemetry/webservice/v1/models/AlarmByRuleListApiModel.java","position":46,"original_position":46,"commit_id":"b8cd4a77e9f45ffb0fabb51fc71f9fd9b99cf61d","original_commit_id":"4516fc67cddbd356cd172c3795209af66fab502c","user":{"login":"ppathan","id":16170750,"avatar_url":"https://avatars2.githubusercontent.com/u/16170750?v=4","gravatar_id":"","url":"https://api.github.com/users/ppathan","html_url":"https://github.com/ppathan","followers_url":"https://api.github.com/users/ppathan/followers","following_url":"https://api.github.com/users/ppathan/following{/other_user}","gists_url":"https://api.github.com/users/ppathan/gists{/gist_id}","starred_url":"https://api.github.com/users/ppathan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppathan/subscriptions","organizations_url":"https://api.github.com/users/ppathan/orgs","repos_url":"https://api.github.com/users/ppathan/repos","events_url":"https://api.github.com/users/ppathan/events{/privacy}","received_events_url":"https://api.github.com/users/ppathan/received_events","type":"User","site_admin":false},"body":"added","created_at":"2017-08-08T17:07:52Z","updated_at":"2017-08-08T17:07:52Z","html_url":"https://github.com/Azure/device-telemetry-java/pull/51#discussion_r131973172","pull_request_url":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/51","_links":{"self":{"href":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/comments/131973172"},"html":{"href":"https://github.com/Azure/device-telemetry-java/pull/51#discussion_r131973172"},"pull_request":{"href":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/51"}}},"pull_request":{"url":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/51","id":134213069,"html_url":"https://github.com/Azure/device-telemetry-java/pull/51","diff_url":"https://github.com/Azure/device-telemetry-java/pull/51.diff","patch_url":"https://github.com/Azure/device-telemetry-java/pull/51.patch","issue_url":"https://api.github.com/repos/Azure/device-telemetry-java/issues/51","number":51,"state":"open","locked":false,"title":"Remaining work for Alarm and AlarmsByRule","user":{"login":"ppathan","id":16170750,"avatar_url":"https://avatars2.githubusercontent.com/u/16170750?v=4","gravatar_id":"","url":"https://api.github.com/users/ppathan","html_url":"https://github.com/ppathan","followers_url":"https://api.github.com/users/ppathan/followers","following_url":"https://api.github.com/users/ppathan/following{/other_user}","gists_url":"https://api.github.com/users/ppathan/gists{/gist_id}","starred_url":"https://api.github.com/users/ppathan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ppathan/subscriptions","organizations_url":"https://api.github.com/users/ppathan/orgs","repos_url":"https://api.github.com/users/ppathan/repos","events_url":"https://api.github.com/users/ppathan/events{/privacy}","received_events_url":"https://api.github.com/users/ppathan/received_events","type":"User","site_admin":false},"body":"# Types of changes\r\n<!-- Please put an `x` (e.g. [x]) in all the boxes that apply: -->\r\n- [ ] Bug fix (non-breaking change which fixes an issue)\r\n- [x] New feature (non-breaking change which adds functionality)\r\n- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)\r\n\r\n# Checklist:\r\n<!-- Please put an `x` (e.g. [x]) in all the boxes that apply: -->\r\n- [ ] The code follows the code style and conventions of this project.\r\n- [ ] The change requires a change to the documentation.\r\n- [ ] I have updated the documentation accordingly.\r\n- [ ] All new and existing tests passed.\r\n\r\n# Description of the change\r\n<!-- Please provide enough information so others can review your pull request -->\r\n* Implement /alarms endpoint to do following:\r\n  * List alarms\r\n  * Get individual alarm\r\n  * Update status of the alarm\r\n* Implement missing feature for /alarmsbyrule that returns totalOccurrence, status and occurred Date\r\n* Added mocked unit tests for both\r\n","created_at":"2017-08-04T17:18:56Z","updated_at":"2017-08-08T17:07:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"26ba970b558f2c5dd52737be178149cfce3fc102","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/51/commits","review_comments_url":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/51/comments","review_comment_url":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/device-telemetry-java/issues/51/comments","statuses_url":"https://api.github.com/repos/Azure/device-telemetry-java/statuses/b8cd4a77e9f45ffb0fabb51fc71f9fd9b99cf61d","head":{"label":"Azure:alarms-bugfix","ref":"alarms-bugfix","sha":"b8cd4a77e9f45ffb0fabb51fc71f9fd9b99cf61d","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":94933761,"name":"device-telemetry-java","full_name":"Azure/device-telemetry-java","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/device-telemetry-java","description":"Java implementation for device telemetry for PCS","fork":false,"url":"https://api.github.com/repos/Azure/device-telemetry-java","forks_url":"https://api.github.com/repos/Azure/device-telemetry-java/forks","keys_url":"https://api.github.com/repos/Azure/device-telemetry-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/device-telemetry-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/device-telemetry-java/teams","hooks_url":"https://api.github.com/repos/Azure/device-telemetry-java/hooks","issue_events_url":"https://api.github.com/repos/Azure/device-telemetry-java/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/device-telemetry-java/events","assignees_url":"https://api.github.com/repos/Azure/device-telemetry-java/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/device-telemetry-java/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/device-telemetry-java/tags","blobs_url":"https://api.github.com/repos/Azure/device-telemetry-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/device-telemetry-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/device-telemetry-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/device-telemetry-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/device-telemetry-java/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/device-telemetry-java/languages","stargazers_url":"https://api.github.com/repos/Azure/device-telemetry-java/stargazers","contributors_url":"https://api.github.com/repos/Azure/device-telemetry-java/contributors","subscribers_url":"https://api.github.com/repos/Azure/device-telemetry-java/subscribers","subscription_url":"https://api.github.com/repos/Azure/device-telemetry-java/subscription","commits_url":"https://api.github.com/repos/Azure/device-telemetry-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/device-telemetry-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/device-telemetry-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/device-telemetry-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/device-telemetry-java/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/device-telemetry-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/device-telemetry-java/merges","archive_url":"https://api.github.com/repos/Azure/device-telemetry-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/device-telemetry-java/downloads","issues_url":"https://api.github.com/repos/Azure/device-telemetry-java/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/device-telemetry-java/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/device-telemetry-java/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/device-telemetry-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/device-telemetry-java/labels{/name}","releases_url":"https://api.github.com/repos/Azure/device-telemetry-java/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/device-telemetry-java/deployments","created_at":"2017-06-20T20:48:07Z","updated_at":"2017-07-13T23:39:08Z","pushed_at":"2017-08-08T16:24:54Z","git_url":"git://github.com/Azure/device-telemetry-java.git","ssh_url":"git@github.com:Azure/device-telemetry-java.git","clone_url":"https://github.com/Azure/device-telemetry-java.git","svn_url":"https://github.com/Azure/device-telemetry-java","homepage":null,"size":2286,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":1,"default_branch":"master"}},"base":{"label":"Azure:master","ref":"master","sha":"99c0c02cc39f455ae33f0cf8868f3c35f2cd0e05","user":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":94933761,"name":"device-telemetry-java","full_name":"Azure/device-telemetry-java","owner":{"login":"Azure","id":6844498,"avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Azure/device-telemetry-java","description":"Java implementation for device telemetry for PCS","fork":false,"url":"https://api.github.com/repos/Azure/device-telemetry-java","forks_url":"https://api.github.com/repos/Azure/device-telemetry-java/forks","keys_url":"https://api.github.com/repos/Azure/device-telemetry-java/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/device-telemetry-java/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/device-telemetry-java/teams","hooks_url":"https://api.github.com/repos/Azure/device-telemetry-java/hooks","issue_events_url":"https://api.github.com/repos/Azure/device-telemetry-java/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/device-telemetry-java/events","assignees_url":"https://api.github.com/repos/Azure/device-telemetry-java/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/device-telemetry-java/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/device-telemetry-java/tags","blobs_url":"https://api.github.com/repos/Azure/device-telemetry-java/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/device-telemetry-java/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/device-telemetry-java/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/device-telemetry-java/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/device-telemetry-java/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/device-telemetry-java/languages","stargazers_url":"https://api.github.com/repos/Azure/device-telemetry-java/stargazers","contributors_url":"https://api.github.com/repos/Azure/device-telemetry-java/contributors","subscribers_url":"https://api.github.com/repos/Azure/device-telemetry-java/subscribers","subscription_url":"https://api.github.com/repos/Azure/device-telemetry-java/subscription","commits_url":"https://api.github.com/repos/Azure/device-telemetry-java/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/device-telemetry-java/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/device-telemetry-java/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/device-telemetry-java/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/device-telemetry-java/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/device-telemetry-java/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/device-telemetry-java/merges","archive_url":"https://api.github.com/repos/Azure/device-telemetry-java/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/device-telemetry-java/downloads","issues_url":"https://api.github.com/repos/Azure/device-telemetry-java/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/device-telemetry-java/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/device-telemetry-java/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/device-telemetry-java/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/device-telemetry-java/labels{/name}","releases_url":"https://api.github.com/repos/Azure/device-telemetry-java/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/device-telemetry-java/deployments","created_at":"2017-06-20T20:48:07Z","updated_at":"2017-07-13T23:39:08Z","pushed_at":"2017-08-08T16:24:54Z","git_url":"git://github.com/Azure/device-telemetry-java.git","ssh_url":"git@github.com:Azure/device-telemetry-java.git","clone_url":"https://github.com/Azure/device-telemetry-java.git","svn_url":"https://github.com/Azure/device-telemetry-java","homepage":null,"size":2286,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":14,"forks":0,"open_issues":14,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/51"},"html":{"href":"https://github.com/Azure/device-telemetry-java/pull/51"},"issue":{"href":"https://api.github.com/repos/Azure/device-telemetry-java/issues/51"},"comments":{"href":"https://api.github.com/repos/Azure/device-telemetry-java/issues/51/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/51/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/device-telemetry-java/pulls/51/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/device-telemetry-java/statuses/b8cd4a77e9f45ffb0fabb51fc71f9fd9b99cf61d"}}}}
{"actor":{"display_login":"ppathan"}}