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