push addional code
[sdc.git] / openecomp-be / lib / openecomp-sdc-action-lib / openecomp-sdc-action-api / src / main / java / org / openecomp / sdc / action / dao / types / ActionEntity.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.action.dao.types;
22
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;
30
31
32 import java.util.ArrayList;
33 import java.util.Date;
34 import java.util.List;
35 import java.util.stream.Collectors;
36
37 @Table(keyspace = "dox", name = "Action")
38 public class ActionEntity {
39
40   @Column(name = "actionUUID")
41   private String actionUuId;
42   @PartitionKey(value = 0)
43   @Column(name = "actionInvariantUUID")
44   private String actionInvariantUuId;
45   @PartitionKey(value = 1)
46   @Frozen
47   @Column(name = "version")
48   private Version version;
49   @Column(name = "status")
50   private String status;
51   @Column(name = "name")
52   private String 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")
60   private String user;
61   @Column(name = "supportedModels")
62   private List<String> supportedModels;
63   @Column(name = "supportedComponents")
64   private List<String> supportedComponents;
65   @Column(name = "data")
66   private String data;
67
68   public ActionEntity() {
69   }
70
71   public ActionEntity(String actionInvariantUuId, Version version) {
72     this.actionInvariantUuId = actionInvariantUuId;
73     this.version = version;
74   }
75
76   public String getActionUuId() {
77     return actionUuId;
78   }
79
80   public void setActionUuId(String actionUuId) {
81     this.actionUuId = actionUuId;
82   }
83
84   public String getActionInvariantUuId() {
85     return actionInvariantUuId;
86   }
87
88   public void setActionInvariantUuId(String actionInvariantUuId) {
89     this.actionInvariantUuId = actionInvariantUuId;
90   }
91
92   public Version getVersion() {
93     return version;
94   }
95
96   public void setVersion(Version version) {
97     this.version = version;
98   }
99
100   public String getStatus() {
101     return status;
102   }
103
104   public void setStatus(String status) {
105     this.status = status;
106   }
107
108   public String getName() {
109     return name;
110   }
111
112   public void setName(String name) {
113     this.name = name;
114   }
115
116   public List<String> getVendorList() {
117     return vendorList;
118   }
119
120   /**
121    * Sets vendor list.
122    *
123    * @param vendorList the vendor list
124    */
125   public void setVendorList(List<String> vendorList) {
126     if (vendorList != null && !vendorList.isEmpty()) {
127       List<String> lowerCaseVendorList = new ArrayList<>();
128       lowerCaseVendorList
129           .addAll(vendorList.stream().map(String::toLowerCase).collect(Collectors.toList()));
130       this.vendorList = lowerCaseVendorList;
131     } else {
132       this.vendorList = vendorList;
133     }
134   }
135
136   public List<String> getCategoryList() {
137     return categoryList;
138   }
139
140   /**
141    * Sets category list.
142    *
143    * @param categoryList the category list
144    */
145   public void setCategoryList(List<String> categoryList) {
146     if (categoryList != null && !categoryList.isEmpty()) {
147       List<String> lowerCaseCategoryList = new ArrayList<>();
148       lowerCaseCategoryList
149           .addAll(categoryList.stream().map(String::toLowerCase).collect(Collectors.toList()));
150       this.categoryList = lowerCaseCategoryList;
151     } else {
152       this.categoryList = categoryList;
153     }
154   }
155
156   public Date getTimestamp() {
157     return timestamp;
158   }
159
160   public void setTimestamp(Date timestamp) {
161     this.timestamp = timestamp;
162   }
163
164   public String getUser() {
165     return user;
166   }
167
168   public void setUser(String user) {
169     this.user = user;
170   }
171
172   public List<String> getSupportedModels() {
173     return supportedModels;
174   }
175
176   public void setSupportedModels(List<String> supportedModels) {
177     this.supportedModels = supportedModels;
178   }
179
180   public List<String> getSupportedComponents() {
181     return supportedComponents;
182   }
183
184   public void setSupportedComponents(List<String> supportedComponents) {
185     this.supportedComponents = supportedComponents;
186   }
187
188   public String getData() {
189     return data;
190   }
191
192   public void setData(String data) {
193     this.data = data;
194   }
195
196   /**
197    * To dto action.
198    *
199    * @return the action
200    */
201   public Action toDto() {
202     //Action destination = new Action();
203
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());
209     return destination;
210   }
211
212   /*private List<HashMap<String,String>> createMapFromList(List<String> list, String idName){
213         List<HashMap<String,String>> keyValueList = new ArrayList<>();
214         if(list != null && !list.isEmpty()){
215             for(String attributeId : list){
216                 HashMap<String,String> attributeIdMap = new HashMap<>();
217                 attributeIdMap.put(idName,attributeId);
218                 keyValueList.add(attributeIdMap);
219             }
220             return keyValueList;
221         }
222         return null;
223   }*/
224 }