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.be.model;
23 import java.io.Serializable;
24 import java.util.List;
25 import java.util.stream.Collectors;
27 import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
28 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
30 public class GroupDefinition extends GroupDataDefinition implements Serializable {
34 private static final long serialVersionUID = -852613634651112247L;
36 // properties (properties should be defined in the group type, the
37 // properties here are actually the value for the properties)
42 // The unique id of the type of this group
45 public GroupDefinition() {
49 public GroupDefinition(GroupDataDefinition other) {
53 public GroupDefinition(GroupDefinition other) {
54 this.setName(other.getName());
55 this.setUniqueId(other.getUniqueId());
56 this.setType(other.getType());
57 this.setVersion(other.getVersion());
58 this.setInvariantUUID(other.getInvariantUUID());
59 this.setGroupUUID(other.getGroupUUID());
60 this.setDescription(other.getDescription());
61 this.setTypeUid(other.getTypeUid());
62 this.setProperties(other.getProperties());
66 public List<GroupProperty> convertToGroupProperties() {
67 List<GroupProperty> properties = null;
68 List<PropertyDataDefinition> propList = super.getProperties();
69 if(propList != null && !propList .isEmpty()){
70 properties = propList.stream().map(pr -> new GroupProperty(pr)).collect(Collectors.toList());
75 public void convertFromGroupProperties(List<GroupProperty> properties) {
76 if(properties != null && !properties .isEmpty()){
77 List<PropertyDataDefinition> propList = properties.stream().map(pr -> new PropertyDataDefinition(pr)).collect(Collectors.toList());
78 super.setProperties(propList);
83 //returns true iff groupName has the same prefix has the resource
84 public boolean isSamePrefix(String resourceName){
85 String name = this.getName();
86 if ( name != null && name.toLowerCase().trim().startsWith(resourceName.toLowerCase()))