2 * ===============================LICENSE_START======================================
\r
4 * ================================================================================
\r
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============================LICENSE_END===========================================
\r
21 package org.openecomp.dcae.apod.analytics.cdap.plugins.domain.config.filter;
\r
23 import co.cask.cdap.api.annotation.Description;
\r
24 import co.cask.cdap.api.annotation.Macro;
\r
25 import co.cask.cdap.api.annotation.Name;
\r
26 import com.google.common.base.Objects;
\r
27 import org.openecomp.dcae.apod.analytics.cdap.common.settings.CDAPBasePluginConfig;
\r
30 * Configuration for Json Path Filter Plugin
\r
32 * @author Rajiv Singla . Creation Date: 3/2/2017.
\r
34 public class JsonPathFilterPluginConfig extends CDAPBasePluginConfig {
\r
36 private static final long serialVersionUID = 1L;
\r
38 @Name("incomingJsonFieldName")
\r
39 @Description("Input schema field name that contain JSON used for filtering")
\r
41 protected String incomingJsonFieldName;
\r
44 @Name("outputSchemaFieldName")
\r
45 @Description("Name of the nullable boolean schema field name that will contain result of the filter matching")
\r
47 protected String outputSchemaFieldName;
\r
50 @Name("jsonFilterMappings")
\r
52 @Description("Filters incoming JSON based on given filter mappings - in terms of JSON path and expected values." +
\r
53 "Right hand side contains JSON path. Left hand side contains semicolon (';') separated expected values " +
\r
54 "for that JSON Path. If all provided JSON Path mappings and corresponding values matches - " +
\r
55 "output schema field will be marked as true")
\r
56 protected String jsonFilterMappings;
\r
60 @Description("Output Schema")
\r
61 protected String schema;
\r
64 public JsonPathFilterPluginConfig(final String referenceName, final String incomingJsonFieldName,
\r
65 final String outputSchemaFieldName, final String jsonFilterMappings,
\r
66 final String schema) {
\r
67 this.referenceName = referenceName;
\r
68 this.incomingJsonFieldName = incomingJsonFieldName;
\r
69 this.outputSchemaFieldName = outputSchemaFieldName;
\r
70 this.jsonFilterMappings = jsonFilterMappings;
\r
71 this.schema = schema;
\r
75 * Provides incoming plugin schema field name which contains json used to apply filter
\r
77 * @return name of incoming schema field containing JSON to be filtered
\r
79 public String getIncomingJsonFieldName() {
\r
80 return incomingJsonFieldName;
\r
84 * Provides plugin output schema filed name that will contain result of filter application
\r
85 * It must be nullable and boolean type
\r
87 * @return name of outgoing schema filed name that will contain filtering result
\r
89 public String getOutputSchemaFieldName() {
\r
90 return outputSchemaFieldName;
\r
94 * Provides JSON filter mappings. LHS contains JSON path value and RHS contains expected
\r
95 * values separated by semicolon
\r
98 * @return String for JSON filter mappings
\r
100 public String getJsonFilterMappings() {
\r
101 return jsonFilterMappings;
\r
107 * @return output schema string
\r
109 public String getSchema() {
\r
115 public String toString() {
\r
116 return Objects.toStringHelper(this)
\r
117 .add("referenceName", referenceName)
\r
118 .add("incomingJsonFieldName", incomingJsonFieldName)
\r
119 .add("outputSchemaFieldName", outputSchemaFieldName)
\r
120 .add("jsonFilterMappings", jsonFilterMappings)
\r
121 .add("schema", schema)
\r