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_artifact")
36 public class EnrichedServiceArtifactEntity implements ServiceElementEntity {
37 private static final String ENTITY_TYPE;
40 ENTITY_TYPE = "Vendor Software Product Service artifact";
44 @Column(name = "vsp_id")
47 @PartitionKey(value = 1)
49 public Version version;
52 @Column(name = "name")
55 @Column(name = "content_data")
56 public ByteBuffer contentData;
58 public EnrichedServiceArtifactEntity() {
62 * Instantiates a new Enriched service artifact entity.
64 * @param entity the entity
66 public EnrichedServiceArtifactEntity(ServiceArtifact entity) {
67 this.id = entity.getVspId();
68 this.version = entity.getVersion();
69 this.name = entity.getName();
72 this.contentData = ByteBuffer.wrap(ByteStreams.toByteArray(entity.getContent()));
73 } catch (IOException ioException) {
74 throw new RuntimeException(ioException);
80 public String getEntityType() {
85 public String getFirstClassCitizenId() {
89 public String getId() {
93 public void setId(String id) {
98 public Version getVersion() {
103 public void setVersion(Version version) {
104 this.version = version;
107 public String getName() {
111 public void setName(String name) {
115 public ByteBuffer getContentData() {
119 public void setContentData(ByteBuffer contentData) {
120 this.contentData = contentData;
124 * Gets service artifact.
126 * @return the service artifact
128 public ServiceArtifact getServiceArtifact() {
129 ServiceArtifact serviceArtifact = new ServiceArtifact();
130 serviceArtifact.setName(this.getName());
131 serviceArtifact.setVersion(this.getVersion());
132 serviceArtifact.setContentData(this.getContentData().array());
133 serviceArtifact.setVspId(this.getId());
134 return serviceArtifact;