2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.action.dao.types;
19 import com.datastax.driver.mapping.annotations.Column;
20 import com.datastax.driver.mapping.annotations.Frozen;
21 import com.datastax.driver.mapping.annotations.PartitionKey;
22 import com.datastax.driver.mapping.annotations.Table;
24 import java.util.Date;
26 import java.util.stream.Collectors;
28 import org.openecomp.core.utilities.json.JsonUtil;
29 import org.openecomp.sdc.action.types.Action;
30 import org.openecomp.sdc.versioning.dao.types.Version;
33 @Table(keyspace = "dox", name = "Action")
34 public class ActionEntity {
36 @Column(name = "actionUuId")
37 private String actionUuId;
38 @PartitionKey(value = 0)
39 @Column(name = "actionInvariantUuId")
40 private String actionInvariantUuId;
41 @PartitionKey(value = 1)
43 @Column(name = "version")
44 private Version version;
45 @Column(name = "status")
46 private String status;
47 @Column(name = "name")
49 @Column(name = "vendor_list")
50 private Set<String> vendorList;
51 @Column(name = "category_list")
52 private Set<String> categoryList;
53 @Column(name = "timestamp")
54 private Date timestamp;
55 @Column(name = "user")
57 @Column(name = "supportedModels")
58 private Set<String> supportedModels;
59 @Column(name = "supportedComponents")
60 private Set<String> supportedComponents;
61 @Column(name = "data")
65 * Every entity class must have a default constructor according to
66 * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
67 * Definition of mapped classes</a>.
69 public ActionEntity() {
70 // Don't delete! Default constructor is required by DataStax driver
73 public ActionEntity(String actionInvariantUuId, Version version) {
74 this.actionInvariantUuId = actionInvariantUuId;
75 this.version = version;
78 public String getActionUuId() {
82 public void setActionUuId(String actionUuId) {
83 this.actionUuId = actionUuId;
86 public String getActionInvariantUuId() {
87 return actionInvariantUuId;
90 public void setActionInvariantUuId(String actionInvariantUuId) {
91 this.actionInvariantUuId = actionInvariantUuId;
94 public Version getVersion() {
98 public void setVersion(Version version) {
99 this.version = version;
102 public String getStatus() {
106 public void setStatus(String status) {
107 this.status = status;
110 public String getName() {
114 public void setName(String name) {
118 public Set<String> getVendorList() {
125 * @param vendorList the vendor list
127 public void setVendorList(Set<String> vendorList) {
128 this.vendorList = vendorList != null && !vendorList.isEmpty() ?
129 vendorList.stream().map(String::toLowerCase).collect(Collectors.toSet()) : vendorList;
132 public Set<String> getCategoryList() {
137 * Sets category list.
139 * @param categoryList the category list
141 public void setCategoryList(Set<String> categoryList) {
142 this.categoryList = categoryList != null && !categoryList.isEmpty() ?
143 categoryList.stream().map(String::toLowerCase).collect(Collectors.toSet()) :
147 public Date getTimestamp() {
151 public void setTimestamp(Date timestamp) {
152 this.timestamp = timestamp;
155 public String getUser() {
159 public void setUser(String user) {
163 public Set<String> getSupportedModels() {
164 return supportedModels;
167 public void setSupportedModels(Set<String> supportedModels) {
168 this.supportedModels = supportedModels;
171 public Set<String> getSupportedComponents() {
172 return supportedComponents;
175 public void setSupportedComponents(Set<String> supportedComponents) {
176 this.supportedComponents = supportedComponents;
179 public String getData() {
183 public void setData(String data) {
192 public Action toDto() {
193 Action destination = JsonUtil.json2Object(this.getData(), Action.class);
194 destination.setData(this.getData());
195 destination.setTimestamp(this.getTimestamp());
196 destination.setUser(this.getUser());
197 destination.setData(this.getData());