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 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;
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);
55 @ApiModelProperty(value = "objectMap")
56 public Map<String, byte[]> getObjectMap() {
60 public void setObjectMap(Map<String, byte[]> objectMap) {
61 this.objectMap = objectMap;
64 @ApiModelProperty(value = "keyspace")
65 public String getKeyspaceName() {
69 public void setKeyspaceName(String keyspaceName) {
70 this.keyspaceName = keyspaceName;
73 @ApiModelProperty(value = "Table name")
74 public String getTableName() {
78 public void setTableName(String tableName) {
79 this.tableName = tableName;
82 @ApiModelProperty(value = "Consistency level", allowableValues = "eventual,critical,atomic")
83 public Map<String, String> getConsistencyInfo() {
84 return consistencyInfo;
87 public void setConsistencyInfo(Map<String, String> consistencyInfo) {
88 this.consistencyInfo = consistencyInfo;
91 @ApiModelProperty(value = "Time to live information")
92 public String getTtl() {
96 public void setTtl(String ttl) {
100 @ApiModelProperty(value = "Time stamp")
101 public String getTimestamp() {
105 public void setTimestamp(String timestamp) {
106 this.timestamp = timestamp;
109 @ApiModelProperty(value = "values returned")
110 public Map<String, Object> getValues() {
114 public void setValues(Map<String, Object> values) {
115 this.values = values;
118 @ApiModelProperty(value = "Information for selecting specific rows for insert")
119 public Map<String, Object> getRow_specification() {
120 return rowSpecification;
123 public void setRow_specification(Map<String, Object> rowSpecification) {
124 this.rowSpecification = rowSpecification;
127 public byte[] serialize() {
128 ByteArrayOutputStream bos = new ByteArrayOutputStream();
129 ObjectOutput out = null;
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);
136 return bos.toByteArray();