fae7720df1b68b8933ebdd976b5b1f823b836d82
[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 import io.swagger.annotations.ApiModel;
31 import io.swagger.annotations.ApiModelProperty;
32
33 @ApiModel(value = "JsonTable", description = "Json model for table update")
34 public class JsonUpdate implements Serializable {
35     private String keyspaceName;
36     private String tableName;
37     private Map<String, Object> values;
38     private String ttl, timestamp;
39     private Map<String, String> consistencyInfo;
40     private Map<String, Object> conditions;
41     private Map<String, Object> row_specification;
42
43     @ApiModelProperty(value = "Conditions")
44     public Map<String, Object> getConditions() {
45         return conditions;
46     }
47
48     public void setConditions(Map<String, Object> conditions) {
49         this.conditions = conditions;
50     }
51
52     @ApiModelProperty(value = "Information for selecting sepcific rows")
53     public Map<String, Object> getRow_specification() {
54         return row_specification;
55     }
56
57     public void setRow_specification(Map<String, Object> row_specification) {
58         this.row_specification = row_specification;
59     }
60
61
62     @ApiModelProperty(value = "Keyspace name")
63     public String getKeyspaceName() {
64         return keyspaceName;
65     }
66
67     public void setKeyspaceName(String keyspaceName) {
68         this.keyspaceName = keyspaceName;
69     }
70
71     @ApiModelProperty(value = "Table name")
72     public String getTableName() {
73         return tableName;
74     }
75
76     public void setTableName(String tableName) {
77         this.tableName = tableName;
78     }
79
80     @ApiModelProperty(value = "Consistency level", allowableValues = "eventual,critical,atomic")
81     public Map<String, String> getConsistencyInfo() {
82         return consistencyInfo;
83     }
84
85     public void setConsistencyInfo(Map<String, String> consistencyInfo) {
86         this.consistencyInfo = consistencyInfo;
87     }
88
89     @ApiModelProperty(value = "Time to live value")
90     public String getTtl() {
91         return ttl;
92     }
93
94     public void setTtl(String ttl) {
95         this.ttl = ttl;
96     }
97
98     @ApiModelProperty(value = "Time stamp")
99     public String getTimestamp() {
100         return timestamp;
101     }
102
103     public void setTimestamp(String timestamp) {
104         this.timestamp = timestamp;
105     }
106
107     @ApiModelProperty(value = "Column values")
108     public Map<String, Object> getValues() {
109         return values;
110     }
111
112     public void setValues(Map<String, Object> values) {
113         this.values = values;
114     }
115
116     public byte[] serialize() {
117         ByteArrayOutputStream bos = new ByteArrayOutputStream();
118         ObjectOutput out = null;
119         try {
120             out = new ObjectOutputStream(bos);
121             out.writeObject(this);
122         } catch (IOException e) {
123             e.printStackTrace();
124         }
125         return bos.toByteArray();
126     }
127
128 }