2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 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.be.ui.model;
23 import com.fasterxml.jackson.annotation.JsonIgnore;
24 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
25 import org.openecomp.sdc.be.model.Component;
26 import org.openecomp.sdc.be.model.category.CategoryDefinition;
27 import org.openecomp.sdc.common.util.ICategorizedElement;
29 import java.util.List;
31 public class UiLeftPaletteComponent implements ICategorizedElement {
32 private String uniqueId;
33 private String name; // archiveName
34 private String version; // archiveVersion
35 private String description;
36 private List<String> tags;
39 private String systemName;
40 private String invariantUUID;
41 private ComponentTypeEnum componentType;
42 private String resourceType;
43 private String categoryName;
44 private String subCategoryName;
45 private String searchFilterTerms;
46 private List<CategoryDefinition> categories;
48 public UiLeftPaletteComponent(Component component) {
49 this.uniqueId = component.getUniqueId();
50 this.name = component.getName();
51 this.version = component.getVersion();
52 this.description = component.getDescription();
53 this.tags = component.getTags();
54 this.icon = component.getIcon();
55 this.UUID = component.getUUID();
56 this.systemName = component.getSystemName();
57 this.invariantUUID = component.getInvariantUUID();
58 this.componentType = component.getComponentType();
59 this.resourceType = component.getActualComponentType();
60 this.categories = component.getCategories();
61 this.categoryName = getCategoryName();
62 this.subCategoryName = getSubcategoryName();
63 String tagString = convertListResultToString(tags);
64 setSearchFilterTerms(name + " " + description + " " + tagString + version);
65 this.searchFilterTerms = getSearchFilterTerms();
68 private String convertListResultToString(List<String> tags) {
69 StringBuilder sb = new StringBuilder();
70 tags.forEach(t->sb.append(t + " "));
71 return sb.toString().toLowerCase();
74 public String getUniqueId() {
78 public String getName() {
82 public String getVersion() {
86 public String getDescription() {
90 public List<String> getTags() {
93 public String getIcon() {
97 public String getUUID() {
101 public String getSystemName() {
105 public String getInvariantUUID() {
106 return invariantUUID;
109 public ComponentTypeEnum getComponentType() {
110 return componentType;
113 public String getResourceType() {
117 public List<CategoryDefinition> getCategories() {
121 public String getSearchFilterTerms() {
122 return searchFilterTerms;
125 public void setSearchFilterTerms(String searchFilterTerms) {
126 this.searchFilterTerms = searchFilterTerms;
131 public String getComponentTypeAsString() {
132 return getComponentType().name();
136 public String getCategoryName() {
137 return getCategories().get(0).getName();
141 public String getSubcategoryName() {
142 if(componentType == ComponentTypeEnum.SERVICE){
145 return getCategories().get(0).getSubcategories().get(0).getName();