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.io.Serializable;
26 import java.util.ArrayList;
27 import java.util.Comparator;
28 import java.util.List;
30 public class Resource implements Serializable {
32 private static final long serialVersionUID = 4259534487473481127L;
33 private String resourceId;
34 private WorkflowType resourceType;
35 private boolean generated;
36 private boolean baseVfModule;
37 private String virtualLinkKey;
38 private String vnfCustomizationId;
39 private String vfModuleCustomizationId;
40 private String cvnfModuleCustomizationId;
41 private String instanceName;
42 private String modelInvariantId;
43 private int processingPriority;
44 private Resource parent;
45 private List<Resource> children;
47 public static final Comparator<Resource> sortByPriorityAsc =
48 Comparator.comparingInt(Resource::getProcessingPriority);
49 public static final Comparator<Resource> sortByPriorityDesc =
50 Comparator.comparingInt(x -> -x.getProcessingPriority());
52 public Resource(WorkflowType resourceType, String resourceId, boolean generated, Resource parent) {
53 this.resourceId = resourceId;
54 this.resourceType = resourceType;
55 this.generated = generated;
56 this.processingPriority = 0;
57 this.children = new ArrayList<>();
60 this.parent.children.add(this);
63 public String getResourceId() {
67 public void setResourceId(String resourceId) {
68 this.resourceId = resourceId;
71 public WorkflowType getResourceType() {
75 public void setResourceType(WorkflowType resourceType) {
76 this.resourceType = resourceType;
79 public boolean isGenerated() {
83 public void setGenerated(boolean generated) {
84 this.generated = generated;
87 public boolean isBaseVfModule() {
91 public void setBaseVfModule(boolean baseVfModule) {
92 this.baseVfModule = baseVfModule;
95 public String getVirtualLinkKey() {
96 return virtualLinkKey;
99 public void setVirtualLinkKey(String virtualLinkKey) {
100 this.virtualLinkKey = virtualLinkKey;
103 public String getVnfCustomizationId() {
104 return vnfCustomizationId;
107 public void setVnfCustomizationId(String vnfCustomizationId) {
108 this.vnfCustomizationId = vnfCustomizationId;
111 public String getVfModuleCustomizationId() {
112 return vfModuleCustomizationId;
115 public void setVfModuleCustomizationId(String vfModuleCustomizationId) {
116 this.vfModuleCustomizationId = vfModuleCustomizationId;
119 public String getCvnfModuleCustomizationId() {
120 return cvnfModuleCustomizationId;
123 public void setCvnfModuleCustomizationId(String cvnfModuleCustomizationId) {
124 this.cvnfModuleCustomizationId = cvnfModuleCustomizationId;
127 public String getInstanceName() {
131 public void setInstanceName(String instanceName) {
132 this.instanceName = instanceName;
135 public String getModelInvariantId() {
136 return modelInvariantId;
139 public void setModelInvariantId(String modelInvariantId) {
140 this.modelInvariantId = modelInvariantId;
144 public int getProcessingPriority() {
145 return processingPriority == 0 ? (isBaseVfModule() ? Integer.MIN_VALUE + 1 : 0) : processingPriority;
148 public void setProcessingPriority(int processingPriority) {
149 this.processingPriority = processingPriority;
152 public Resource getParent() {
156 public List<Resource> getChildren() {
157 return this.children;
160 public Boolean hasParent() {
161 return parent != null;