Add the target resource ID
[clamp.git] / src / main / java / org / onap / clamp / clds / model / prop / PolicyItem.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ===================================================================
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23
24 package org.onap.clamp.clds.model.prop;
25
26 import com.att.eelf.configuration.EELFLogger;
27 import com.att.eelf.configuration.EELFManager;
28 import com.fasterxml.jackson.databind.JsonNode;
29
30 import java.util.List;
31
32 /**
33  * Parse policyConfigurations from Policy json properties.
34  * <p>
35  * Example json:
36  * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[
37  * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{
38  * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{
39  * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]}
40  * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]
41  * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]
42  * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]}
43  * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]}
44  * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"
45  * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[
46  * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[
47  * "vf3RtPi"]},{"name":
48  * "targetResourceId","value":["Eace933104d443b496b8.nodes.heat.vpg"]}]]}]
49  */
50 public class PolicyItem implements Cloneable {
51     protected static final EELFLogger logger      = EELFManager.getInstance().getLogger(PolicyItem.class);
52     protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
53
54     private String                    id;
55     private String                    recipe;
56     private int                       maxRetries;
57     private int                       retryTimeLimit;
58     private String                    parentPolicy;
59     private List<String>              parentPolicyConditions;
60     private String                    actor;
61     private String                    targetResourceId;
62
63     /**
64      * Parse Policy given json node.
65      *
66      * @param node
67      */
68     public PolicyItem(JsonNode node) {
69         id = AbstractModelElement.getValueByName(node, "_id");
70         recipe = AbstractModelElement.getValueByName(node, "recipe");
71         maxRetries = AbstractModelElement.getIntValueByName(node, "maxRetries");
72         retryTimeLimit = AbstractModelElement.getIntValueByName(node, "retryTimeLimit");
73         parentPolicy = AbstractModelElement.getValueByName(node, "parentPolicy");
74         parentPolicyConditions = AbstractModelElement.getValuesByName(node, "parentPolicyConditions");
75         targetResourceId = AbstractModelElement.getValueByName(node, "targetResourceId");
76
77     }
78
79     /**
80      * @return the id
81      */
82     public String getId() {
83         return id;
84     }
85
86     /**
87      * @return the recipe
88      */
89     public String getRecipe() {
90         return recipe;
91     }
92
93     /**
94      * @set the id
95      */
96     public void setId(String id) {
97         this.id = id;
98     }
99
100     /**
101      * @set the recipe
102      */
103     public void setRecipe(String recipe) {
104         this.recipe = recipe;
105     }
106
107     /**
108      * @set the parentPolicy
109      */
110     public void setParentPolicy(String parentPolicy) {
111         this.parentPolicy = parentPolicy;
112     }
113
114     /**
115      * @set the maxRetries
116      */
117     public void setMaxRetries(int maxRetries) {
118         this.maxRetries = maxRetries;
119     }
120
121     /**
122      * @set the retryTimeLimit
123      */
124     public void setRetryTimeLimit(int retryTimeLimit) {
125         this.retryTimeLimit = retryTimeLimit;
126     }
127
128     /**
129      * @set the parentPolicyConditions
130      */
131     public void setParentPolicyConditions(List<String> parentPolicyConditions) {
132         this.parentPolicyConditions = parentPolicyConditions;
133     }
134
135     /**
136      * @return the maxRetries
137      */
138     public int getMaxRetries() {
139         return maxRetries;
140     }
141
142     /**
143      * @return the retryTimeLimit
144      */
145     public int getRetryTimeLimit() {
146         return retryTimeLimit;
147     }
148
149     /**
150      * @return the parentPolicy
151      */
152     public String getParentPolicy() {
153         return parentPolicy;
154     }
155
156     /**
157      * @return the parentPolicyConditions
158      */
159     public List<String> getParentPolicyConditions() {
160         return parentPolicyConditions;
161     }
162
163     /**
164      * @return the actor
165      */
166     public String getActor() {
167         return actor;
168     }
169
170     /**
171      * @set the actor
172      */
173     public void setActor(String actor) {
174         this.actor = actor;
175     }
176
177     public String getTargetResourceId() {
178         return targetResourceId;
179     }
180
181     public void setTargetResourceId(String targetResourceId) {
182         this.targetResourceId = targetResourceId;
183     }
184
185     @Override
186     public Object clone() throws CloneNotSupportedException {
187         return super.clone();
188     }
189 }