TCA: Support for VES/A&AI enrichment
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-plugins / src / main / java / org / openecomp / dcae / apod / analytics / cdap / plugins / domain / config / filter / JsonPathFilterPluginConfig.java
1 /*\r
2  * ===============================LICENSE_START======================================\r
3  *  dcae-analytics\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
10  *\r
11  *          http://www.apache.org/licenses/LICENSE-2.0\r
12  *\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
19  */\r
20 \r
21 package org.openecomp.dcae.apod.analytics.cdap.plugins.domain.config.filter;\r
22 \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
28 \r
29 /**\r
30  * Configuration for Json Path Filter Plugin\r
31  *\r
32  * @author Rajiv Singla . Creation Date: 3/2/2017.\r
33  */\r
34 public class JsonPathFilterPluginConfig extends CDAPBasePluginConfig {\r
35 \r
36     private static final long serialVersionUID = 1L;\r
37 \r
38     @Name("incomingJsonFieldName")\r
39     @Description("Input schema field name that contain JSON used for filtering")\r
40     @Macro\r
41     protected String incomingJsonFieldName;\r
42 \r
43 \r
44     @Name("outputSchemaFieldName")\r
45     @Description("Name of the nullable boolean schema field name that will contain result of the filter matching")\r
46     @Macro\r
47     protected String outputSchemaFieldName;\r
48 \r
49 \r
50     @Name("jsonFilterMappings")\r
51     @Macro\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
57 \r
58 \r
59     @Name("schema")\r
60     @Description("Output Schema")\r
61     protected String schema;\r
62 \r
63 \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
72     }\r
73 \r
74     /**\r
75      * Provides incoming plugin schema field name which contains json used to apply filter\r
76      *\r
77      * @return  name of incoming schema field containing JSON to be filtered\r
78      */\r
79     public String getIncomingJsonFieldName() {\r
80         return incomingJsonFieldName;\r
81     }\r
82 \r
83     /**\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
86      *\r
87      * @return name of outgoing schema filed name that will contain filtering result\r
88      */\r
89     public String getOutputSchemaFieldName() {\r
90         return outputSchemaFieldName;\r
91     }\r
92 \r
93     /**\r
94      * Provides JSON filter mappings. LHS contains JSON path value and RHS contains expected\r
95      * values separated by semicolon\r
96      *\r
97      *\r
98      * @return String for JSON filter mappings\r
99      */\r
100     public String getJsonFilterMappings() {\r
101         return jsonFilterMappings;\r
102     }\r
103 \r
104     /**\r
105      * Output Schema\r
106      *\r
107      * @return output schema string\r
108      */\r
109     public String getSchema() {\r
110         return schema;\r
111     }\r
112 \r
113 \r
114     @Override\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
122                 .toString();\r
123     }\r
124 \r
125 }\r