62db64491cbf5423444cfeddb139b7486df66c87
[policy/engine.git] / PolicyEngineAPI / src / main / java / org / onap / policy / std / StdPolicyConfig.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineAPI
4  * ================================================================================
5  * Copyright (C) 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21
22 package org.onap.policy.std;
23
24 import java.util.Map;
25 import java.util.Properties;
26
27 import javax.json.JsonObject;
28
29 import org.onap.policy.api.PolicyConfig;
30 import org.onap.policy.api.PolicyConfigStatus;
31 import org.onap.policy.api.PolicyConfigType;
32 import org.onap.policy.api.PolicyType;
33 import org.w3c.dom.Document;
34
35 /**
36  * PolicyConfig Implementation. 
37  * 
38  * @version 0.3
39  *
40  */
41
42 public class StdPolicyConfig implements PolicyConfig{
43         private PolicyType policyType;
44         private Properties properties;
45         private JsonObject jsonObject;
46         private Document document;
47         private String other;
48         private PolicyConfigStatus policyConfigStatus;
49         private String configStatus;
50         private String policyName;
51         private String policyVersion;
52         private PolicyConfigType type;
53         private Map<String,String> matchingConditions; 
54         private Map<String,String> responseAttributes;
55         
56         @Override
57         public PolicyType getType() {
58                 return policyType;
59         }
60
61         @Override
62         public Properties toProperties() {
63                 return properties;
64         }
65
66         @Override
67         public JsonObject toJSON() {
68                 return jsonObject;
69         }
70
71         @Override
72         public Document toXML() {
73                 return document;
74         }
75         
76         @Override
77         public String toOther() {
78                 return other;
79         }
80
81         @Override
82         public PolicyConfigStatus getPolicyConfigStatus() {
83                 return policyConfigStatus;
84         }
85
86         @Override
87         public String getPolicyConfigMessage() {
88                 return configStatus;
89         }
90         
91         @Override
92         public String getPolicyName() {
93                 if(policyName!=null && policyName.contains(".xml")){
94                         return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf('.')).lastIndexOf('.')));
95                 }
96                 return policyName;
97         }
98         
99         @Override
100         public String getPolicyVersion() {
101                 return policyVersion;
102         }
103         
104         @Override
105         public Map<String,String> getMatchingConditions(){
106                 return matchingConditions;
107         }
108         
109         @Override
110         public Map<String,String> getResponseAttributes(){
111                 return responseAttributes;
112         }
113         
114         public void setPolicyType(PolicyType policyType) {
115                 this.policyType = policyType;
116         }
117         
118         public void setPolicyName(String policyName) {
119                 this.policyName = policyName;
120         }
121         
122         public void setPolicyVersion(String policyVersion) {
123                 this.policyVersion = policyVersion;
124         }
125         
126         public void setProperties(Properties properties) {
127                 this.properties = properties;
128         }
129
130         public void setJsonObject(JsonObject jsonObject) {
131                 this.jsonObject = jsonObject;
132         }
133         
134         public void setDocument(Document document) {
135                 this.document = document;
136         }
137         
138         public void setOther(String other) {
139                 this.other = other;
140         }
141         
142         public void setConfigStatus(String configStatus) {
143                 this.configStatus = configStatus;
144         }
145         
146         public void setPolicyConfigStatus(PolicyConfigStatus policyConfigStatus) {
147                 this.policyConfigStatus = policyConfigStatus;
148         }
149         
150         public void setConfigStatus(String configStatus, PolicyConfigStatus policyConfigStatus) {
151                 this.configStatus = configStatus;
152                 this.policyConfigStatus = policyConfigStatus;
153         }
154         
155         public void setMatchingConditions(Map<String,String> matchingConditions){
156                 this.matchingConditions = matchingConditions;
157         }
158         
159         public void setResponseAttributes(Map<String,String> responseAttributes){
160                 this.responseAttributes = responseAttributes;
161         }
162         
163         
164         public void setPolicyType(PolicyConfigType policyType) {
165         this.type = policyType;
166     }
167         
168         @Override
169         public PolicyConfigType getPolicyType(){
170             return this.type;
171         }
172
173     @Override
174         public String toString() {
175                 return "PolicyConfig [ policyConfigStatus=" + policyConfigStatus + ", policyConfigMessage=" + configStatus + ", policyName=" + policyName + 
176                                 ""
177                                 + "]";
178         }
179
180 }