Added oparent to sdc main
[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 / ComputeEntity.java
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 org.openecomp.core.utilities.json.JsonUtil;
25 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
26 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
27 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
28 import org.openecomp.sdc.versioning.dao.types.Version;
29
30 @Table(keyspace = "dox", name = "vsp_component_compute")
31 public class ComputeEntity implements CompositionEntity {
32   public static final String ENTITY_TYPE = "Vendor Software Product Component Compute Flavor";
33
34   @PartitionKey
35   @Column(name = "vsp_id")
36   private String vspId;
37   @PartitionKey(value = 1)
38   @Frozen
39   private Version version;
40   @ClusteringColumn
41   @Column(name = "component_id")
42   private String componentId;
43   @ClusteringColumn(value = 1)
44   @Column(name = "compute_id")
45   private String id;
46   @Column(name = "composition_data")
47   private String compositionData;
48   @Column(name = "questionnaire_data")
49   private String questionnaireData;
50
51   /**
52    * Every entity class must have a default constructor according to
53    * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
54    * Definition of mapped classes</a>.
55    */
56   public ComputeEntity() {
57     // Don't delete! Default constructor is required by DataStax driver
58   }
59
60   public ComputeEntity(String vspId, Version version, String componentId, String id) {
61     this.vspId = vspId;
62     this.version = version;
63     this.componentId = componentId;
64     this.id = id;
65   }
66
67   @Override
68   public String getEntityType() {
69     return ENTITY_TYPE;
70   }
71
72   @Override
73   public String getFirstClassCitizenId() {
74     return getVspId();
75   }
76
77   @Override
78   public String getId() {
79     return id;
80   }
81
82   @Override
83   public void setId(String id) {
84     this.id = id;
85   }
86
87   @Override
88   public Version getVersion() {
89     return version;
90   }
91
92   @Override
93   public void setVersion(Version version) {
94     this.version = version;
95   }
96
97   @Override
98   public CompositionEntityType getType() {
99     return CompositionEntityType.compute;
100   }
101
102   @Override
103   public CompositionEntityId getCompositionEntityId() {
104     return new CompositionEntityId(getId(),
105         new CompositionEntityId(getComponentId(), new CompositionEntityId(getVspId(), null)));
106   }
107
108   @Override
109   public String getCompositionData() {
110     return compositionData;
111   }
112
113   @Override
114   public void setCompositionData(String compositionData) {
115     this.compositionData = compositionData;
116   }
117
118   @Override
119   public String getQuestionnaireData() {
120     return questionnaireData;
121   }
122
123   @Override
124   public void setQuestionnaireData(String questionnaireData) {
125     this.questionnaireData = questionnaireData;
126   }
127
128   public String getVspId() {
129     return vspId;
130   }
131
132   public void setVspId(String vspId) {
133     this.vspId = vspId;
134   }
135
136   public String getComponentId() {
137     return componentId;
138   }
139
140   public void setComponentId(String componentId) {
141     this.componentId = componentId;
142   }
143
144   public ComputeData getComputeCompositionData() {
145     return compositionData == null ? null
146         : JsonUtil.json2Object(compositionData, ComputeData.class);
147   }
148
149   public void setComputeCompositionData(ComputeData computeData){
150     this.compositionData = computeData == null ? null : JsonUtil.object2Json(computeData);
151   }
152
153
154 }