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