{"action":"created","comment":{"url":"https://api.github.com/repos/codice/ddf/pulls/comments/87686192","pull_request_review_id":8292405,"id":87686192,"diff_hunk":"@@ -0,0 +1,104 @@\n+/**\n+ * Copyright (c) Codice Foundation\n+ * <p>\n+ * This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser\n+ * General Public License as published by the Free Software Foundation, either version 3 of the\n+ * License, or any later version.\n+ * <p>\n+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\n+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ * Lesser General Public License for more details. A copy of the GNU Lesser General Public License\n+ * is distributed along with this program and can be found at\n+ * <http://www.gnu.org/licenses/lgpl.html>.\n+ */\n+package org.codice.ddf.catalog.plugin.metacard.util;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.Objects;\n+import java.util.Set;\n+import java.util.function.Function;\n+import java.util.stream.Collectors;\n+import java.util.stream.Stream;\n+\n+import com.google.common.collect.ImmutableList;\n+\n+import ddf.catalog.data.AttributeDescriptor;\n+import ddf.catalog.data.Metacard;\n+import ddf.catalog.data.MetacardType;\n+\n+/**\n+ * Support and bulk operations for {@link Metacard}s. Contains state relevant to the provided\n+ * services.\n+ */\n+public class MetacardServices {\n+\n+    private final List<MetacardType> systemMetacardTypes;\n+\n+    /**\n+     * Initializes the services with an empty list of system {@link MetacardType}s.\n+     */\n+    public MetacardServices() {\n+        this.systemMetacardTypes = new ArrayList<>();\n+    }\n+\n+    /**\n+     * Initializes the services with the provided list of {@link MetacardType}s.\n+     *\n+     * @param systemMetacardTypes The list of metacard types to use.\n+     */\n+    public MetacardServices(List<MetacardType> systemMetacardTypes) {\n+        this.systemMetacardTypes = systemMetacardTypes;\n+    }\n+\n+    /**\n+     * Iterates over each {@link Metacard} in the {@param metacards} collection and applies each\n+     * attribute in the {@param attributeMap} only if the attribute is not already set on the\n+     * {@link Metacard}. That is, the attribute must be {@code null} or not in the {@link Metacard}'s\n+     * map.\n+     *\n+     * @param metacards        The list of metacards to attempt to add the attributes to.\n+     * @param attributeMap     The map of attributes to attempt to add. Attributes already set on any\n+     *                         given {@link Metacard} will not be changed. For multi-valued attributes,\n+     *                         the value string should separate different entities with commas.\n+     * @param attributeFactory The factory to use to create attributes.\n+     */\n+    public void setAttributesIfAbsent(List<Metacard> metacards, Map<String, String> attributeMap,\n+            AttributeFactory attributeFactory) {\n+","path":"catalog/plugin/catalog-plugin-metacardingest-network/src/main/java/org/codice/ddf/catalog/plugin/metacard/util/MetacardServices.java","position":69,"original_position":69,"commit_id":"473894b094b784f4b3e6366c767fecd2a46c6625","original_commit_id":"473894b094b784f4b3e6366c767fecd2a46c6625","user":{"login":"Lambeaux","id":7215534,"avatar_url":"https://avatars.githubusercontent.com/u/7215534?v=3","gravatar_id":"","url":"https://api.github.com/users/Lambeaux","html_url":"https://github.com/Lambeaux","followers_url":"https://api.github.com/users/Lambeaux/followers","following_url":"https://api.github.com/users/Lambeaux/following{/other_user}","gists_url":"https://api.github.com/users/Lambeaux/gists{/gist_id}","starred_url":"https://api.github.com/users/Lambeaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lambeaux/subscriptions","organizations_url":"https://api.github.com/users/Lambeaux/orgs","repos_url":"https://api.github.com/users/Lambeaux/repos","events_url":"https://api.github.com/users/Lambeaux/events{/privacy}","received_events_url":"https://api.github.com/users/Lambeaux/received_events","type":"User","site_admin":false},"body":"Going to punt on this one until this code gets moved into a more common-area. ","created_at":"2016-11-12T04:07:24Z","updated_at":"2016-11-12T04:07:24Z","html_url":"https://github.com/codice/ddf/pull/1401#discussion_r87686192","pull_request_url":"https://api.github.com/repos/codice/ddf/pulls/1401","_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments/87686192"},"html":{"href":"https://github.com/codice/ddf/pull/1401#discussion_r87686192"},"pull_request":{"href":"https://api.github.com/repos/codice/ddf/pulls/1401"}}},"pull_request":{"url":"https://api.github.com/repos/codice/ddf/pulls/1401","id":92259117,"html_url":"https://github.com/codice/ddf/pull/1401","diff_url":"https://github.com/codice/ddf/pull/1401.diff","patch_url":"https://github.com/codice/ddf/pull/1401.patch","issue_url":"https://api.github.com/repos/codice/ddf/issues/1401","number":1401,"state":"open","locked":false,"title":"DDF-2502: Added an AttributeHelper for creating new attributes on metacards","user":{"login":"Lambeaux","id":7215534,"avatar_url":"https://avatars.githubusercontent.com/u/7215534?v=3","gravatar_id":"","url":"https://api.github.com/users/Lambeaux","html_url":"https://github.com/Lambeaux","followers_url":"https://api.github.com/users/Lambeaux/followers","following_url":"https://api.github.com/users/Lambeaux/following{/other_user}","gists_url":"https://api.github.com/users/Lambeaux/gists{/gist_id}","starred_url":"https://api.github.com/users/Lambeaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lambeaux/subscriptions","organizations_url":"https://api.github.com/users/Lambeaux/orgs","repos_url":"https://api.github.com/users/Lambeaux/repos","events_url":"https://api.github.com/users/Lambeaux/events{/privacy}","received_events_url":"https://api.github.com/users/Lambeaux/received_events","type":"User","site_admin":false},"body":"#### What does this PR do?\r\nProvides a helper class for the core ticket. This one in particular is for adding attributes to metacards, performing correct attribute processing from string values, and iterating over the system's published `MetacardType`s. \r\n\r\nAttributes already set are not overwritten.\r\n\r\nIf context is desired for how this will be used, see the [massive, feature complete PR](https://github.com/codice/ddf/pull/1353) for all the code. \r\n\r\n#### Who is reviewing it (please choose AT LEAST two reviewers that need to approve the PR before it can get merged)?\r\n@lessarderic \r\n@figliold \r\n@shaundmorris \r\n@brjeter \r\n\r\n#### Select at least one member from relevant component team(s) from below (at least one component team member needs to approve the PR).\r\n[Security](https://github.com/orgs/codice/teams/security)\r\n\r\n#### Choose 2 committers to review/merge the PR (please choose ONLY two committers from below, delete the rest).\r\n@pklinef \r\n@stustison\r\n\r\n#### How should this be tested? (List steps with links to updated documentation)\r\nIf unit tests pass, along with the full build, this is sufficient for now. \r\n\r\n#### Any background context you want to provide?\r\nThis is a small piece of a much bigger change-set that will allow admins to add attributes to metacards based on the originating IP, hostname, scheme, or context path. \r\n\r\n#### What are the relevant tickets?\r\n[DDF-2502](https://codice.atlassian.net/browse/DDF-2502)","created_at":"2016-11-03T23:20:41Z","updated_at":"2016-11-12T04:07:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"66773d0e0484f2db6b037c2e477603092467765a","assignee":{"login":"pklinef","id":700518,"avatar_url":"https://avatars.githubusercontent.com/u/700518?v=3","gravatar_id":"","url":"https://api.github.com/users/pklinef","html_url":"https://github.com/pklinef","followers_url":"https://api.github.com/users/pklinef/followers","following_url":"https://api.github.com/users/pklinef/following{/other_user}","gists_url":"https://api.github.com/users/pklinef/gists{/gist_id}","starred_url":"https://api.github.com/users/pklinef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pklinef/subscriptions","organizations_url":"https://api.github.com/users/pklinef/orgs","repos_url":"https://api.github.com/users/pklinef/repos","events_url":"https://api.github.com/users/pklinef/events{/privacy}","received_events_url":"https://api.github.com/users/pklinef/received_events","type":"User","site_admin":false},"assignees":[{"login":"pklinef","id":700518,"avatar_url":"https://avatars.githubusercontent.com/u/700518?v=3","gravatar_id":"","url":"https://api.github.com/users/pklinef","html_url":"https://github.com/pklinef","followers_url":"https://api.github.com/users/pklinef/followers","following_url":"https://api.github.com/users/pklinef/following{/other_user}","gists_url":"https://api.github.com/users/pklinef/gists{/gist_id}","starred_url":"https://api.github.com/users/pklinef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pklinef/subscriptions","organizations_url":"https://api.github.com/users/pklinef/orgs","repos_url":"https://api.github.com/users/pklinef/repos","events_url":"https://api.github.com/users/pklinef/events{/privacy}","received_events_url":"https://api.github.com/users/pklinef/received_events","type":"User","site_admin":false},{"login":"stustison","id":4391679,"avatar_url":"https://avatars.githubusercontent.com/u/4391679?v=3","gravatar_id":"","url":"https://api.github.com/users/stustison","html_url":"https://github.com/stustison","followers_url":"https://api.github.com/users/stustison/followers","following_url":"https://api.github.com/users/stustison/following{/other_user}","gists_url":"https://api.github.com/users/stustison/gists{/gist_id}","starred_url":"https://api.github.com/users/stustison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stustison/subscriptions","organizations_url":"https://api.github.com/users/stustison/orgs","repos_url":"https://api.github.com/users/stustison/repos","events_url":"https://api.github.com/users/stustison/events{/privacy}","received_events_url":"https://api.github.com/users/stustison/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/codice/ddf/pulls/1401/commits","review_comments_url":"https://api.github.com/repos/codice/ddf/pulls/1401/comments","review_comment_url":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codice/ddf/issues/1401/comments","statuses_url":"https://api.github.com/repos/codice/ddf/statuses/473894b094b784f4b3e6366c767fecd2a46c6625","head":{"label":"Lambeaux:DDF-2502-AttributeHelper","ref":"DDF-2502-AttributeHelper","sha":"473894b094b784f4b3e6366c767fecd2a46c6625","user":{"login":"Lambeaux","id":7215534,"avatar_url":"https://avatars.githubusercontent.com/u/7215534?v=3","gravatar_id":"","url":"https://api.github.com/users/Lambeaux","html_url":"https://github.com/Lambeaux","followers_url":"https://api.github.com/users/Lambeaux/followers","following_url":"https://api.github.com/users/Lambeaux/following{/other_user}","gists_url":"https://api.github.com/users/Lambeaux/gists{/gist_id}","starred_url":"https://api.github.com/users/Lambeaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lambeaux/subscriptions","organizations_url":"https://api.github.com/users/Lambeaux/orgs","repos_url":"https://api.github.com/users/Lambeaux/repos","events_url":"https://api.github.com/users/Lambeaux/events{/privacy}","received_events_url":"https://api.github.com/users/Lambeaux/received_events","type":"User","site_admin":false},"repo":{"id":47577497,"name":"ddf","full_name":"Lambeaux/ddf","owner":{"login":"Lambeaux","id":7215534,"avatar_url":"https://avatars.githubusercontent.com/u/7215534?v=3","gravatar_id":"","url":"https://api.github.com/users/Lambeaux","html_url":"https://github.com/Lambeaux","followers_url":"https://api.github.com/users/Lambeaux/followers","following_url":"https://api.github.com/users/Lambeaux/following{/other_user}","gists_url":"https://api.github.com/users/Lambeaux/gists{/gist_id}","starred_url":"https://api.github.com/users/Lambeaux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lambeaux/subscriptions","organizations_url":"https://api.github.com/users/Lambeaux/orgs","repos_url":"https://api.github.com/users/Lambeaux/repos","events_url":"https://api.github.com/users/Lambeaux/events{/privacy}","received_events_url":"https://api.github.com/users/Lambeaux/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Lambeaux/ddf","description":"The Distributed Data Framework - Distribution, SDK, and Test","fork":true,"url":"https://api.github.com/repos/Lambeaux/ddf","forks_url":"https://api.github.com/repos/Lambeaux/ddf/forks","keys_url":"https://api.github.com/repos/Lambeaux/ddf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Lambeaux/ddf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Lambeaux/ddf/teams","hooks_url":"https://api.github.com/repos/Lambeaux/ddf/hooks","issue_events_url":"https://api.github.com/repos/Lambeaux/ddf/issues/events{/number}","events_url":"https://api.github.com/repos/Lambeaux/ddf/events","assignees_url":"https://api.github.com/repos/Lambeaux/ddf/assignees{/user}","branches_url":"https://api.github.com/repos/Lambeaux/ddf/branches{/branch}","tags_url":"https://api.github.com/repos/Lambeaux/ddf/tags","blobs_url":"https://api.github.com/repos/Lambeaux/ddf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Lambeaux/ddf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Lambeaux/ddf/git/refs{/sha}","trees_url":"https://api.github.com/repos/Lambeaux/ddf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Lambeaux/ddf/statuses/{sha}","languages_url":"https://api.github.com/repos/Lambeaux/ddf/languages","stargazers_url":"https://api.github.com/repos/Lambeaux/ddf/stargazers","contributors_url":"https://api.github.com/repos/Lambeaux/ddf/contributors","subscribers_url":"https://api.github.com/repos/Lambeaux/ddf/subscribers","subscription_url":"https://api.github.com/repos/Lambeaux/ddf/subscription","commits_url":"https://api.github.com/repos/Lambeaux/ddf/commits{/sha}","git_commits_url":"https://api.github.com/repos/Lambeaux/ddf/git/commits{/sha}","comments_url":"https://api.github.com/repos/Lambeaux/ddf/comments{/number}","issue_comment_url":"https://api.github.com/repos/Lambeaux/ddf/issues/comments{/number}","contents_url":"https://api.github.com/repos/Lambeaux/ddf/contents/{+path}","compare_url":"https://api.github.com/repos/Lambeaux/ddf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Lambeaux/ddf/merges","archive_url":"https://api.github.com/repos/Lambeaux/ddf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Lambeaux/ddf/downloads","issues_url":"https://api.github.com/repos/Lambeaux/ddf/issues{/number}","pulls_url":"https://api.github.com/repos/Lambeaux/ddf/pulls{/number}","milestones_url":"https://api.github.com/repos/Lambeaux/ddf/milestones{/number}","notifications_url":"https://api.github.com/repos/Lambeaux/ddf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Lambeaux/ddf/labels{/name}","releases_url":"https://api.github.com/repos/Lambeaux/ddf/releases{/id}","deployments_url":"https://api.github.com/repos/Lambeaux/ddf/deployments","created_at":"2015-12-07T20:30:44Z","updated_at":"2016-01-11T17:33:30Z","pushed_at":"2016-11-12T03:15:21Z","git_url":"git://github.com/Lambeaux/ddf.git","ssh_url":"git@github.com:Lambeaux/ddf.git","clone_url":"https://github.com/Lambeaux/ddf.git","svn_url":"https://github.com/Lambeaux/ddf","homepage":"","size":147581,"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":"codice:master","ref":"master","sha":"3b22b0c0b1a2ec650ab2c7300f8ab6d9b2e4143f","user":{"login":"codice","id":2386734,"avatar_url":"https://avatars.githubusercontent.com/u/2386734?v=3","gravatar_id":"","url":"https://api.github.com/users/codice","html_url":"https://github.com/codice","followers_url":"https://api.github.com/users/codice/followers","following_url":"https://api.github.com/users/codice/following{/other_user}","gists_url":"https://api.github.com/users/codice/gists{/gist_id}","starred_url":"https://api.github.com/users/codice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codice/subscriptions","organizations_url":"https://api.github.com/users/codice/orgs","repos_url":"https://api.github.com/users/codice/repos","events_url":"https://api.github.com/users/codice/events{/privacy}","received_events_url":"https://api.github.com/users/codice/received_events","type":"Organization","site_admin":false},"repo":{"id":15173563,"name":"ddf","full_name":"codice/ddf","owner":{"login":"codice","id":2386734,"avatar_url":"https://avatars.githubusercontent.com/u/2386734?v=3","gravatar_id":"","url":"https://api.github.com/users/codice","html_url":"https://github.com/codice","followers_url":"https://api.github.com/users/codice/followers","following_url":"https://api.github.com/users/codice/following{/other_user}","gists_url":"https://api.github.com/users/codice/gists{/gist_id}","starred_url":"https://api.github.com/users/codice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codice/subscriptions","organizations_url":"https://api.github.com/users/codice/orgs","repos_url":"https://api.github.com/users/codice/repos","events_url":"https://api.github.com/users/codice/events{/privacy}","received_events_url":"https://api.github.com/users/codice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codice/ddf","description":"Distributed Data Framework - an open source, modular integration framework.","fork":false,"url":"https://api.github.com/repos/codice/ddf","forks_url":"https://api.github.com/repos/codice/ddf/forks","keys_url":"https://api.github.com/repos/codice/ddf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codice/ddf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codice/ddf/teams","hooks_url":"https://api.github.com/repos/codice/ddf/hooks","issue_events_url":"https://api.github.com/repos/codice/ddf/issues/events{/number}","events_url":"https://api.github.com/repos/codice/ddf/events","assignees_url":"https://api.github.com/repos/codice/ddf/assignees{/user}","branches_url":"https://api.github.com/repos/codice/ddf/branches{/branch}","tags_url":"https://api.github.com/repos/codice/ddf/tags","blobs_url":"https://api.github.com/repos/codice/ddf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codice/ddf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codice/ddf/git/refs{/sha}","trees_url":"https://api.github.com/repos/codice/ddf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codice/ddf/statuses/{sha}","languages_url":"https://api.github.com/repos/codice/ddf/languages","stargazers_url":"https://api.github.com/repos/codice/ddf/stargazers","contributors_url":"https://api.github.com/repos/codice/ddf/contributors","subscribers_url":"https://api.github.com/repos/codice/ddf/subscribers","subscription_url":"https://api.github.com/repos/codice/ddf/subscription","commits_url":"https://api.github.com/repos/codice/ddf/commits{/sha}","git_commits_url":"https://api.github.com/repos/codice/ddf/git/commits{/sha}","comments_url":"https://api.github.com/repos/codice/ddf/comments{/number}","issue_comment_url":"https://api.github.com/repos/codice/ddf/issues/comments{/number}","contents_url":"https://api.github.com/repos/codice/ddf/contents/{+path}","compare_url":"https://api.github.com/repos/codice/ddf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codice/ddf/merges","archive_url":"https://api.github.com/repos/codice/ddf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codice/ddf/downloads","issues_url":"https://api.github.com/repos/codice/ddf/issues{/number}","pulls_url":"https://api.github.com/repos/codice/ddf/pulls{/number}","milestones_url":"https://api.github.com/repos/codice/ddf/milestones{/number}","notifications_url":"https://api.github.com/repos/codice/ddf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codice/ddf/labels{/name}","releases_url":"https://api.github.com/repos/codice/ddf/releases{/id}","deployments_url":"https://api.github.com/repos/codice/ddf/deployments","created_at":"2013-12-13T20:38:28Z","updated_at":"2016-11-08T16:53:10Z","pushed_at":"2016-11-12T03:15:22Z","git_url":"git://github.com/codice/ddf.git","ssh_url":"git@github.com:codice/ddf.git","clone_url":"https://github.com/codice/ddf.git","svn_url":"https://github.com/codice/ddf","homepage":"http://ddf.codice.org","size":295445,"stargazers_count":49,"watchers_count":49,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":96,"mirror_url":null,"open_issues_count":34,"forks":96,"open_issues":34,"watchers":49,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codice/ddf/pulls/1401"},"html":{"href":"https://github.com/codice/ddf/pull/1401"},"issue":{"href":"https://api.github.com/repos/codice/ddf/issues/1401"},"comments":{"href":"https://api.github.com/repos/codice/ddf/issues/1401/comments"},"review_comments":{"href":"https://api.github.com/repos/codice/ddf/pulls/1401/comments"},"review_comment":{"href":"https://api.github.com/repos/codice/ddf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codice/ddf/pulls/1401/commits"},"statuses":{"href":"https://api.github.com/repos/codice/ddf/statuses/473894b094b784f4b3e6366c767fecd2a46c6625"}}}}
{"actor":{"display_login":"Lambeaux"}}