{"action":"created","comment":{"url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/comments/78441570","id":78441570,"diff_hunk":"@@ -0,0 +1,60 @@\n+package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9;\n+\n+import org.openmrs.Location;\n+import org.openmrs.LocationAttribute;\n+import org.openmrs.api.context.Context;\n+import org.openmrs.module.webservices.rest.web.RequestContext;\n+import org.openmrs.module.webservices.rest.web.RestConstants;\n+import org.openmrs.module.webservices.rest.web.resource.api.PageableResult;\n+import org.openmrs.module.webservices.rest.web.resource.api.SearchConfig;\n+import org.openmrs.module.webservices.rest.web.resource.api.SearchQuery;\n+import org.openmrs.module.webservices.rest.web.resource.api.SubSearchHandler;\n+import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult;\n+import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging;\n+import org.openmrs.module.webservices.rest.web.response.ResponseException;\n+import org.springframework.stereotype.Component;\n+\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.List;\n+\n+@Component\n+public class LocationAttributeSubSearchHandler1_9 implements SubSearchHandler {\n+\n+    private final static SearchConfig SEARCH_CONFIG = new SearchConfig(\n+            \"default\",\n+            RestConstants.VERSION_1 + \"/location/attribute\",\n+            Arrays.asList(\"1.9.*\", \"1.10.*\", \"1.11.*\", \"1.12.*\", \"2.0.*\"),\n+            new SearchQuery.Builder(\"Allows you to find attributes by attribute type\")\n+                    .withRequiredParameters(\"attributeType\")\n+                    .build()\n+    );\n+\n+    @Override\n+    public SearchConfig getSearchConfig() {\n+        return SEARCH_CONFIG;\n+    }\n+\n+    @Override\n+    public PageableResult search(RequestContext context) throws ResponseException {\n+        throw new UnsupportedOperationException(\"Cannot search for location attributes without parent location\");\n+    }\n+\n+    @Override\n+    public PageableResult search(String parentUuid, RequestContext context) throws ResponseException {\n+        String attributeType = context.getParameter(\"attributeType\");\n+        Location parentLocation = Context.getLocationService().getLocationByUuid(parentUuid);\n+\n+        if(attributeType == null || parentUuid == null){\n+            return new EmptySearchResult();\n+        }\n+\n+        List<LocationAttribute> results = new ArrayList<LocationAttribute>();\n+        for(LocationAttribute activeAttribute : parentLocation.getActiveAttributes()){\n+            if(activeAttribute.getAttributeType().getUuid().equals(attributeType)){","path":"omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/LocationAttributeSubSearchHandler1_9.java","position":54,"original_position":54,"commit_id":"e9bef4fc214c1c837746e70a779745cb2d5deeff","original_commit_id":"e9bef4fc214c1c837746e70a779745cb2d5deeff","user":{"login":"wluyima","id":1395907,"avatar_url":"https://avatars.githubusercontent.com/u/1395907?v=3","gravatar_id":"","url":"https://api.github.com/users/wluyima","html_url":"https://github.com/wluyima","followers_url":"https://api.github.com/users/wluyima/followers","following_url":"https://api.github.com/users/wluyima/following{/other_user}","gists_url":"https://api.github.com/users/wluyima/gists{/gist_id}","starred_url":"https://api.github.com/users/wluyima/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wluyima/subscriptions","organizations_url":"https://api.github.com/users/wluyima/orgs","repos_url":"https://api.github.com/users/wluyima/repos","events_url":"https://api.github.com/users/wluyima/events{/privacy}","received_events_url":"https://api.github.com/users/wluyima/received_events","type":"User","site_admin":false},"body":"getting a sub resource is always supported anways, I would expect this to do more useful searches e.g one with a name that contains or starts with a given piece of text","created_at":"2016-09-12T19:48:45Z","updated_at":"2016-09-12T19:48:45Z","html_url":"https://github.com/openmrs/openmrs-module-webservices.rest/pull/226#discussion_r78441570","pull_request_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/226","_links":{"self":{"href":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/comments/78441570"},"html":{"href":"https://github.com/openmrs/openmrs-module-webservices.rest/pull/226#discussion_r78441570"},"pull_request":{"href":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/226"}}},"pull_request":{"url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/226","id":84848058,"html_url":"https://github.com/openmrs/openmrs-module-webservices.rest/pull/226","diff_url":"https://github.com/openmrs/openmrs-module-webservices.rest/pull/226.diff","patch_url":"https://github.com/openmrs/openmrs-module-webservices.rest/pull/226.patch","issue_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/issues/226","number":226,"state":"open","locked":false,"title":"RESTWS-362 Add search for subresources","user":{"login":"PawelGutkowski","id":17570261,"avatar_url":"https://avatars.githubusercontent.com/u/17570261?v=3","gravatar_id":"","url":"https://api.github.com/users/PawelGutkowski","html_url":"https://github.com/PawelGutkowski","followers_url":"https://api.github.com/users/PawelGutkowski/followers","following_url":"https://api.github.com/users/PawelGutkowski/following{/other_user}","gists_url":"https://api.github.com/users/PawelGutkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/PawelGutkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PawelGutkowski/subscriptions","organizations_url":"https://api.github.com/users/PawelGutkowski/orgs","repos_url":"https://api.github.com/users/PawelGutkowski/repos","events_url":"https://api.github.com/users/PawelGutkowski/events{/privacy}","received_events_url":"https://api.github.com/users/PawelGutkowski/received_events","type":"User","site_admin":false},"body":"https://issues.openmrs.org/browse/RESTWS-362","created_at":"2016-09-12T10:28:19Z","updated_at":"2016-09-12T19:48:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"46852cc4be1d330cedbacd2c7df997f277bd7398","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/226/commits","review_comments_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/226/comments","review_comment_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/issues/226/comments","statuses_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/statuses/e9bef4fc214c1c837746e70a779745cb2d5deeff","head":{"label":"PawelGutkowski:master","ref":"master","sha":"e9bef4fc214c1c837746e70a779745cb2d5deeff","user":{"login":"PawelGutkowski","id":17570261,"avatar_url":"https://avatars.githubusercontent.com/u/17570261?v=3","gravatar_id":"","url":"https://api.github.com/users/PawelGutkowski","html_url":"https://github.com/PawelGutkowski","followers_url":"https://api.github.com/users/PawelGutkowski/followers","following_url":"https://api.github.com/users/PawelGutkowski/following{/other_user}","gists_url":"https://api.github.com/users/PawelGutkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/PawelGutkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PawelGutkowski/subscriptions","organizations_url":"https://api.github.com/users/PawelGutkowski/orgs","repos_url":"https://api.github.com/users/PawelGutkowski/repos","events_url":"https://api.github.com/users/PawelGutkowski/events{/privacy}","received_events_url":"https://api.github.com/users/PawelGutkowski/received_events","type":"User","site_admin":false},"repo":{"id":54971308,"name":"openmrs-module-webservices.rest","full_name":"PawelGutkowski/openmrs-module-webservices.rest","owner":{"login":"PawelGutkowski","id":17570261,"avatar_url":"https://avatars.githubusercontent.com/u/17570261?v=3","gravatar_id":"","url":"https://api.github.com/users/PawelGutkowski","html_url":"https://github.com/PawelGutkowski","followers_url":"https://api.github.com/users/PawelGutkowski/followers","following_url":"https://api.github.com/users/PawelGutkowski/following{/other_user}","gists_url":"https://api.github.com/users/PawelGutkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/PawelGutkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PawelGutkowski/subscriptions","organizations_url":"https://api.github.com/users/PawelGutkowski/orgs","repos_url":"https://api.github.com/users/PawelGutkowski/repos","events_url":"https://api.github.com/users/PawelGutkowski/events{/privacy}","received_events_url":"https://api.github.com/users/PawelGutkowski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PawelGutkowski/openmrs-module-webservices.rest","description":"Provides RESTful web services for OpenMRS","fork":true,"url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest","forks_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/forks","keys_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/teams","hooks_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/hooks","issue_events_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/issues/events{/number}","events_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/events","assignees_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/assignees{/user}","branches_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/branches{/branch}","tags_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/tags","blobs_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/git/refs{/sha}","trees_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/statuses/{sha}","languages_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/languages","stargazers_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/stargazers","contributors_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/contributors","subscribers_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/subscribers","subscription_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/subscription","commits_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/commits{/sha}","git_commits_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/git/commits{/sha}","comments_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/comments{/number}","issue_comment_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/issues/comments{/number}","contents_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/contents/{+path}","compare_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/merges","archive_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/downloads","issues_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/issues{/number}","pulls_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/pulls{/number}","milestones_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/milestones{/number}","notifications_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/labels{/name}","releases_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/releases{/id}","deployments_url":"https://api.github.com/repos/PawelGutkowski/openmrs-module-webservices.rest/deployments","created_at":"2016-03-29T11:47:22Z","updated_at":"2016-03-29T11:47:25Z","pushed_at":"2016-09-12T10:25:45Z","git_url":"git://github.com/PawelGutkowski/openmrs-module-webservices.rest.git","ssh_url":"git@github.com:PawelGutkowski/openmrs-module-webservices.rest.git","clone_url":"https://github.com/PawelGutkowski/openmrs-module-webservices.rest.git","svn_url":"https://github.com/PawelGutkowski/openmrs-module-webservices.rest","homepage":null,"size":4764,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"openmrs:master","ref":"master","sha":"cd6222dd820f976c5d10961405876771ab62fe0a","user":{"login":"openmrs","id":860776,"avatar_url":"https://avatars.githubusercontent.com/u/860776?v=3","gravatar_id":"","url":"https://api.github.com/users/openmrs","html_url":"https://github.com/openmrs","followers_url":"https://api.github.com/users/openmrs/followers","following_url":"https://api.github.com/users/openmrs/following{/other_user}","gists_url":"https://api.github.com/users/openmrs/gists{/gist_id}","starred_url":"https://api.github.com/users/openmrs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openmrs/subscriptions","organizations_url":"https://api.github.com/users/openmrs/orgs","repos_url":"https://api.github.com/users/openmrs/repos","events_url":"https://api.github.com/users/openmrs/events{/privacy}","received_events_url":"https://api.github.com/users/openmrs/received_events","type":"Organization","site_admin":false},"repo":{"id":6951233,"name":"openmrs-module-webservices.rest","full_name":"openmrs/openmrs-module-webservices.rest","owner":{"login":"openmrs","id":860776,"avatar_url":"https://avatars.githubusercontent.com/u/860776?v=3","gravatar_id":"","url":"https://api.github.com/users/openmrs","html_url":"https://github.com/openmrs","followers_url":"https://api.github.com/users/openmrs/followers","following_url":"https://api.github.com/users/openmrs/following{/other_user}","gists_url":"https://api.github.com/users/openmrs/gists{/gist_id}","starred_url":"https://api.github.com/users/openmrs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openmrs/subscriptions","organizations_url":"https://api.github.com/users/openmrs/orgs","repos_url":"https://api.github.com/users/openmrs/repos","events_url":"https://api.github.com/users/openmrs/events{/privacy}","received_events_url":"https://api.github.com/users/openmrs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openmrs/openmrs-module-webservices.rest","description":"Provides RESTful web services for OpenMRS","fork":false,"url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest","forks_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/forks","keys_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/teams","hooks_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/hooks","issue_events_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/issues/events{/number}","events_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/events","assignees_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/assignees{/user}","branches_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/branches{/branch}","tags_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/tags","blobs_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/git/refs{/sha}","trees_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/statuses/{sha}","languages_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/languages","stargazers_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/stargazers","contributors_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/contributors","subscribers_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/subscribers","subscription_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/subscription","commits_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/commits{/sha}","git_commits_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/git/commits{/sha}","comments_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/comments{/number}","issue_comment_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/issues/comments{/number}","contents_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/contents/{+path}","compare_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/merges","archive_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/downloads","issues_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/issues{/number}","pulls_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls{/number}","milestones_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/milestones{/number}","notifications_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/labels{/name}","releases_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/releases{/id}","deployments_url":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/deployments","created_at":"2012-12-01T06:50:25Z","updated_at":"2016-08-18T05:02:19Z","pushed_at":"2016-09-12T18:30:18Z","git_url":"git://github.com/openmrs/openmrs-module-webservices.rest.git","ssh_url":"git@github.com:openmrs/openmrs-module-webservices.rest.git","clone_url":"https://github.com/openmrs/openmrs-module-webservices.rest.git","svn_url":"https://github.com/openmrs/openmrs-module-webservices.rest","homepage":null,"size":6095,"stargazers_count":16,"watchers_count":16,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":146,"mirror_url":null,"open_issues_count":1,"forks":146,"open_issues":1,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/226"},"html":{"href":"https://github.com/openmrs/openmrs-module-webservices.rest/pull/226"},"issue":{"href":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/issues/226"},"comments":{"href":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/issues/226/comments"},"review_comments":{"href":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/226/comments"},"review_comment":{"href":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/pulls/226/commits"},"statuses":{"href":"https://api.github.com/repos/openmrs/openmrs-module-webservices.rest/statuses/e9bef4fc214c1c837746e70a779745cb2d5deeff"}}}}
{"actor":{"display_login":"wluyima"}}