dd145b1f54a6304cbd4fdccc335e2d3aa80973e7
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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.*;
24 import lombok.EqualsAndHashCode;
25 import lombok.Getter;
26 import lombok.NoArgsConstructor;
27 import lombok.Setter;
28 import org.openecomp.core.utilities.json.JsonUtil;
29 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
30 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
31 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
32 import org.openecomp.sdc.versioning.dao.types.Version;
33
34 @EqualsAndHashCode
35 @Getter
36 @Setter
37 @NoArgsConstructor
38 @Table(keyspace = "dox", name = "vsp_deployment_flavor")
39 public class DeploymentFlavorEntity implements CompositionEntity{
40     private static final String ENTITY_TYPE = "Vendor Software Product Deployment Flavor";
41
42     @PartitionKey
43     @Column(name = "vsp_id")
44     private String vspId;
45     @PartitionKey(value = 1)
46     @Frozen
47     private Version version;
48     @ClusteringColumn
49     @Column(name = "deployment_flavor_id")
50     private String id;
51     @Column(name = "composition_data")
52     private String compositionData;
53     @Column(name = "questionnaire_data")
54     private String questionnaireData;
55
56     /**
57      * Instantiates a new DeploymentFlavor entity.
58      *
59      * @param vspId   the vsp id
60      * @param version the version
61      * @param id      the id
62      */
63     public DeploymentFlavorEntity(String vspId, Version version, String id) {
64         this.vspId = vspId;
65         this.version = version;
66         this.id = id;
67     }
68     @Override
69     public CompositionEntityType getType() {
70         return CompositionEntityType.deployment;
71     }
72
73     @Override
74     public CompositionEntityId getCompositionEntityId() {
75         return new CompositionEntityId(getId(), new CompositionEntityId(getVspId(), null));
76     }
77
78     @Override
79     public String getEntityType() {
80         return ENTITY_TYPE;
81     }
82
83     @Override
84     public String getFirstClassCitizenId() {
85         return getVspId();
86     }
87
88    public DeploymentFlavor getDeploymentFlavorCompositionData() {
89         return compositionData == null ? null : JsonUtil.json2Object(compositionData, DeploymentFlavor.class);
90     }
91
92     public void setDeploymentFlavorCompositionData(DeploymentFlavor deploymentFlavor) {
93         this.compositionData = deploymentFlavor == null ? null : JsonUtil.object2Json(deploymentFlavor);
94     }
95 }