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.action.dao.types;
23 import com.datastax.driver.mapping.annotations.Column;
24 import com.datastax.driver.mapping.annotations.Frozen;
25 import com.datastax.driver.mapping.annotations.PartitionKey;
26 import com.datastax.driver.mapping.annotations.Table;
27 import org.openecomp.core.utilities.json.JsonUtil;
28 import org.openecomp.sdc.action.types.Action;
29 import org.openecomp.sdc.versioning.dao.types.Version;
31 import java.util.ArrayList;
32 import java.util.Date;
33 import java.util.List;
34 import java.util.stream.Collectors;
37 @Table(keyspace = "dox", name = "Action")
38 public class ActionEntity {
40 @Column(name = "actionUuId")
41 private String actionUuId;
42 @PartitionKey(value = 0)
43 @Column(name = "actionInvariantUuId")
44 private String actionInvariantUuId;
45 @PartitionKey(value = 1)
47 @Column(name = "version")
48 private Version version;
49 @Column(name = "status")
50 private String status;
51 @Column(name = "name")
53 @Column(name = "vendor_list")
54 private List<String> vendorList;
55 @Column(name = "category_list")
56 private List<String> categoryList;
57 @Column(name = "timestamp")
58 private Date timestamp;
59 @Column(name = "user")
61 @Column(name = "supportedModels")
62 private List<String> supportedModels;
63 @Column(name = "supportedComponents")
64 private List<String> supportedComponents;
65 @Column(name = "data")
69 * Every entity class must have a default constructor according to
70 * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
71 * Definition of mapped classes</a>.
73 public ActionEntity() {
74 // Don't delete! Default constructor is required by DataStax driver
77 public ActionEntity(String actionInvariantUuId, Version version) {
78 this.actionInvariantUuId = actionInvariantUuId;
79 this.version = version;
82 public String getActionUuId() {
86 public void setActionUuId(String actionUuId) {
87 this.actionUuId = actionUuId;
90 public String getActionInvariantUuId() {
91 return actionInvariantUuId;
94 public void setActionInvariantUuId(String actionInvariantUuId) {
95 this.actionInvariantUuId = actionInvariantUuId;
98 public Version getVersion() {
102 public void setVersion(Version version) {
103 this.version = version;
106 public String getStatus() {
110 public void setStatus(String status) {
111 this.status = status;
114 public String getName() {
118 public void setName(String name) {
122 public List<String> getVendorList() {
129 * @param vendorList the vendor list
131 public void setVendorList(List<String> vendorList) {
132 if (vendorList != null && !vendorList.isEmpty()) {
133 List<String> lowerCaseVendorList = new ArrayList<>();
135 .addAll(vendorList.stream().map(String::toLowerCase).collect(Collectors.toList()));
136 this.vendorList = lowerCaseVendorList;
138 this.vendorList = vendorList;
142 public List<String> getCategoryList() {
147 * Sets category list.
149 * @param categoryList the category list
151 public void setCategoryList(List<String> categoryList) {
152 if (categoryList != null && !categoryList.isEmpty()) {
153 List<String> lowerCaseCategoryList = new ArrayList<>();
154 lowerCaseCategoryList
155 .addAll(categoryList.stream().map(String::toLowerCase).collect(Collectors.toList()));
156 this.categoryList = lowerCaseCategoryList;
158 this.categoryList = categoryList;
162 public Date getTimestamp() {
166 public void setTimestamp(Date timestamp) {
167 this.timestamp = timestamp;
170 public String getUser() {
174 public void setUser(String user) {
178 public List<String> getSupportedModels() {
179 return supportedModels;
182 public void setSupportedModels(List<String> supportedModels) {
183 this.supportedModels = supportedModels;
186 public List<String> getSupportedComponents() {
187 return supportedComponents;
190 public void setSupportedComponents(List<String> supportedComponents) {
191 this.supportedComponents = supportedComponents;
194 public String getData() {
198 public void setData(String data) {
207 public Action toDto() {
208 Action destination = JsonUtil.json2Object(this.getData(), Action.class);
209 destination.setData(this.getData());
210 destination.setTimestamp(this.getTimestamp());
211 destination.setUser(this.getUser());
212 destination.setData(this.getData());