de6c525701a049c6a48f603a6e1248f560416654
[sdc.git] /
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.ClusteringColumn;
24 import com.datastax.driver.mapping.annotations.Column;
25 import com.datastax.driver.mapping.annotations.Frozen;
26 import com.datastax.driver.mapping.annotations.PartitionKey;
27 import com.datastax.driver.mapping.annotations.Table;
28 import org.openecomp.core.enrichment.types.MonitoringUploadType;
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_component_artifact")
35 public class ComponentMonitoringUploadEntity implements VersionableEntity {
36   public static final String ENTITY_TYPE = "Vendor Software Product Component Artifact";
37   @PartitionKey
38   @Column(name = "vsp_id")
39   private String vspId;
40   @PartitionKey(value = 1)
41   @Frozen
42   private Version version;
43   @ClusteringColumn
44   @Column(name = "component_id")
45   private String componentId;
46   @ClusteringColumn(value = 1)
47   @Column(name = "artifact_type")
48   private MonitoringUploadType type;
49   @ClusteringColumn(value = 2)
50   @Column(name = "artifact_id")
51   private String id;
52   @Column(name = "name")
53   private String artifactName;
54   private ByteBuffer artifact;
55
56   /**
57    * Every entity class must have a default constructor according to
58    * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
59    * Definition of mapped classes</a>.
60    */
61   public ComponentMonitoringUploadEntity() {
62     // Don't delete! Default constructor is required by DataStax driver
63   }
64
65   /**
66    * Instantiates a new Component artifact entity.
67    *
68    * @param vspId       the vsp id
69    * @param version     the version
70    * @param componentId the component id
71    * @param id          the id
72    */
73   public ComponentMonitoringUploadEntity(String vspId, Version version, String componentId,
74                                          String id) {
75     this.vspId = vspId;
76     this.version = version;
77     this.componentId = componentId;
78     this.id = id;
79   }
80
81   public String getVspId() {
82     return vspId;
83   }
84
85   public void setVspId(String vspId) {
86     this.vspId = vspId;
87   }
88
89   public String getComponentId() {
90     return componentId;
91   }
92
93   public void setComponentId(String componentId) {
94     this.componentId = componentId;
95   }
96
97   @Override
98   public String getEntityType() {
99     return ENTITY_TYPE;
100   }
101
102   @Override
103   public String getFirstClassCitizenId() {
104     return getVspId();
105   }
106
107   public String getId() {
108     return id;
109   }
110
111   public void setId(String id) {
112     this.id = id;
113   }
114
115   public Version getVersion() {
116     return version;
117   }
118
119   public void setVersion(Version version) {
120     this.version = version;
121   }
122
123   public String getArtifactName() {
124     return artifactName;
125   }
126
127   public void setArtifactName(String artifactName) {
128     this.artifactName = artifactName;
129   }
130
131   public ByteBuffer getArtifact() {
132     return artifact;
133   }
134
135   public void setArtifact(ByteBuffer artifact) {
136     this.artifact = artifact;
137   }
138
139   public MonitoringUploadType getType() {
140     return type;
141   }
142
143   public void setType(MonitoringUploadType type) {
144     this.type = type;
145   }
146
147   @Override
148   public String toString() {
149     return "ComponentMonitoringUploadEntity{" +
150         "vspId='" + vspId + '\'' +
151         ", version=" + version +
152         ", componentId='" + componentId + '\'' +
153         ", type=" + type +
154         ", id='" + id + '\'' +
155         ", artifactName='" + artifactName + '\'' +
156         '}';
157   }
158 }