2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.vendorsoftwareproduct.dao.type;
23 import com.datastax.driver.mapping.annotations.*;
24 import lombok.EqualsAndHashCode;
26 import lombok.NoArgsConstructor;
28 import org.openecomp.core.utilities.json.JsonUtil;
29 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
30 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
31 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
32 import org.openecomp.sdc.versioning.dao.types.Version;
34 import java.util.ArrayList;
35 import java.util.List;
41 @Table(keyspace = "dox", name = "vsp_component")
42 public class ComponentEntity implements CompositionEntity {
43 public static final String ENTITY_TYPE = "Vendor Software Product Component";
46 @Column(name = "vsp_id")
48 @PartitionKey(value = 1)
50 private Version version;
52 @Column(name = "component_id")
54 @Column(name = "composition_data")
55 private String compositionData;
56 @Column(name = "questionnaire_data")
57 private String questionnaireData;
59 private List<NicEntity> nics = new ArrayList<>();
62 * Instantiates a new Component entity.
64 * @param vspId the vsp id
65 * @param version the version
68 public ComponentEntity(String vspId, Version version, String id) {
70 this.version = version;
75 public CompositionEntityType getType() {
76 return CompositionEntityType.component;
80 public CompositionEntityId getCompositionEntityId() {
81 return new CompositionEntityId(getId(), new CompositionEntityId(getVspId(), null));
85 public String getEntityType() {
90 public String getFirstClassCitizenId() {
94 public ComponentData getComponentCompositionData() {
95 return compositionData == null ? null
96 : JsonUtil.json2Object(compositionData, ComponentData.class);
99 public void setComponentCompositionData(ComponentData component) {
100 this.compositionData = component == null ? null : JsonUtil.object2Json(component);