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")
68 public ActionEntity() {
71 public ActionEntity(String actionInvariantUuId, Version version) {
72 this.actionInvariantUuId = actionInvariantUuId;
73 this.version = version;
76 public String getActionUuId() {
80 public void setActionUuId(String actionUuId) {
81 this.actionUuId = actionUuId;
84 public String getActionInvariantUuId() {
85 return actionInvariantUuId;
88 public void setActionInvariantUuId(String actionInvariantUuId) {
89 this.actionInvariantUuId = actionInvariantUuId;
92 public Version getVersion() {
96 public void setVersion(Version version) {
97 this.version = version;
100 public String getStatus() {
104 public void setStatus(String status) {
105 this.status = status;
108 public String getName() {
112 public void setName(String name) {
116 public List<String> getVendorList() {
123 * @param vendorList the vendor list
125 public void setVendorList(List<String> vendorList) {
126 if (vendorList != null && !vendorList.isEmpty()) {
127 List<String> lowerCaseVendorList = new ArrayList<String>();
129 .addAll(vendorList.stream().map(String::toLowerCase).collect(Collectors.toList()));
130 this.vendorList = lowerCaseVendorList;
132 this.vendorList = vendorList;
136 public List<String> getCategoryList() {
141 * Sets category list.
143 * @param categoryList the category list
145 public void setCategoryList(List<String> categoryList) {
146 if (categoryList != null && !categoryList.isEmpty()) {
147 List<String> lowerCaseCategoryList = new ArrayList<String>();
148 lowerCaseCategoryList
149 .addAll(categoryList.stream().map(String::toLowerCase).collect(Collectors.toList()));
150 this.categoryList = lowerCaseCategoryList;
152 this.categoryList = categoryList;
156 public Date getTimestamp() {
160 public void setTimestamp(Date timestamp) {
161 this.timestamp = timestamp;
164 public String getUser() {
168 public void setUser(String user) {
172 public List<String> getSupportedModels() {
173 return supportedModels;
176 public void setSupportedModels(List<String> supportedModels) {
177 this.supportedModels = supportedModels;
180 public List<String> getSupportedComponents() {
181 return supportedComponents;
184 public void setSupportedComponents(List<String> supportedComponents) {
185 this.supportedComponents = supportedComponents;
188 public String getData() {
192 public void setData(String data) {
201 public Action toDto() {
202 //Action destination = new Action();
204 Action destination = JsonUtil.json2Object(this.getData(), Action.class);
205 destination.setData(this.getData());
206 destination.setTimestamp(this.getTimestamp());
207 destination.setUser(this.getUser());
208 destination.setData(this.getData());