{"action":"created","comment":{"url":"https://api.github.com/repos/nasa/openmctweb/pulls/comments/44190535","id":44190535,"diff_hunk":"@@ -0,0 +1,79 @@\n+/*****************************************************************************\n+ * Open MCT Web, Copyright (c) 2014-2015, United States Government\n+ * as represented by the Administrator of the National Aeronautics and Space\n+ * Administration. All rights reserved.\n+ *\n+ * Open MCT Web is licensed under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ * http://www.apache.org/licenses/LICENSE-2.0.\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations\n+ * under the License.\n+ *\n+ * Open MCT Web includes source code licensed under additional open source\n+ * licenses. See the Open Source Licenses file (LICENSES.md) included with\n+ * this source code distribution or the Licensing information page available\n+ * at runtime from the About dialog for additional information.\n+ *****************************************************************************/\n+/*global define,Promise*/\n+\n+define(\n+    ['../objects/DomainObjectImpl', 'uuid'],\n+    function (DomainObjectImpl, uuid) {\n+        'use strict';\n+\n+        /**\n+         * Implements the `creation` capability. This allows new domain\n+         * objects to be instantiated.\n+         *\n+         * @constructor\n+         * @memberof platform/core\n+         * @param $injector Angular's `$injector`\n+         */\n+        function CreationCapability($injector) {\n+            this.$injector = $injector;\n+        }\n+\n+        /**\n+         * Alias of `capabilityService.getCapabilities`; handles lazy loading\n+         * of `capabilityService`, since it cannot be declared as a\n+         * dependency directly without creating a cycle.\n+         * @private\n+         */\n+        CreationCapability.prototype.getCapabilities = function (model) {\n+            if (!this.capabilityService) {\n+                this.capabilityService =\n+                    this.$injector.get('capabilityService');\n+            }\n+            return this.capabilityService.getCapabilities(model);\n+        };\n+\n+        /**\n+         * Instantiate a new domain object with the provided model.\n+         *\n+         * This domain object will have been simply instantiated; it will not\n+         * have been persisted, nor will it have been added to the\n+         * composition of the object which exposed this capability.\n+         *\n+         * @returns {DomainObject} the new domain object\n+         */\n+        CreationCapability.prototype.create = function (model) {\n+            var id = uuid(),\n+                capabilities = this.getCapabilities(model);\n+            return new DomainObjectImpl(id, model, capabilities);\n+        };\n+\n+        /**\n+         * Alias of `create`.\n+         * @see {platform/core.CreationCapability#create}\n+         */\n+        CreationCapability.prototype.invoke =\n+            CreationCapability.prototype.create;\n+\n+        return CreationCapability;\n+    }\n+);","path":"platform/core/src/capabilities/CreationCapability.js","position":79,"original_position":79,"commit_id":"3741a02d2a54bbae314bfa3d65af49a8980628fc","original_commit_id":"3741a02d2a54bbae314bfa3d65af49a8980628fc","user":{"login":"akhenry","id":4215777,"avatar_url":"https://avatars.githubusercontent.com/u/4215777?v=3","gravatar_id":"","url":"https://api.github.com/users/akhenry","html_url":"https://github.com/akhenry","followers_url":"https://api.github.com/users/akhenry/followers","following_url":"https://api.github.com/users/akhenry/following{/other_user}","gists_url":"https://api.github.com/users/akhenry/gists{/gist_id}","starred_url":"https://api.github.com/users/akhenry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akhenry/subscriptions","organizations_url":"https://api.github.com/users/akhenry/orgs","repos_url":"https://api.github.com/users/akhenry/repos","events_url":"https://api.github.com/users/akhenry/events{/privacy}","received_events_url":"https://api.github.com/users/akhenry/received_events","type":"User","site_admin":false},"body":"In short, it would be nice if it were possible to leave resolution of persistence space until its time to persist the object","created_at":"2015-11-06T21:39:05Z","updated_at":"2015-11-06T21:39:05Z","html_url":"https://github.com/nasa/openmctweb/pull/255#discussion_r44190535","pull_request_url":"https://api.github.com/repos/nasa/openmctweb/pulls/255","_links":{"self":{"href":"https://api.github.com/repos/nasa/openmctweb/pulls/comments/44190535"},"html":{"href":"https://github.com/nasa/openmctweb/pull/255#discussion_r44190535"},"pull_request":{"href":"https://api.github.com/repos/nasa/openmctweb/pulls/255"}}},"pull_request":{"url":"https://api.github.com/repos/nasa/openmctweb/pulls/255","id":49901348,"html_url":"https://github.com/nasa/openmctweb/pull/255","diff_url":"https://github.com/nasa/openmctweb/pull/255.diff","patch_url":"https://github.com/nasa/openmctweb/pull/255.patch","issue_url":"https://api.github.com/repos/nasa/openmctweb/issues/255","number":255,"state":"open","locked":false,"title":"[Creation] Add creation capability","user":{"login":"VWoeltjen","id":1685764,"avatar_url":"https://avatars.githubusercontent.com/u/1685764?v=3","gravatar_id":"","url":"https://api.github.com/users/VWoeltjen","html_url":"https://github.com/VWoeltjen","followers_url":"https://api.github.com/users/VWoeltjen/followers","following_url":"https://api.github.com/users/VWoeltjen/following{/other_user}","gists_url":"https://api.github.com/users/VWoeltjen/gists{/gist_id}","starred_url":"https://api.github.com/users/VWoeltjen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VWoeltjen/subscriptions","organizations_url":"https://api.github.com/users/VWoeltjen/orgs","repos_url":"https://api.github.com/users/VWoeltjen/repos","events_url":"https://api.github.com/users/VWoeltjen/events{/privacy}","received_events_url":"https://api.github.com/users/VWoeltjen/received_events","type":"User","site_admin":false},"body":"Add a `creation` capability which can be used to instantiate new domain objects using an existing domain object. Created objects are not persisted nor added to any objects composition, allowing these steps to be handled separately (using the created object's `persistence` and the parent object's `composition` capabilities, respectively), per #215.\r\n\r\nSummary of changes:\r\n* Add `creation` capability, with a `create` method that generates a new DomainObject instance from the provided model.\r\n* Move `uuid` library to core, from commonUI\r\n* Update `creationService` to use this capability, instead of interacting with `persistenceService` directly.\r\n\r\n@akhenry  - as discussed, there's some refactoring to duplicate as implemented in #249 that could use this capability. Hadn't expected to address this so soon, but after evaluating a few strategies believe this will be useful for #245. I see three ways to reconcile this with #249 - I'm fine with any option, let me know which you prefer.\r\n\r\n1. Merge #249 first, then I update this PR to reflect the desired refactoring\r\n2. Merge this PR first, update #249 to use it\r\n3. Handle both separately, file a follow up issue to reconcile (believe this change set will not break changes from #249, so this should be an option.)\r\n\r\nAll else being equal, I'd go with Option 3 to maintain forward progress.\r\n\r\n### Author Checklist\r\n\r\n1. Changes address original issue? Y\r\n2. Unit tests included and/or updated with changes? Y\r\n3. Command line build passes? Y\r\n4. Expect to pass code review? Y","created_at":"2015-11-06T00:27:45Z","updated_at":"2015-11-06T21:39:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"63ff9b40bafbedd13dd3a6ddf11619f21089feaa","assignee":{"login":"akhenry","id":4215777,"avatar_url":"https://avatars.githubusercontent.com/u/4215777?v=3","gravatar_id":"","url":"https://api.github.com/users/akhenry","html_url":"https://github.com/akhenry","followers_url":"https://api.github.com/users/akhenry/followers","following_url":"https://api.github.com/users/akhenry/following{/other_user}","gists_url":"https://api.github.com/users/akhenry/gists{/gist_id}","starred_url":"https://api.github.com/users/akhenry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akhenry/subscriptions","organizations_url":"https://api.github.com/users/akhenry/orgs","repos_url":"https://api.github.com/users/akhenry/repos","events_url":"https://api.github.com/users/akhenry/events{/privacy}","received_events_url":"https://api.github.com/users/akhenry/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/nasa/openmctweb/milestones/3","html_url":"https://github.com/nasa/openmctweb/milestones/Ballard","labels_url":"https://api.github.com/repos/nasa/openmctweb/milestones/3/labels","id":1364443,"number":3,"title":"Ballard","description":"","creator":{"login":"VWoeltjen","id":1685764,"avatar_url":"https://avatars.githubusercontent.com/u/1685764?v=3","gravatar_id":"","url":"https://api.github.com/users/VWoeltjen","html_url":"https://github.com/VWoeltjen","followers_url":"https://api.github.com/users/VWoeltjen/followers","following_url":"https://api.github.com/users/VWoeltjen/following{/other_user}","gists_url":"https://api.github.com/users/VWoeltjen/gists{/gist_id}","starred_url":"https://api.github.com/users/VWoeltjen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VWoeltjen/subscriptions","organizations_url":"https://api.github.com/users/VWoeltjen/orgs","repos_url":"https://api.github.com/users/VWoeltjen/repos","events_url":"https://api.github.com/users/VWoeltjen/events{/privacy}","received_events_url":"https://api.github.com/users/VWoeltjen/received_events","type":"User","site_admin":false},"open_issues":22,"closed_issues":55,"state":"open","created_at":"2015-10-19T17:19:20Z","updated_at":"2015-11-06T21:17:43Z","due_on":"2015-11-06T08:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/nasa/openmctweb/pulls/255/commits","review_comments_url":"https://api.github.com/repos/nasa/openmctweb/pulls/255/comments","review_comment_url":"https://api.github.com/repos/nasa/openmctweb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nasa/openmctweb/issues/255/comments","statuses_url":"https://api.github.com/repos/nasa/openmctweb/statuses/3741a02d2a54bbae314bfa3d65af49a8980628fc","head":{"label":"nasa:open215","ref":"open215","sha":"3741a02d2a54bbae314bfa3d65af49a8980628fc","user":{"login":"nasa","id":848102,"avatar_url":"https://avatars.githubusercontent.com/u/848102?v=3","gravatar_id":"","url":"https://api.github.com/users/nasa","html_url":"https://github.com/nasa","followers_url":"https://api.github.com/users/nasa/followers","following_url":"https://api.github.com/users/nasa/following{/other_user}","gists_url":"https://api.github.com/users/nasa/gists{/gist_id}","starred_url":"https://api.github.com/users/nasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nasa/subscriptions","organizations_url":"https://api.github.com/users/nasa/orgs","repos_url":"https://api.github.com/users/nasa/repos","events_url":"https://api.github.com/users/nasa/events{/privacy}","received_events_url":"https://api.github.com/users/nasa/received_events","type":"Organization","site_admin":false},"repo":{"id":36753839,"name":"openmctweb","full_name":"nasa/openmctweb","owner":{"login":"nasa","id":848102,"avatar_url":"https://avatars.githubusercontent.com/u/848102?v=3","gravatar_id":"","url":"https://api.github.com/users/nasa","html_url":"https://github.com/nasa","followers_url":"https://api.github.com/users/nasa/followers","following_url":"https://api.github.com/users/nasa/following{/other_user}","gists_url":"https://api.github.com/users/nasa/gists{/gist_id}","starred_url":"https://api.github.com/users/nasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nasa/subscriptions","organizations_url":"https://api.github.com/users/nasa/orgs","repos_url":"https://api.github.com/users/nasa/repos","events_url":"https://api.github.com/users/nasa/events{/privacy}","received_events_url":"https://api.github.com/users/nasa/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nasa/openmctweb","description":"","fork":false,"url":"https://api.github.com/repos/nasa/openmctweb","forks_url":"https://api.github.com/repos/nasa/openmctweb/forks","keys_url":"https://api.github.com/repos/nasa/openmctweb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nasa/openmctweb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nasa/openmctweb/teams","hooks_url":"https://api.github.com/repos/nasa/openmctweb/hooks","issue_events_url":"https://api.github.com/repos/nasa/openmctweb/issues/events{/number}","events_url":"https://api.github.com/repos/nasa/openmctweb/events","assignees_url":"https://api.github.com/repos/nasa/openmctweb/assignees{/user}","branches_url":"https://api.github.com/repos/nasa/openmctweb/branches{/branch}","tags_url":"https://api.github.com/repos/nasa/openmctweb/tags","blobs_url":"https://api.github.com/repos/nasa/openmctweb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nasa/openmctweb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nasa/openmctweb/git/refs{/sha}","trees_url":"https://api.github.com/repos/nasa/openmctweb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nasa/openmctweb/statuses/{sha}","languages_url":"https://api.github.com/repos/nasa/openmctweb/languages","stargazers_url":"https://api.github.com/repos/nasa/openmctweb/stargazers","contributors_url":"https://api.github.com/repos/nasa/openmctweb/contributors","subscribers_url":"https://api.github.com/repos/nasa/openmctweb/subscribers","subscription_url":"https://api.github.com/repos/nasa/openmctweb/subscription","commits_url":"https://api.github.com/repos/nasa/openmctweb/commits{/sha}","git_commits_url":"https://api.github.com/repos/nasa/openmctweb/git/commits{/sha}","comments_url":"https://api.github.com/repos/nasa/openmctweb/comments{/number}","issue_comment_url":"https://api.github.com/repos/nasa/openmctweb/issues/comments{/number}","contents_url":"https://api.github.com/repos/nasa/openmctweb/contents/{+path}","compare_url":"https://api.github.com/repos/nasa/openmctweb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nasa/openmctweb/merges","archive_url":"https://api.github.com/repos/nasa/openmctweb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nasa/openmctweb/downloads","issues_url":"https://api.github.com/repos/nasa/openmctweb/issues{/number}","pulls_url":"https://api.github.com/repos/nasa/openmctweb/pulls{/number}","milestones_url":"https://api.github.com/repos/nasa/openmctweb/milestones{/number}","notifications_url":"https://api.github.com/repos/nasa/openmctweb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nasa/openmctweb/labels{/name}","releases_url":"https://api.github.com/repos/nasa/openmctweb/releases{/id}","created_at":"2015-06-02T18:40:28Z","updated_at":"2015-11-04T18:21:40Z","pushed_at":"2015-11-06T19:01:07Z","git_url":"git://github.com/nasa/openmctweb.git","ssh_url":"git@github.com:nasa/openmctweb.git","clone_url":"https://github.com/nasa/openmctweb.git","svn_url":"https://github.com/nasa/openmctweb","homepage":"","size":11694,"stargazers_count":28,"watchers_count":28,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":101,"forks":10,"open_issues":101,"watchers":28,"default_branch":"master"}},"base":{"label":"nasa:master","ref":"master","sha":"92cf86837b8b5832c7983e89fd0a0b6f4905d555","user":{"login":"nasa","id":848102,"avatar_url":"https://avatars.githubusercontent.com/u/848102?v=3","gravatar_id":"","url":"https://api.github.com/users/nasa","html_url":"https://github.com/nasa","followers_url":"https://api.github.com/users/nasa/followers","following_url":"https://api.github.com/users/nasa/following{/other_user}","gists_url":"https://api.github.com/users/nasa/gists{/gist_id}","starred_url":"https://api.github.com/users/nasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nasa/subscriptions","organizations_url":"https://api.github.com/users/nasa/orgs","repos_url":"https://api.github.com/users/nasa/repos","events_url":"https://api.github.com/users/nasa/events{/privacy}","received_events_url":"https://api.github.com/users/nasa/received_events","type":"Organization","site_admin":false},"repo":{"id":36753839,"name":"openmctweb","full_name":"nasa/openmctweb","owner":{"login":"nasa","id":848102,"avatar_url":"https://avatars.githubusercontent.com/u/848102?v=3","gravatar_id":"","url":"https://api.github.com/users/nasa","html_url":"https://github.com/nasa","followers_url":"https://api.github.com/users/nasa/followers","following_url":"https://api.github.com/users/nasa/following{/other_user}","gists_url":"https://api.github.com/users/nasa/gists{/gist_id}","starred_url":"https://api.github.com/users/nasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nasa/subscriptions","organizations_url":"https://api.github.com/users/nasa/orgs","repos_url":"https://api.github.com/users/nasa/repos","events_url":"https://api.github.com/users/nasa/events{/privacy}","received_events_url":"https://api.github.com/users/nasa/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nasa/openmctweb","description":"","fork":false,"url":"https://api.github.com/repos/nasa/openmctweb","forks_url":"https://api.github.com/repos/nasa/openmctweb/forks","keys_url":"https://api.github.com/repos/nasa/openmctweb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nasa/openmctweb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nasa/openmctweb/teams","hooks_url":"https://api.github.com/repos/nasa/openmctweb/hooks","issue_events_url":"https://api.github.com/repos/nasa/openmctweb/issues/events{/number}","events_url":"https://api.github.com/repos/nasa/openmctweb/events","assignees_url":"https://api.github.com/repos/nasa/openmctweb/assignees{/user}","branches_url":"https://api.github.com/repos/nasa/openmctweb/branches{/branch}","tags_url":"https://api.github.com/repos/nasa/openmctweb/tags","blobs_url":"https://api.github.com/repos/nasa/openmctweb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nasa/openmctweb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nasa/openmctweb/git/refs{/sha}","trees_url":"https://api.github.com/repos/nasa/openmctweb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nasa/openmctweb/statuses/{sha}","languages_url":"https://api.github.com/repos/nasa/openmctweb/languages","stargazers_url":"https://api.github.com/repos/nasa/openmctweb/stargazers","contributors_url":"https://api.github.com/repos/nasa/openmctweb/contributors","subscribers_url":"https://api.github.com/repos/nasa/openmctweb/subscribers","subscription_url":"https://api.github.com/repos/nasa/openmctweb/subscription","commits_url":"https://api.github.com/repos/nasa/openmctweb/commits{/sha}","git_commits_url":"https://api.github.com/repos/nasa/openmctweb/git/commits{/sha}","comments_url":"https://api.github.com/repos/nasa/openmctweb/comments{/number}","issue_comment_url":"https://api.github.com/repos/nasa/openmctweb/issues/comments{/number}","contents_url":"https://api.github.com/repos/nasa/openmctweb/contents/{+path}","compare_url":"https://api.github.com/repos/nasa/openmctweb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nasa/openmctweb/merges","archive_url":"https://api.github.com/repos/nasa/openmctweb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nasa/openmctweb/downloads","issues_url":"https://api.github.com/repos/nasa/openmctweb/issues{/number}","pulls_url":"https://api.github.com/repos/nasa/openmctweb/pulls{/number}","milestones_url":"https://api.github.com/repos/nasa/openmctweb/milestones{/number}","notifications_url":"https://api.github.com/repos/nasa/openmctweb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nasa/openmctweb/labels{/name}","releases_url":"https://api.github.com/repos/nasa/openmctweb/releases{/id}","created_at":"2015-06-02T18:40:28Z","updated_at":"2015-11-04T18:21:40Z","pushed_at":"2015-11-06T19:01:07Z","git_url":"git://github.com/nasa/openmctweb.git","ssh_url":"git@github.com:nasa/openmctweb.git","clone_url":"https://github.com/nasa/openmctweb.git","svn_url":"https://github.com/nasa/openmctweb","homepage":"","size":11694,"stargazers_count":28,"watchers_count":28,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":101,"forks":10,"open_issues":101,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nasa/openmctweb/pulls/255"},"html":{"href":"https://github.com/nasa/openmctweb/pull/255"},"issue":{"href":"https://api.github.com/repos/nasa/openmctweb/issues/255"},"comments":{"href":"https://api.github.com/repos/nasa/openmctweb/issues/255/comments"},"review_comments":{"href":"https://api.github.com/repos/nasa/openmctweb/pulls/255/comments"},"review_comment":{"href":"https://api.github.com/repos/nasa/openmctweb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nasa/openmctweb/pulls/255/commits"},"statuses":{"href":"https://api.github.com/repos/nasa/openmctweb/statuses/3741a02d2a54bbae314bfa3d65af49a8980628fc"}}}}