push addional code
[sdc.git] / openecomp-be / lib / openecomp-sdc-vendor-software-product-lib / openecomp-sdc-vendor-software-product-api / src / main / java / org / openecomp / sdc / vendorsoftwareproduct / dao / type / UploadDataEntity.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.vendorsoftwareproduct.dao.type;
22
23 import com.datastax.driver.mapping.annotations.Column;
24 import com.datastax.driver.mapping.annotations.Frozen;
25 import com.datastax.driver.mapping.annotations.PartitionKey;
26 import com.datastax.driver.mapping.annotations.Table;
27 import org.openecomp.core.utilities.json.JsonUtil;
28 import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
29 import org.openecomp.sdc.versioning.dao.types.Version;
30 import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
31
32 import java.nio.ByteBuffer;
33
34 @Table(keyspace = "dox", name = "vsp_information")
35 public class UploadDataEntity implements VersionableEntity {
36   private static final String ENTITY_TYPE = "Vendor Software Product Upload data";
37
38   @PartitionKey
39   @Column(name = "vsp_id")
40   private String id;
41
42   @PartitionKey(value = 1)
43   @Frozen
44   private Version version;
45
46   @Column(name = "package_name")
47   private String packageName;
48
49   @Column(name = "package_version")
50   private String packageVersion;
51
52   @Column(name = "validation_data")
53   private String validationData;
54
55   @Column(name = "content_data")
56   private ByteBuffer contentData;
57
58   public UploadDataEntity() {
59   }
60
61   public UploadDataEntity(String id, Version version) {
62     this.id = id;
63     this.version = version;
64   }
65
66   @Override
67   public String getEntityType() {
68     return ENTITY_TYPE;
69   }
70
71   @Override
72   public String getFirstClassCitizenId() {
73     return getId();
74   }
75
76   public String getId() {
77     return id;
78   }
79
80   public void setId(String id) {
81     this.id = id;
82   }
83
84   @Override
85   public Version getVersion() {
86     return version;
87   }
88
89   @Override
90   public void setVersion(Version version) {
91     this.version = version;
92   }
93
94   public String getPackageName() {
95     return packageName;
96   }
97
98   public void setPackageName(String packageName) {
99     this.packageName = packageName;
100   }
101
102   public String getPackageVersion() {
103     return packageVersion;
104   }
105
106   public void setPackageVersion(String packageVersion) {
107     this.packageVersion = packageVersion;
108   }
109
110   public String getValidationData() {
111     return validationData;
112   }
113
114   public void setValidationData(String validationData) {
115     this.validationData = validationData;
116   }
117
118   public ValidationStructureList getValidationDataStructure() {
119     return validationData == null ? null
120         : JsonUtil.json2Object(validationData, ValidationStructureList.class);
121   }
122
123   public void setValidationDataStructure(ValidationStructureList validationData) {
124     this.validationData = validationData == null ? null
125         : JsonUtil.object2Json(validationData);
126   }
127
128   public ByteBuffer getContentData() {
129     return contentData;
130   }
131
132   public void setContentData(ByteBuffer contentData) {
133     this.contentData = contentData;
134   }
135 }