{"action":"created","comment":{"url":"https://api.github.com/repos/swalker2m/ocs/pulls/comments/53204482","id":53204482,"diff_hunk":"@@ -80,34 +83,25 @@ object AgsStrategy {\n    * results are valid along with all assignments of guide probes to stars.\n    */\n   case class Selection(posAngle: Angle, assignments: List[Assignment]) {\n-\n     /**\n      * Creates a new TargetEnvironment with guide stars for each assignment in\n      * the Selection.\n      */\n     def applyTo(env: TargetEnvironment): TargetEnvironment = {\n-      def findMatching(gpt: GuideProbeTargets, target: SPTarget): Option[SPTarget] = {\n-        def name(t: SPTarget): Option[String] =\n-          Option(t.getTarget.getName).map(_.trim)\n-\n-        name(target).flatMap(n => gpt.getTargets.asScalaList.find(name(_).exists(_ == n)))\n-      }\n-\n-      (env /: assignments) { (curEnv, ass) =>\n-        val target = new SPTarget(HmsDegTarget.fromSkyObject(ass.guideStar.toOldModel))\n-        val oldGpt = curEnv.getPrimaryGuideProbeTargets(ass.guideProbe).asScalaOpt\n-\n-        val newGpt = oldGpt.fold(GuideProbeTargets.create(ass.guideProbe, target)) { gpt =>\n-          // We already have guide probe targets for guide probe.\n-          // Does one with the same target name already exist? If so, mark it as\n-          // primary and replace it with the target we just made.  If not, add the\n-          // target and mark it as primary.\n-          findMatching(gpt, target).fold(gpt.update(OptionsList.UpdateOps.appendAsPrimary(target))) { existing =>\n-            gpt.selectPrimary(existing).setPrimary(target)\n-          }\n-        }\n-\n-        curEnv.putPrimaryGuideProbeTargets(newGpt)\n+      val targetMap = ==>>.fromList(assignments.map { case Assignment(gp,gs) =>\n+        gp -> new SPTarget(HmsDegTarget.fromSkyObject(gs.toOldModel))})\n+      val newAuto: AutomaticGroup = AutomaticGroup.Active(targetMap)\n+\n+      // If this is different from the old automatic GG, then replace.\n+      val oldGuideEnvironment = env.getGuideEnvironment\n+      val oldGuideEnv         = oldGuideEnvironment.guideEnv\n+\n+      if (oldGuideEnv.auto =/= newAuto) {","path":"bundle/edu.gemini.ags/src/main/scala/edu/gemini/ags/api/AgsStrategy.scala","position":56,"original_position":56,"commit_id":"7d08c82329ebc5d988c21ce34725c7067e31cf0c","original_commit_id":"c28194fc79d2919dde5f66ddd1e826be557a1014","user":{"login":"swalker2m","id":4906023,"avatar_url":"https://avatars.githubusercontent.com/u/4906023?v=3","gravatar_id":"","url":"https://api.github.com/users/swalker2m","html_url":"https://github.com/swalker2m","followers_url":"https://api.github.com/users/swalker2m/followers","following_url":"https://api.github.com/users/swalker2m/following{/other_user}","gists_url":"https://api.github.com/users/swalker2m/gists{/gist_id}","starred_url":"https://api.github.com/users/swalker2m/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swalker2m/subscriptions","organizations_url":"https://api.github.com/users/swalker2m/orgs","repos_url":"https://api.github.com/users/swalker2m/repos","events_url":"https://api.github.com/users/swalker2m/events{/privacy}","received_events_url":"https://api.github.com/users/swalker2m/received_events","type":"User","site_admin":false},"body":"That's a good point.  You can't edit auto targets via the UI.  It doesn't *feel* that satisfying though since you can certainly edit them programatically.  Still, checking the name might be the best option for now.  Once the `SPTarget` holds a mutable reference to an immutable `Target`, then we could just directly compare the `Target` references.  Alternatively today we'd need to do something like we do in the `AlmostEquals` implementation for `SPTarget` and compare them field-by-field.  I guess let's just go with the name check.","created_at":"2016-02-17T18:03:17Z","updated_at":"2016-02-17T18:03:17Z","html_url":"https://github.com/swalker2m/ocs/pull/3#discussion_r53204482","pull_request_url":"https://api.github.com/repos/swalker2m/ocs/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/swalker2m/ocs/pulls/comments/53204482"},"html":{"href":"https://github.com/swalker2m/ocs/pull/3#discussion_r53204482"},"pull_request":{"href":"https://api.github.com/repos/swalker2m/ocs/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/swalker2m/ocs/pulls/3","id":58665518,"html_url":"https://github.com/swalker2m/ocs/pull/3","diff_url":"https://github.com/swalker2m/ocs/pull/3.diff","patch_url":"https://github.com/swalker2m/ocs/pull/3.patch","issue_url":"https://api.github.com/repos/swalker2m/ocs/issues/3","number":3,"state":"open","locked":false,"title":"OCSADV-517: Getting the target editor AGS button and other target editor components working with the new data model","user":{"login":"sraaphorst","id":8795653,"avatar_url":"https://avatars.githubusercontent.com/u/8795653?v=3","gravatar_id":"","url":"https://api.github.com/users/sraaphorst","html_url":"https://github.com/sraaphorst","followers_url":"https://api.github.com/users/sraaphorst/followers","following_url":"https://api.github.com/users/sraaphorst/following{/other_user}","gists_url":"https://api.github.com/users/sraaphorst/gists{/gist_id}","starred_url":"https://api.github.com/users/sraaphorst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sraaphorst/subscriptions","organizations_url":"https://api.github.com/users/sraaphorst/orgs","repos_url":"https://api.github.com/users/sraaphorst/repos","events_url":"https://api.github.com/users/sraaphorst/events{/privacy}","received_events_url":"https://api.github.com/users/sraaphorst/received_events","type":"User","site_admin":false},"body":"Alright, here is the big PR of all the work I've been doing to get the target editor, TPE, etc. working with the new data model.\r\n\r\nI think @swalker2m, you already know the majority of the content, and it would be too long to type up much here in great detail, so I will let you ask questions if needed.\r\n\r\nA few notes:\r\n= Addition of a Java `Either` class and converters. (Could probably use some test cases. I'll add this tomorrow.)\r\n= Change `EdCompTargetList` and the contained clipboard to use `Either`.\r\n= Added an `IndexedGuideGroup` to not have to use the horrific `Tuple2<Integer,GuideGroup>` everywhere, which was just ugly.\r\n= AGS button works now for GeMS and single probe strategies.\r\n= TPE erase and add guide star buttons are greyed out if the auto group is the primary.\r\n= Target editor remove / primary buttons and add guide star menu options are greyed out as they should be (depending on current selection). Auto group guide stars are always primary.\r\n= Everything seems to work harmoniously with the new model now.\r\n\r\nI think that's essentially a summary of most of what this covers.","created_at":"2016-02-08T20:54:55Z","updated_at":"2016-02-17T18:03:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fa73f536c76cd1e7c5329c4993ccfd518a06ff02","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/swalker2m/ocs/pulls/3/commits","review_comments_url":"https://api.github.com/repos/swalker2m/ocs/pulls/3/comments","review_comment_url":"https://api.github.com/repos/swalker2m/ocs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/swalker2m/ocs/issues/3/comments","statuses_url":"https://api.github.com/repos/swalker2m/ocs/statuses/7d08c82329ebc5d988c21ce34725c7067e31cf0c","head":{"label":"sraaphorst:feature/OCSADV-517","ref":"feature/OCSADV-517","sha":"7d08c82329ebc5d988c21ce34725c7067e31cf0c","user":{"login":"sraaphorst","id":8795653,"avatar_url":"https://avatars.githubusercontent.com/u/8795653?v=3","gravatar_id":"","url":"https://api.github.com/users/sraaphorst","html_url":"https://github.com/sraaphorst","followers_url":"https://api.github.com/users/sraaphorst/followers","following_url":"https://api.github.com/users/sraaphorst/following{/other_user}","gists_url":"https://api.github.com/users/sraaphorst/gists{/gist_id}","starred_url":"https://api.github.com/users/sraaphorst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sraaphorst/subscriptions","organizations_url":"https://api.github.com/users/sraaphorst/orgs","repos_url":"https://api.github.com/users/sraaphorst/repos","events_url":"https://api.github.com/users/sraaphorst/events{/privacy}","received_events_url":"https://api.github.com/users/sraaphorst/received_events","type":"User","site_admin":false},"repo":{"id":24112855,"name":"ocs","full_name":"sraaphorst/ocs","owner":{"login":"sraaphorst","id":8795653,"avatar_url":"https://avatars.githubusercontent.com/u/8795653?v=3","gravatar_id":"","url":"https://api.github.com/users/sraaphorst","html_url":"https://github.com/sraaphorst","followers_url":"https://api.github.com/users/sraaphorst/followers","following_url":"https://api.github.com/users/sraaphorst/following{/other_user}","gists_url":"https://api.github.com/users/sraaphorst/gists{/gist_id}","starred_url":"https://api.github.com/users/sraaphorst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sraaphorst/subscriptions","organizations_url":"https://api.github.com/users/sraaphorst/orgs","repos_url":"https://api.github.com/users/sraaphorst/repos","events_url":"https://api.github.com/users/sraaphorst/events{/privacy}","received_events_url":"https://api.github.com/users/sraaphorst/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sraaphorst/ocs","description":"","fork":true,"url":"https://api.github.com/repos/sraaphorst/ocs","forks_url":"https://api.github.com/repos/sraaphorst/ocs/forks","keys_url":"https://api.github.com/repos/sraaphorst/ocs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sraaphorst/ocs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sraaphorst/ocs/teams","hooks_url":"https://api.github.com/repos/sraaphorst/ocs/hooks","issue_events_url":"https://api.github.com/repos/sraaphorst/ocs/issues/events{/number}","events_url":"https://api.github.com/repos/sraaphorst/ocs/events","assignees_url":"https://api.github.com/repos/sraaphorst/ocs/assignees{/user}","branches_url":"https://api.github.com/repos/sraaphorst/ocs/branches{/branch}","tags_url":"https://api.github.com/repos/sraaphorst/ocs/tags","blobs_url":"https://api.github.com/repos/sraaphorst/ocs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sraaphorst/ocs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sraaphorst/ocs/git/refs{/sha}","trees_url":"https://api.github.com/repos/sraaphorst/ocs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sraaphorst/ocs/statuses/{sha}","languages_url":"https://api.github.com/repos/sraaphorst/ocs/languages","stargazers_url":"https://api.github.com/repos/sraaphorst/ocs/stargazers","contributors_url":"https://api.github.com/repos/sraaphorst/ocs/contributors","subscribers_url":"https://api.github.com/repos/sraaphorst/ocs/subscribers","subscription_url":"https://api.github.com/repos/sraaphorst/ocs/subscription","commits_url":"https://api.github.com/repos/sraaphorst/ocs/commits{/sha}","git_commits_url":"https://api.github.com/repos/sraaphorst/ocs/git/commits{/sha}","comments_url":"https://api.github.com/repos/sraaphorst/ocs/comments{/number}","issue_comment_url":"https://api.github.com/repos/sraaphorst/ocs/issues/comments{/number}","contents_url":"https://api.github.com/repos/sraaphorst/ocs/contents/{+path}","compare_url":"https://api.github.com/repos/sraaphorst/ocs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sraaphorst/ocs/merges","archive_url":"https://api.github.com/repos/sraaphorst/ocs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sraaphorst/ocs/downloads","issues_url":"https://api.github.com/repos/sraaphorst/ocs/issues{/number}","pulls_url":"https://api.github.com/repos/sraaphorst/ocs/pulls{/number}","milestones_url":"https://api.github.com/repos/sraaphorst/ocs/milestones{/number}","notifications_url":"https://api.github.com/repos/sraaphorst/ocs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sraaphorst/ocs/labels{/name}","releases_url":"https://api.github.com/repos/sraaphorst/ocs/releases{/id}","deployments_url":"https://api.github.com/repos/sraaphorst/ocs/deployments","created_at":"2014-09-16T18:48:19Z","updated_at":"2016-01-11T14:32:59Z","pushed_at":"2016-02-17T17:17:06Z","git_url":"git://github.com/sraaphorst/ocs.git","ssh_url":"git@github.com:sraaphorst/ocs.git","clone_url":"https://github.com/sraaphorst/ocs.git","svn_url":"https://github.com/sraaphorst/ocs","homepage":null,"size":324409,"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":"develop"}},"base":{"label":"swalker2m:feature/OCSADV-514","ref":"feature/OCSADV-514","sha":"3d5ca1d2fc34fa1d6645056bd9d013c3e6596b9f","user":{"login":"swalker2m","id":4906023,"avatar_url":"https://avatars.githubusercontent.com/u/4906023?v=3","gravatar_id":"","url":"https://api.github.com/users/swalker2m","html_url":"https://github.com/swalker2m","followers_url":"https://api.github.com/users/swalker2m/followers","following_url":"https://api.github.com/users/swalker2m/following{/other_user}","gists_url":"https://api.github.com/users/swalker2m/gists{/gist_id}","starred_url":"https://api.github.com/users/swalker2m/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swalker2m/subscriptions","organizations_url":"https://api.github.com/users/swalker2m/orgs","repos_url":"https://api.github.com/users/swalker2m/repos","events_url":"https://api.github.com/users/swalker2m/events{/privacy}","received_events_url":"https://api.github.com/users/swalker2m/received_events","type":"User","site_admin":false},"repo":{"id":23966397,"name":"ocs","full_name":"swalker2m/ocs","owner":{"login":"swalker2m","id":4906023,"avatar_url":"https://avatars.githubusercontent.com/u/4906023?v=3","gravatar_id":"","url":"https://api.github.com/users/swalker2m","html_url":"https://github.com/swalker2m","followers_url":"https://api.github.com/users/swalker2m/followers","following_url":"https://api.github.com/users/swalker2m/following{/other_user}","gists_url":"https://api.github.com/users/swalker2m/gists{/gist_id}","starred_url":"https://api.github.com/users/swalker2m/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swalker2m/subscriptions","organizations_url":"https://api.github.com/users/swalker2m/orgs","repos_url":"https://api.github.com/users/swalker2m/repos","events_url":"https://api.github.com/users/swalker2m/events{/privacy}","received_events_url":"https://api.github.com/users/swalker2m/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/swalker2m/ocs","description":"","fork":true,"url":"https://api.github.com/repos/swalker2m/ocs","forks_url":"https://api.github.com/repos/swalker2m/ocs/forks","keys_url":"https://api.github.com/repos/swalker2m/ocs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/swalker2m/ocs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/swalker2m/ocs/teams","hooks_url":"https://api.github.com/repos/swalker2m/ocs/hooks","issue_events_url":"https://api.github.com/repos/swalker2m/ocs/issues/events{/number}","events_url":"https://api.github.com/repos/swalker2m/ocs/events","assignees_url":"https://api.github.com/repos/swalker2m/ocs/assignees{/user}","branches_url":"https://api.github.com/repos/swalker2m/ocs/branches{/branch}","tags_url":"https://api.github.com/repos/swalker2m/ocs/tags","blobs_url":"https://api.github.com/repos/swalker2m/ocs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/swalker2m/ocs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/swalker2m/ocs/git/refs{/sha}","trees_url":"https://api.github.com/repos/swalker2m/ocs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/swalker2m/ocs/statuses/{sha}","languages_url":"https://api.github.com/repos/swalker2m/ocs/languages","stargazers_url":"https://api.github.com/repos/swalker2m/ocs/stargazers","contributors_url":"https://api.github.com/repos/swalker2m/ocs/contributors","subscribers_url":"https://api.github.com/repos/swalker2m/ocs/subscribers","subscription_url":"https://api.github.com/repos/swalker2m/ocs/subscription","commits_url":"https://api.github.com/repos/swalker2m/ocs/commits{/sha}","git_commits_url":"https://api.github.com/repos/swalker2m/ocs/git/commits{/sha}","comments_url":"https://api.github.com/repos/swalker2m/ocs/comments{/number}","issue_comment_url":"https://api.github.com/repos/swalker2m/ocs/issues/comments{/number}","contents_url":"https://api.github.com/repos/swalker2m/ocs/contents/{+path}","compare_url":"https://api.github.com/repos/swalker2m/ocs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/swalker2m/ocs/merges","archive_url":"https://api.github.com/repos/swalker2m/ocs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/swalker2m/ocs/downloads","issues_url":"https://api.github.com/repos/swalker2m/ocs/issues{/number}","pulls_url":"https://api.github.com/repos/swalker2m/ocs/pulls{/number}","milestones_url":"https://api.github.com/repos/swalker2m/ocs/milestones{/number}","notifications_url":"https://api.github.com/repos/swalker2m/ocs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/swalker2m/ocs/labels{/name}","releases_url":"https://api.github.com/repos/swalker2m/ocs/releases{/id}","deployments_url":"https://api.github.com/repos/swalker2m/ocs/deployments","created_at":"2014-09-12T15:41:27Z","updated_at":"2016-01-18T13:43:15Z","pushed_at":"2016-02-17T17:17:07Z","git_url":"git://github.com/swalker2m/ocs.git","ssh_url":"git@github.com:swalker2m/ocs.git","clone_url":"https://github.com/swalker2m/ocs.git","svn_url":"https://github.com/swalker2m/ocs","homepage":null,"size":324403,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/swalker2m/ocs/pulls/3"},"html":{"href":"https://github.com/swalker2m/ocs/pull/3"},"issue":{"href":"https://api.github.com/repos/swalker2m/ocs/issues/3"},"comments":{"href":"https://api.github.com/repos/swalker2m/ocs/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/swalker2m/ocs/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/swalker2m/ocs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/swalker2m/ocs/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/swalker2m/ocs/statuses/7d08c82329ebc5d988c21ce34725c7067e31cf0c"}}}}