2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2021 Orange
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.infrastructure.workflow.tasks;
25 import java.util.ArrayList;
26 import java.util.Comparator;
27 import java.util.List;
29 public class Resource {
31 private String resourceId;
32 private WorkflowType resourceType;
33 private boolean generated;
34 private boolean baseVfModule;
35 private String virtualLinkKey;
36 private String vnfCustomizationId;
37 private String vfModuleCustomizationId;
38 private String cvnfModuleCustomizationId;
39 private String instanceName;
40 private int processingPriority;
41 private Resource parent;
42 private List<Resource> children;
44 public static final Comparator<Resource> sortByPriorityAsc =
45 Comparator.comparingInt(Resource::getProcessingPriority);
46 public static final Comparator<Resource> sortByPriorityDesc =
47 Comparator.comparingInt(x -> -x.getProcessingPriority());
49 public Resource(WorkflowType resourceType, String resourceId, boolean generated, Resource parent) {
50 this.resourceId = resourceId;
51 this.resourceType = resourceType;
52 this.generated = generated;
53 this.processingPriority = 0;
54 this.children = new ArrayList<>();
57 this.parent.children.add(this);
60 public String getResourceId() {
64 public void setResourceId(String resourceId) {
65 this.resourceId = resourceId;
68 public WorkflowType getResourceType() {
72 public void setResourceType(WorkflowType resourceType) {
73 this.resourceType = resourceType;
76 public boolean isGenerated() {
80 public void setGenerated(boolean generated) {
81 this.generated = generated;
84 public boolean isBaseVfModule() {
88 public void setBaseVfModule(boolean baseVfModule) {
89 this.baseVfModule = baseVfModule;
92 public String getVirtualLinkKey() {
93 return virtualLinkKey;
96 public void setVirtualLinkKey(String virtualLinkKey) {
97 this.virtualLinkKey = virtualLinkKey;
100 public String getVnfCustomizationId() {
101 return vnfCustomizationId;
104 public void setVnfCustomizationId(String vnfCustomizationId) {
105 this.vnfCustomizationId = vnfCustomizationId;
108 public String getVfModuleCustomizationId() {
109 return vfModuleCustomizationId;
112 public void setVfModuleCustomizationId(String vfModuleCustomizationId) {
113 this.vfModuleCustomizationId = vfModuleCustomizationId;
116 public String getCvnfModuleCustomizationId() {
117 return cvnfModuleCustomizationId;
120 public void setCvnfModuleCustomizationId(String cvnfModuleCustomizationId) {
121 this.cvnfModuleCustomizationId = cvnfModuleCustomizationId;
124 public String getInstanceName() {
128 public void setInstanceName(String instanceName) {
129 this.instanceName = instanceName;
132 public int getProcessingPriority() {
133 return processingPriority == 0 ? (isBaseVfModule() ? Integer.MIN_VALUE + 1 : 0) : processingPriority;
136 public void setProcessingPriority(int processingPriority) {
137 this.processingPriority = processingPriority;
140 public Resource getParent() {
144 public List<Resource> getChildren() {
145 return this.children;