2 * ============LICENSE_START==========================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 * ============LICENSE_END=============================================
21 * ====================================================================
23 package org.onap.music.datastore.jsonobjects;
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;
32 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
34 import io.swagger.annotations.ApiModel;
35 import io.swagger.annotations.ApiModelProperty;
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;
42 @ApiModel(value = "JsonTable", description = "Json model for table update")
43 @JsonIgnoreProperties(ignoreUnknown = true)
44 public class JsonUpdate implements Serializable {
45 private String keyspaceName;
46 private String tableName;
47 private transient Map<String, Object> values;
49 private String timestamp;
50 private Map<String, String> consistencyInfo;
51 private transient Map<String, Object> conditions;
52 private transient Map<String, Object> rowSpecification;
53 private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonUpdate.class);
55 @ApiModelProperty(value = "Conditions")
56 public Map<String, Object> getConditions() {
60 public void setConditions(Map<String, Object> conditions) {
61 this.conditions = conditions;
64 @ApiModelProperty(value = "Information for selecting sepcific rows")
65 public Map<String, Object> getRow_specification() {
66 return rowSpecification;
69 public void setRow_specification(Map<String, Object> rowSpecification) {
70 this.rowSpecification = rowSpecification;
74 @ApiModelProperty(value = "Keyspace name")
75 public String getKeyspaceName() {
79 public void setKeyspaceName(String keyspaceName) {
80 this.keyspaceName = keyspaceName;
83 @ApiModelProperty(value = "Table name")
84 public String getTableName() {
88 public void setTableName(String tableName) {
89 this.tableName = tableName;
92 @ApiModelProperty(value = "Consistency level", allowableValues = "eventual,critical,atomic")
93 public Map<String, String> getConsistencyInfo() {
94 return consistencyInfo;
97 public void setConsistencyInfo(Map<String, String> consistencyInfo) {
98 this.consistencyInfo = consistencyInfo;
101 @ApiModelProperty(value = "Time to live value")
102 public String getTtl() {
106 public void setTtl(String ttl) {
110 @ApiModelProperty(value = "Time stamp")
111 public String getTimestamp() {
115 public void setTimestamp(String timestamp) {
116 this.timestamp = timestamp;
119 @ApiModelProperty(value = "Column values")
120 public Map<String, Object> getValues() {
124 public void setValues(Map<String, Object> values) {
125 this.values = values;
128 public byte[] serialize() {
129 ByteArrayOutputStream bos = new ByteArrayOutputStream();
130 ObjectOutput out = null;
132 out = new ObjectOutputStream(bos);
133 out.writeObject(this);
134 } catch (IOException e) {
135 logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.DATAERROR);
137 return bos.toByteArray();