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