Merge "Sonar fix: RestMusicHealthCheckAPI.java"
[music.git] / src / main / java / org / onap / music / datastore / jsonobjects / JsonInsert.java
1 /*
2  * ============LICENSE_START==========================================
3  * org.onap.music
4  * ===================================================================
5  *  Copyright (c) 2017 AT&T Intellectual Property
6  *  Modifications Copyright (C) 2018 IBM.
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  * 
20  * ============LICENSE_END=============================================
21  * ====================================================================
22  */
23 package org.onap.music.datastore.jsonobjects;
24
25 import java.io.ByteArrayOutputStream;
26 import java.io.IOException;
27 import java.io.ObjectOutput;
28 import java.io.ObjectOutputStream;
29 import java.io.Serializable;
30 import java.util.Map;
31
32 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
33
34 import io.swagger.annotations.ApiModel;
35 import io.swagger.annotations.ApiModelProperty;
36
37 import org.onap.music.eelf.logging.EELFLoggerDelegate;
38 import org.onap.music.eelf.logging.format.AppMessages;
39 import org.onap.music.eelf.logging.format.ErrorSeverity;
40 import org.onap.music.eelf.logging.format.ErrorTypes;
41
42 @ApiModel(value = "JsonTable", description = "Json model for table vlaues insert")
43 @JsonIgnoreProperties(ignoreUnknown = true)
44 public class JsonInsert implements Serializable {
45     private String keyspaceName;
46     private String tableName;
47     private transient Map<String, Object> values;
48     private String ttl;
49     private String timestamp;
50     private transient Map<String, Object> rowSpecification;
51     private Map<String, String> consistencyInfo;
52     private Map<String, byte[]> objectMap;
53     private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonInsert.class);
54
55     @ApiModelProperty(value = "objectMap")
56     public Map<String, byte[]> getObjectMap() {
57                 return objectMap;
58         }
59     
60     public void setObjectMap(Map<String, byte[]> objectMap) {
61                 this.objectMap = objectMap;
62         }
63     
64     @ApiModelProperty(value = "keyspace")
65     public String getKeyspaceName() {
66         return keyspaceName;
67     }
68
69     public void setKeyspaceName(String keyspaceName) {
70         this.keyspaceName = keyspaceName;
71     }
72
73     @ApiModelProperty(value = "Table name")
74     public String getTableName() {
75         return tableName;
76     }
77
78     public void setTableName(String tableName) {
79         this.tableName = tableName;
80     }
81
82     @ApiModelProperty(value = "Consistency level", allowableValues = "eventual,critical,atomic")
83     public Map<String, String> getConsistencyInfo() {
84         return consistencyInfo;
85     }
86
87     public void setConsistencyInfo(Map<String, String> consistencyInfo) {
88         this.consistencyInfo = consistencyInfo;
89     }
90
91     @ApiModelProperty(value = "Time to live information")
92     public String getTtl() {
93         return ttl;
94     }
95
96     public void setTtl(String ttl) {
97         this.ttl = ttl;
98     }
99
100     @ApiModelProperty(value = "Time stamp")
101     public String getTimestamp() {
102         return timestamp;
103     }
104
105     public void setTimestamp(String timestamp) {
106         this.timestamp = timestamp;
107     }
108
109     @ApiModelProperty(value = "values returned")
110     public Map<String, Object> getValues() {
111         return values;
112     }
113
114     public void setValues(Map<String, Object> values) {
115         this.values = values;
116     }
117
118     @ApiModelProperty(value = "Information for selecting specific rows for insert")
119     public Map<String, Object> getRow_specification() {
120         return rowSpecification;
121     }
122
123     public void setRow_specification(Map<String, Object> rowSpecification) {
124         this.rowSpecification = rowSpecification;
125     }
126
127     public byte[] serialize() {
128         ByteArrayOutputStream bos = new ByteArrayOutputStream();
129         ObjectOutput out = null;
130         try {
131             out = new ObjectOutputStream(bos);
132             out.writeObject(this);
133         } catch (IOException e) {
134             logger.error(EELFLoggerDelegate.errorLogger, e, AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.DATAERROR);
135         }
136         return bos.toByteArray();
137     }
138
139 }