Upgrade to Cassandra 3
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / SdcSchemaFilesData.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.resources.data;
22
23 import com.datastax.driver.mapping.annotations.ClusteringColumn;
24 import com.datastax.driver.mapping.annotations.Column;
25 import com.datastax.driver.mapping.annotations.PartitionKey;
26 import com.datastax.driver.mapping.annotations.Table;
27 import com.datastax.driver.mapping.annotations.Transient;
28 import java.nio.ByteBuffer;
29 import java.util.Date;
30
31 @Table(keyspace = "sdcartifact", name = "sdcschemafiles")
32 public class SdcSchemaFilesData {
33         @PartitionKey(0)
34         @Column(name = "sdcreleasenum")
35         private String sdcReleaseNum;
36         
37         @ClusteringColumn
38         @Column(name = "timestamp")
39         private Date timestamp;
40         
41         @PartitionKey(1)
42         @Column(name = "conformanceLevel")
43         private String conformanceLevel;
44
45         @Column(name = "fileName")
46         private String fileName;
47
48         @Column(name = "payload")
49         private ByteBuffer payload;
50         
51         @Column(name = "checksum")
52         private String checksum;
53         
54         public SdcSchemaFilesData() {
55         
56         }
57         
58         public SdcSchemaFilesData(String sdcReleaseNum, Date timestamp, String conformanceLevel, String fileName, byte[] payload, String checksum){
59                 this.sdcReleaseNum = sdcReleaseNum;
60                 this.timestamp = timestamp;
61                 this.conformanceLevel = conformanceLevel;
62                 this.fileName = fileName;
63                 if(payload != null) {
64                         this.payload = ByteBuffer.wrap(payload.clone());
65                 }
66                 this.checksum = checksum;
67         }
68         
69         public String getSdcReleaseNum() {
70                 return sdcReleaseNum;
71         }
72
73         public void setSdcReleaseNum(String sdcReleaseNum) {
74                 this.sdcReleaseNum = sdcReleaseNum;
75         }
76
77         public String getConformanceLevel() {
78                 return conformanceLevel;
79         }
80
81         public void setConformanceLevel(String conformanceLevel) {
82                 this.conformanceLevel = conformanceLevel;
83         }
84
85         public String getFileName() {
86                 return fileName;
87         }
88
89         public void setFileName(String fileName) {
90                 this.fileName = fileName;
91         }
92
93         public ByteBuffer getPayload() {
94                 return payload;
95         }
96
97         public void setPayload(ByteBuffer payload) {
98                 if(payload != null){
99                         this.payload = payload.duplicate();
100                 }
101         }
102         
103         public void setPayloadAsArray(byte[] payload) {
104                 if(payload != null){
105                         this.payload = ByteBuffer.wrap(payload.clone());
106                 }
107         }
108
109         @Transient
110         public byte[] getPayloadAsArray() {
111                 return payload != null ? payload.array() : null;
112         }
113
114         public Date getTimestamp() {
115                 return timestamp;
116         }
117
118         public void setTimestamp(Date timestamp) {
119                 this.timestamp = timestamp;
120         }
121
122         public String getChecksum() {
123                 return checksum;
124         }
125
126         public void setChecksum(String checksum) {
127                 this.checksum = checksum;
128         }
129
130         @Override
131         public String toString() {
132                 return "SdcSchemaFilesData [sdcReleaseNum=" + sdcReleaseNum + ", timestamp=" + timestamp + ", conformanceLevel="
133                                 + conformanceLevel + ", fileName=" + fileName + ", checksum=" + checksum + "]";
134         }
135 }