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=========================================================
20 package org.openecomp.sdc.be.ui.model;
22 import com.fasterxml.jackson.annotation.JsonIgnore;
23 import java.util.List;
26 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
27 import org.openecomp.sdc.be.model.Component;
28 import org.openecomp.sdc.be.model.category.CategoryDefinition;
29 import org.openecomp.sdc.common.util.ICategorizedElement;
33 public class UiLeftPaletteComponent implements ICategorizedElement {
35 private final String uniqueId;
36 private final String name; // archiveName
38 private final String version; // archiveVersion
39 private final String description;
40 private final List<String> tags;
41 private final String icon;
42 private final String UUID;
43 private final String systemName;
44 private final String invariantUUID;
45 private final ComponentTypeEnum componentType;
46 private final String resourceType;
47 private final String categoryName;
48 private final String subCategoryName;
49 private final String searchFilterTerms;
50 private final List<CategoryDefinition> categories;
52 public UiLeftPaletteComponent(final Component component) {
53 this.uniqueId = component.getUniqueId();
54 this.name = component.getName();
55 this.version = component.getVersion();
56 this.description = component.getDescription();
57 this.tags = component.getTags();
58 this.icon = component.getIcon();
59 this.UUID = component.getUUID();
60 this.systemName = component.getSystemName();
61 this.invariantUUID = component.getInvariantUUID();
62 this.componentType = component.getComponentType();
63 this.resourceType = component.getActualComponentType();
64 this.categories = component.getCategories();
65 this.categoryName = getCategoryName();
66 this.subCategoryName = getSubcategoryName();
67 this.searchFilterTerms = (name + " " + description + " " + convertListResultToString(tags) + version);
70 private String convertListResultToString(final List<String> tags) {
71 final StringBuilder sb = new StringBuilder();
73 tags.forEach(t -> sb.append(t + " "));
75 return sb.toString().toLowerCase();
80 public String getComponentTypeAsString() {
81 return componentType.name();
85 public String getCategoryName() {
86 return categories.get(0).getName();
90 public String getSubcategoryName() {
91 if (componentType == ComponentTypeEnum.SERVICE) {
94 return categories.get(0).getSubcategories().get(0).getName();