{"action":"created","comment":{"url":"https://api.github.com/repos/openregister/presentation/pulls/comments/35214834","id":35214834,"diff_hunk":"@@ -0,0 +1,83 @@\n+package uk.gov.register.presentation.representations;\n+\n+import com.google.common.base.Throwables;\n+import uk.gov.register.presentation.Entry;\n+import uk.gov.register.presentation.mapper.JsonObjectMapper;\n+import uk.gov.register.presentation.view.AbstractView;\n+import uk.gov.register.presentation.view.ListResultView;\n+import uk.gov.register.presentation.view.SingleResultView;\n+\n+import javax.ws.rs.Produces;\n+import javax.ws.rs.WebApplicationException;\n+import javax.ws.rs.core.MediaType;\n+import javax.ws.rs.core.MultivaluedMap;\n+import javax.ws.rs.core.UriBuilder;\n+import java.io.IOException;\n+import java.io.OutputStream;\n+import java.lang.annotation.Annotation;\n+import java.lang.reflect.Type;\n+import java.net.URI;\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.stream.Collectors;\n+\n+@Produces(ExtraMediaType.TEXT_TTL)\n+public class TurtleWriter extends RepresentationWriter<AbstractView> {\n+\n+\n+    @Override\n+    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {\n+        return type.isAssignableFrom(SingleResultView.class) || type.isAssignableFrom(ListResultView.class);\n+    }\n+\n+    @SuppressWarnings(\"unchecked\")\n+    @Override\n+    public void writeTo(AbstractView view, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {\n+        List<Entry> entries = getEntries(view.get());\n+\n+        List<String> fields = entryFields(JsonObjectMapper.convert(entries.get(0).getContent(), Map.class));\n+        for (Entry entry : entries) {\n+            writeRow(entry, fields, entityStream);\n+        }\n+    }\n+\n+    @SuppressWarnings(\"unchecked\")\n+    private List<Entry> getEntries(Object o) {\n+        if (o instanceof List) {\n+            return (List<Entry>) o;\n+        } else {\n+            List<Entry> entries = new ArrayList<>();\n+            entries.add((Entry) o);\n+            return entries;\n+        }\n+    }\n+\n+    //TODO: this should be retrieved from register call\n+    private static final String registerBaseUri = \"http://localhost:9000\";\n+\n+    @SuppressWarnings(\"unchecked\")\n+    private List entryFields(Map map) {","path":"src/main/java/uk/gov/register/presentation/representations/TurtleWriter.java","position":60,"original_position":60,"commit_id":"218bd14b549e326e200417b4267b7a3a63744594","original_commit_id":"218bd14b549e326e200417b4267b7a3a63744594","user":{"login":"philandstuff","id":581269,"avatar_url":"https://avatars.githubusercontent.com/u/581269?v=3","gravatar_id":"","url":"https://api.github.com/users/philandstuff","html_url":"https://github.com/philandstuff","followers_url":"https://api.github.com/users/philandstuff/followers","following_url":"https://api.github.com/users/philandstuff/following{/other_user}","gists_url":"https://api.github.com/users/philandstuff/gists{/gist_id}","starred_url":"https://api.github.com/users/philandstuff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philandstuff/subscriptions","organizations_url":"https://api.github.com/users/philandstuff/orgs","repos_url":"https://api.github.com/users/philandstuff/repos","events_url":"https://api.github.com/users/philandstuff/events{/privacy}","received_events_url":"https://api.github.com/users/philandstuff/received_events","type":"User","site_admin":false},"body":"you can remove the warning suppression here with the signature `private List<String> entryFields(Map<String,?> map)`","created_at":"2015-07-22T13:58:00Z","updated_at":"2015-07-22T13:58:00Z","html_url":"https://github.com/openregister/presentation/pull/17#discussion_r35214834","pull_request_url":"https://api.github.com/repos/openregister/presentation/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/openregister/presentation/pulls/comments/35214834"},"html":{"href":"https://github.com/openregister/presentation/pull/17#discussion_r35214834"},"pull_request":{"href":"https://api.github.com/repos/openregister/presentation/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/openregister/presentation/pulls/17","id":40554644,"html_url":"https://github.com/openregister/presentation/pull/17","diff_url":"https://github.com/openregister/presentation/pull/17.diff","patch_url":"https://github.com/openregister/presentation/pull/17.patch","issue_url":"https://api.github.com/repos/openregister/presentation/issues/17","number":17,"state":"open","locked":false,"title":"Turtle representation","user":{"login":"om-sharma","id":8011952,"avatar_url":"https://avatars.githubusercontent.com/u/8011952?v=3","gravatar_id":"","url":"https://api.github.com/users/om-sharma","html_url":"https://github.com/om-sharma","followers_url":"https://api.github.com/users/om-sharma/followers","following_url":"https://api.github.com/users/om-sharma/following{/other_user}","gists_url":"https://api.github.com/users/om-sharma/gists{/gist_id}","starred_url":"https://api.github.com/users/om-sharma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/om-sharma/subscriptions","organizations_url":"https://api.github.com/users/om-sharma/orgs","repos_url":"https://api.github.com/users/om-sharma/repos","events_url":"https://api.github.com/users/om-sharma/events{/privacy}","received_events_url":"https://api.github.com/users/om-sharma/received_events","type":"User","site_admin":false},"body":"Added functionality for all api methods to support turtle representation. This commit also include the refactoring to use Entry object to render json, also all writers are using Entry object now and view provides other methods needed for only html.","created_at":"2015-07-22T11:23:41Z","updated_at":"2015-07-22T13:58:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"31bf0445ce48e27899c42fa03e8e81485a19c9a1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openregister/presentation/pulls/17/commits","review_comments_url":"https://api.github.com/repos/openregister/presentation/pulls/17/comments","review_comment_url":"https://api.github.com/repos/openregister/presentation/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openregister/presentation/issues/17/comments","statuses_url":"https://api.github.com/repos/openregister/presentation/statuses/218bd14b549e326e200417b4267b7a3a63744594","head":{"label":"openregister:turtle_representation","ref":"turtle_representation","sha":"218bd14b549e326e200417b4267b7a3a63744594","user":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"repo":{"id":38381661,"name":"presentation","full_name":"openregister/presentation","owner":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openregister/presentation","description":"Read-only register application","fork":false,"url":"https://api.github.com/repos/openregister/presentation","forks_url":"https://api.github.com/repos/openregister/presentation/forks","keys_url":"https://api.github.com/repos/openregister/presentation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openregister/presentation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openregister/presentation/teams","hooks_url":"https://api.github.com/repos/openregister/presentation/hooks","issue_events_url":"https://api.github.com/repos/openregister/presentation/issues/events{/number}","events_url":"https://api.github.com/repos/openregister/presentation/events","assignees_url":"https://api.github.com/repos/openregister/presentation/assignees{/user}","branches_url":"https://api.github.com/repos/openregister/presentation/branches{/branch}","tags_url":"https://api.github.com/repos/openregister/presentation/tags","blobs_url":"https://api.github.com/repos/openregister/presentation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openregister/presentation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openregister/presentation/git/refs{/sha}","trees_url":"https://api.github.com/repos/openregister/presentation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openregister/presentation/statuses/{sha}","languages_url":"https://api.github.com/repos/openregister/presentation/languages","stargazers_url":"https://api.github.com/repos/openregister/presentation/stargazers","contributors_url":"https://api.github.com/repos/openregister/presentation/contributors","subscribers_url":"https://api.github.com/repos/openregister/presentation/subscribers","subscription_url":"https://api.github.com/repos/openregister/presentation/subscription","commits_url":"https://api.github.com/repos/openregister/presentation/commits{/sha}","git_commits_url":"https://api.github.com/repos/openregister/presentation/git/commits{/sha}","comments_url":"https://api.github.com/repos/openregister/presentation/comments{/number}","issue_comment_url":"https://api.github.com/repos/openregister/presentation/issues/comments{/number}","contents_url":"https://api.github.com/repos/openregister/presentation/contents/{+path}","compare_url":"https://api.github.com/repos/openregister/presentation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openregister/presentation/merges","archive_url":"https://api.github.com/repos/openregister/presentation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openregister/presentation/downloads","issues_url":"https://api.github.com/repos/openregister/presentation/issues{/number}","pulls_url":"https://api.github.com/repos/openregister/presentation/pulls{/number}","milestones_url":"https://api.github.com/repos/openregister/presentation/milestones{/number}","notifications_url":"https://api.github.com/repos/openregister/presentation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openregister/presentation/labels{/name}","releases_url":"https://api.github.com/repos/openregister/presentation/releases{/id}","created_at":"2015-07-01T16:17:58Z","updated_at":"2015-07-16T09:18:23Z","pushed_at":"2015-07-22T13:37:13Z","git_url":"git://github.com/openregister/presentation.git","ssh_url":"git@github.com:openregister/presentation.git","clone_url":"https://github.com/openregister/presentation.git","svn_url":"https://github.com/openregister/presentation","homepage":"","size":1132,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"openregister:master","ref":"master","sha":"94a79fb0f8e6c7d6c4c956e12caea36962500fa9","user":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"repo":{"id":38381661,"name":"presentation","full_name":"openregister/presentation","owner":{"login":"openregister","id":10206003,"avatar_url":"https://avatars.githubusercontent.com/u/10206003?v=3","gravatar_id":"","url":"https://api.github.com/users/openregister","html_url":"https://github.com/openregister","followers_url":"https://api.github.com/users/openregister/followers","following_url":"https://api.github.com/users/openregister/following{/other_user}","gists_url":"https://api.github.com/users/openregister/gists{/gist_id}","starred_url":"https://api.github.com/users/openregister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openregister/subscriptions","organizations_url":"https://api.github.com/users/openregister/orgs","repos_url":"https://api.github.com/users/openregister/repos","events_url":"https://api.github.com/users/openregister/events{/privacy}","received_events_url":"https://api.github.com/users/openregister/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openregister/presentation","description":"Read-only register application","fork":false,"url":"https://api.github.com/repos/openregister/presentation","forks_url":"https://api.github.com/repos/openregister/presentation/forks","keys_url":"https://api.github.com/repos/openregister/presentation/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openregister/presentation/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openregister/presentation/teams","hooks_url":"https://api.github.com/repos/openregister/presentation/hooks","issue_events_url":"https://api.github.com/repos/openregister/presentation/issues/events{/number}","events_url":"https://api.github.com/repos/openregister/presentation/events","assignees_url":"https://api.github.com/repos/openregister/presentation/assignees{/user}","branches_url":"https://api.github.com/repos/openregister/presentation/branches{/branch}","tags_url":"https://api.github.com/repos/openregister/presentation/tags","blobs_url":"https://api.github.com/repos/openregister/presentation/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openregister/presentation/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openregister/presentation/git/refs{/sha}","trees_url":"https://api.github.com/repos/openregister/presentation/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openregister/presentation/statuses/{sha}","languages_url":"https://api.github.com/repos/openregister/presentation/languages","stargazers_url":"https://api.github.com/repos/openregister/presentation/stargazers","contributors_url":"https://api.github.com/repos/openregister/presentation/contributors","subscribers_url":"https://api.github.com/repos/openregister/presentation/subscribers","subscription_url":"https://api.github.com/repos/openregister/presentation/subscription","commits_url":"https://api.github.com/repos/openregister/presentation/commits{/sha}","git_commits_url":"https://api.github.com/repos/openregister/presentation/git/commits{/sha}","comments_url":"https://api.github.com/repos/openregister/presentation/comments{/number}","issue_comment_url":"https://api.github.com/repos/openregister/presentation/issues/comments{/number}","contents_url":"https://api.github.com/repos/openregister/presentation/contents/{+path}","compare_url":"https://api.github.com/repos/openregister/presentation/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openregister/presentation/merges","archive_url":"https://api.github.com/repos/openregister/presentation/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openregister/presentation/downloads","issues_url":"https://api.github.com/repos/openregister/presentation/issues{/number}","pulls_url":"https://api.github.com/repos/openregister/presentation/pulls{/number}","milestones_url":"https://api.github.com/repos/openregister/presentation/milestones{/number}","notifications_url":"https://api.github.com/repos/openregister/presentation/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openregister/presentation/labels{/name}","releases_url":"https://api.github.com/repos/openregister/presentation/releases{/id}","created_at":"2015-07-01T16:17:58Z","updated_at":"2015-07-16T09:18:23Z","pushed_at":"2015-07-22T13:37:13Z","git_url":"git://github.com/openregister/presentation.git","ssh_url":"git@github.com:openregister/presentation.git","clone_url":"https://github.com/openregister/presentation.git","svn_url":"https://github.com/openregister/presentation","homepage":"","size":1132,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openregister/presentation/pulls/17"},"html":{"href":"https://github.com/openregister/presentation/pull/17"},"issue":{"href":"https://api.github.com/repos/openregister/presentation/issues/17"},"comments":{"href":"https://api.github.com/repos/openregister/presentation/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/openregister/presentation/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/openregister/presentation/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openregister/presentation/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/openregister/presentation/statuses/218bd14b549e326e200417b4267b7a3a63744594"}}}}