bc34b8dfdac00031761cb8144d15ece709649af6
[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.action.dao.types;
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 import org.openecomp.sdc.action.types.ActionArtifact;
27
28 import java.nio.ByteBuffer;
29
30 @Table(keyspace = "dox", name = "action_artifact")
31 public class ActionArtifactEntity {
32
33   @PartitionKey
34   @Column(name = "artifactuuid")
35   private String artifactUuId;
36
37   @PartitionKey(value = 1)
38   @Column(name = "effective_version")
39   private int effectiveVersion;
40
41   @Column(name = "artifact")
42   private ByteBuffer artifact;
43
44   /**
45    * Every entity class must have a default constructor according to
46    * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
47    * Definition of mapped classes</a>.
48    */
49   public ActionArtifactEntity() {
50     // Don't delete! Default constructor is required by DataStax driver
51   }
52
53   public ActionArtifactEntity(String artifactUuId, int effectiveVersion) {
54     this.artifactUuId = artifactUuId;
55     this.effectiveVersion = effectiveVersion;
56   }
57
58   public String getArtifactUuId() {
59     return artifactUuId;
60   }
61
62   public void setArtifactUuId(String artifactUuId) {
63     this.artifactUuId = artifactUuId;
64   }
65
66   public int getEffectiveVersion() {
67     return effectiveVersion;
68   }
69
70   public void setEffectiveVersion(int effectiveVersion) {
71     this.effectiveVersion = effectiveVersion;
72   }
73
74   public ByteBuffer getArtifact() {
75     return artifact;
76   }
77
78   public void setArtifact(ByteBuffer artifact) {
79     this.artifact = artifact;
80   }
81
82   /**
83    * To dto action artifact.
84    *
85    * @return the action artifact
86    */
87   public ActionArtifact toDto() {
88     ActionArtifact destination = new ActionArtifact();
89     destination.setArtifactUuId(this.getArtifactUuId());
90     destination.setEffectiveVersion(this.getEffectiveVersion());
91     destination.setArtifact(this.getArtifact().array());
92     return destination;
93   }
94 }