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 * ====================================================================
24 package org.onap.music.datastore.jsonobjects;
26 import java.io.ByteArrayOutputStream;
27 import java.io.IOException;
28 import java.io.ObjectOutput;
29 import java.io.ObjectOutputStream;
30 import java.io.Serializable;
33 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
35 import io.swagger.annotations.ApiModel;
36 import io.swagger.annotations.ApiModelProperty;
38 import org.onap.music.eelf.logging.EELFLoggerDelegate;
39 import org.onap.music.eelf.logging.format.AppMessages;
40 import org.onap.music.eelf.logging.format.ErrorSeverity;
41 import org.onap.music.eelf.logging.format.ErrorTypes;
43 @ApiModel(value = "JsonTable", description = "Json model for table update")
44 @JsonIgnoreProperties(ignoreUnknown = true)
45 public class JsonUpdate implements Serializable {
46 private String keyspaceName;
47 private String tableName;
48 private transient Map<String, Object> values;
50 private String timestamp;
51 private Map<String, String> consistencyInfo;
52 private transient Map<String, Object> conditions;
53 private transient Map<String, Object> rowSpecification;
54 private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonUpdate.class);
56 @ApiModelProperty(value = "Conditions")
57 public Map<String, Object> getConditions() {
61 public void setConditions(Map<String, Object> conditions) {
62 this.conditions = conditions;
65 @ApiModelProperty(value = "Information for selecting sepcific rows")
66 public Map<String, Object> getRow_specification() {
67 return rowSpecification;
70 public void setRow_specification(Map<String, Object> rowSpecification) {
71 this.rowSpecification = rowSpecification;
75 @ApiModelProperty(value = "Keyspace name")
76 public String getKeyspaceName() {
80 public void setKeyspaceName(String keyspaceName) {
81 this.keyspaceName = keyspaceName;
84 @ApiModelProperty(value = "Table name")
85 public String getTableName() {
89 public void setTableName(String tableName) {
90 this.tableName = tableName;
93 @ApiModelProperty(value = "Consistency level", allowableValues = "eventual,critical,atomic")
94 public Map<String, String> getConsistencyInfo() {
95 return consistencyInfo;
98 public void setConsistencyInfo(Map<String, String> consistencyInfo) {
99 this.consistencyInfo = consistencyInfo;
102 @ApiModelProperty(value = "Time to live value")
103 public String getTtl() {
107 public void setTtl(String ttl) {
111 @ApiModelProperty(value = "Time stamp")
112 public String getTimestamp() {
116 public void setTimestamp(String timestamp) {
117 this.timestamp = timestamp;
120 @ApiModelProperty(value = "Column values")
121 public Map<String, Object> getValues() {
125 public void setValues(Map<String, Object> values) {
126 this.values = values;
129 public byte[] serialize() {
130 ByteArrayOutputStream bos = new ByteArrayOutputStream();
131 ObjectOutput out = null;
133 out = new ObjectOutputStream(bos);
134 out.writeObject(this);
135 } catch (IOException e) {
136 logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.DATAERROR);
138 return bos.toByteArray();