Catalog alignment
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / ComponentCacheData.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.Column;
24 import com.datastax.driver.mapping.annotations.PartitionKey;
25 import com.datastax.driver.mapping.annotations.Table;
26
27 import java.nio.ByteBuffer;
28 import java.util.Date;
29
30 @Table(keyspace = "sdccomponent", name = "componentcache")
31 public class ComponentCacheData {
32         public final static String RRESOURCE_ID_FIELD = "resourceId";
33
34         public final static String SERVICE_NAME_FIELD = "serviceName";
35         public final static String SERVICE_VERSION_FIELD = "serviceVersion";
36         public final static String ARTIFACT_NAME_FIELD = "artifactName";
37
38         public static String delim = ":";
39
40         @PartitionKey
41         @Column(name = "id")
42         private String id;
43
44         @Column
45         private ByteBuffer data;
46
47         @Column(name = "modification_time")
48         private Date modificationTime;
49
50         @Column
51         private String type;
52
53         @Column(name = "is_dirty")
54         private boolean isDirty;
55
56         @Column(name = "is_zipped")
57         private boolean isZipped;
58
59         public ComponentCacheData() {
60
61         }
62
63         public ComponentCacheData(String id, byte[] data, Date modificationTime, String type, boolean isDirty,
64                         boolean isZipped) {
65                 super();
66                 this.id = id;
67                 if (data != null) {
68                         this.data = ByteBuffer.wrap(data.clone());
69                 }
70                 this.modificationTime = modificationTime;
71                 this.type = type;
72                 this.isDirty = isDirty;
73                 this.isZipped = isZipped;
74         }
75
76         public ComponentCacheData(String id) {
77
78                 this.id = id;
79         }
80
81         public ComponentCacheData(String artifactId, byte[] data) {
82                 super();
83                 this.id = artifactId;
84                 if (data != null) {
85                         this.data = ByteBuffer.wrap(data.clone());
86                         // this.data = data.clone();
87                 }
88         }
89
90         public byte[] getDataAsArray() {
91                 if (data != null) {
92                         return data.array();
93                 }
94                 return null;
95         }
96
97         public void setDataAsArray(byte[] data) {
98                 if (data != null) {
99                         this.data = ByteBuffer.wrap(data.clone());
100                 }
101         }
102
103         public ByteBuffer getData() {
104                 return data;
105         }
106
107         public void setData(ByteBuffer data) {
108                 if (data != null) {
109                         this.data = data.duplicate();
110                 }
111         }
112
113         public String getId() {
114                 return id;
115         }
116
117         public void setId(String id) {
118                 this.id = id;
119         }
120
121         public Date getModificationTime() {
122                 return modificationTime;
123         }
124
125         public void setModificationTime(Date modificationTime) {
126                 this.modificationTime = modificationTime;
127         }
128
129         public String getType() {
130                 return type;
131         }
132
133         public void setType(String type) {
134                 this.type = type;
135         }
136
137         public boolean getIsDirty() {
138                 return isDirty;
139         }
140
141         public void setIsDirty(boolean isDirty) {
142                 this.isDirty = isDirty;
143         }
144
145         public boolean getIsZipped() {
146                 return isZipped;
147         }
148
149         public void setIsZipped(boolean isZipped) {
150                 this.isZipped = isZipped;
151         }
152
153 }