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=========================================================
20 package org.openecomp.sdc.be.components.distribution.engine;
22 import java.util.ArrayList;
23 import java.util.LinkedList;
24 import java.util.List;
26 import java.util.stream.Collectors;
27 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
28 import org.openecomp.sdc.be.model.GroupDefinition;
29 import org.openecomp.sdc.be.model.GroupInstance;
30 import org.openecomp.sdc.be.model.GroupInstanceProperty;
31 import org.openecomp.sdc.common.api.Constants;
33 public class VfModuleArtifactPayload {
35 private String vfModuleModelName;
36 private List<String> artifacts;
37 private Map<String, Object> properties;
39 public VfModuleArtifactPayload(GroupDefinition group) {
40 vfModuleModelName = group.getName();
41 artifacts = group.getArtifactsUuid();
42 // Base Value is set from properties
45 public VfModuleArtifactPayload(GroupInstance group) {
46 vfModuleModelName = group.getGroupName();
47 artifacts = new ArrayList<>(group.getArtifactsUuid() != null ? group.getArtifactsUuid() : new LinkedList<>());
48 artifacts.addAll(group.getGroupInstanceArtifactsUuid() != null ? group.getGroupInstanceArtifactsUuid() : new LinkedList<>());
49 // Base Value is set from properties
50 if (group.convertToGroupInstancesProperties() != null) {
51 setProperties(group.convertToGroupInstancesProperties());
55 public static int compareByGroupName(VfModuleArtifactPayload art1, VfModuleArtifactPayload art2) {
56 Float thisCounter = Float.parseFloat(art1.vfModuleModelName.split(Constants.MODULE_NAME_DELIMITER)[1].replace(' ', '.'));
57 Float otherCounter = Float.parseFloat(art2.vfModuleModelName.split(Constants.MODULE_NAME_DELIMITER)[1].replace(' ', '.'));
58 return thisCounter.compareTo(otherCounter);
61 public List<String> getArtifacts() {
65 public void setArtifacts(List<String> artifacts) {
66 this.artifacts = artifacts;
69 public Map<String, Object> getProperties() {
73 public void setProperties(List<GroupInstanceProperty> properties) {
74 this.properties = properties.stream().filter(p -> !p.getName().equals(Constants.IS_BASE))
75 .collect(Collectors.toMap(PropertyDataDefinition::getName, x -> x.getValue() == null ? "" : x.getValue()));