Adding interfaces in documentation
[aai/sparky-be.git] / sparkybe-onap-service / src / main / java / org / onap / aai / sparky / subscription / payload / entity / ObjectInspectorPayload.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
8  * ============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25 package org.onap.aai.sparky.subscription.payload.entity;
26
27 import java.io.File;
28 import java.io.IOException;
29
30 import org.onap.aai.sparky.subscription.config.SubscriptionConfig;
31 import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
32
33 import com.fasterxml.jackson.annotation.JsonInclude;
34 import com.fasterxml.jackson.annotation.JsonProperty;
35 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
36 import com.fasterxml.jackson.core.JsonParseException;
37 import com.fasterxml.jackson.databind.JsonMappingException;
38 import com.fasterxml.jackson.databind.ObjectMapper;
39
40 @JsonInclude(JsonInclude.Include.NON_NULL)
41 @JsonPropertyOrder({ "target", "origin", "messageType", "topic", "message" })
42 public class ObjectInspectorPayload {
43
44         @JsonProperty("target")
45         private String target;
46         @JsonProperty("origin")
47         private String origin;
48         @JsonProperty("messageType")
49         private String messageType;
50         @JsonProperty("topic")
51         private String topic;
52         @JsonProperty("message")
53         private Message message;
54
55         @JsonProperty("target")
56         public String getTarget() {
57                 return target;
58         }
59
60         @JsonProperty("target")
61         public void setTarget(String target) {
62                 this.target = target;
63         }
64
65         @JsonProperty("origin")
66         public String getOrigin() {
67                 return origin;
68         }
69
70         @JsonProperty("origin")
71         public void setOrigin(String origin) {
72                 this.origin = origin;
73         }
74
75         @JsonProperty("messageType")
76         public String getMessageType() {
77                 return messageType;
78         }
79
80         @JsonProperty("messageType")
81         public void setMessageType(String messageType) {
82                 this.messageType = messageType;
83         }
84
85         @JsonProperty("topic")
86         public String getTopic() {
87                 return topic;
88         }
89
90         @JsonProperty("topic")
91         public void setTopic(String topic) {
92                 this.topic = topic;
93         }
94
95         @JsonProperty("message")
96         public Message getMessage() {
97                 return message;
98         }
99
100         @JsonProperty("message")
101         public void setMessage(Message message) {
102                 this.message = message;
103         }
104         
105         private static ObjectInspectorPayload lic;
106         public static ObjectInspectorPayload getOIPayload(SubscriptionConfig subscriptionConf) throws JsonParseException, JsonMappingException, IOException{
107                 if(lic == null){
108                         ObjectMapper mapper = new ObjectMapper();
109                         lic = mapper.readValue(new File(SparkyConstants.SUBSCRIPTION_OI_MAPPING), ObjectInspectorPayload.class);
110                         lic.intitializeOIPayload(subscriptionConf);
111                 }
112                 
113                 return lic;
114         }
115         
116         private void intitializeOIPayload(SubscriptionConfig subscriptionConf) {
117                 try {
118                         lic.setOrigin(subscriptionConf.getLaunchOIOrigin());
119                         lic.setTarget(subscriptionConf.getLaunchOITarget());
120                         lic.setTopic(subscriptionConf.getLaunchOITopic());
121                         lic.setMessageType(subscriptionConf.getLaunchOIMessageType());
122                 } catch (Exception e) {
123                         // TODO Auto-generated catch block
124                         e.printStackTrace();
125                 } 
126                 
127         }
128 }