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.core.model.types;
23 import com.google.common.io.ByteStreams;
25 import com.datastax.driver.mapping.annotations.ClusteringColumn;
26 import com.datastax.driver.mapping.annotations.Column;
27 import com.datastax.driver.mapping.annotations.Frozen;
28 import com.datastax.driver.mapping.annotations.PartitionKey;
29 import com.datastax.driver.mapping.annotations.Table;
30 import org.openecomp.sdc.versioning.dao.types.Version;
32 import java.io.IOException;
33 import java.nio.ByteBuffer;
35 @Table(keyspace = "dox", name = "vsp_enriched_service_template")
36 public class EnrichedServiceTemplateEntity implements ServiceElementEntity {
38 private static final String ENTITY_TYPE;
41 ENTITY_TYPE = "Vendor Software Product Service model";
45 @Column(name = "vsp_id")
48 @PartitionKey(value = 1)
50 public Version version;
53 @Column(name = "name")
56 @Column(name = "content_data")
57 public ByteBuffer contentData;
60 @Column(name = "base_name")
61 private String baseName;
63 public EnrichedServiceTemplateEntity() {
67 * Instantiates a new Enriched service template entity.
69 * @param entity the entity
71 public EnrichedServiceTemplateEntity(ServiceTemplate entity) {
72 this.id = entity.getVspId();
73 this.version = entity.getVersion();
74 this.name = entity.getName();
75 this.setBaseName(entity.getBaseName());
77 this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent()));
78 } catch (IOException ioException) {
79 throw new RuntimeException(ioException);
85 public String getBaseName() {
89 public void setBaseName(String baseName) {
90 this.baseName = baseName;
95 public String getEntityType() {
100 public String getFirstClassCitizenId() {
104 public String getId() {
108 public void setId(String id) {
113 public Version getVersion() {
118 public void setVersion(Version version) {
119 this.version = version;
122 public String getName() {
126 public void setName(String name) {
130 public ByteBuffer getContentData() {
134 public void setContentData(ByteBuffer contentData) {
135 this.contentData = contentData;
140 * Gets service template.
142 * @return the service template
144 public ServiceTemplate getServiceTemplate() {
145 ServiceTemplate serviceTemplate = new ServiceTemplate();
146 serviceTemplate.setName(this.getName());
147 serviceTemplate.setVersion(this.getVersion());
148 serviceTemplate.setContentData(this.getContentData().array());
149 serviceTemplate.setVspId(this.getId());
150 serviceTemplate.setBaseName(this.getBaseName());
151 return serviceTemplate;