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 String modelVersionId;
44 private String modelCustomizationId;
45 private int processingPriority;
46 private Resource parent;
47 private List<Resource> children;
49 public static final Comparator<Resource> sortByPriorityAsc =
50 Comparator.comparingInt(Resource::getProcessingPriority);
51 public static final Comparator<Resource> sortByPriorityDesc =
52 Comparator.comparingInt(x -> -x.getProcessingPriority());
54 public Resource(WorkflowType resourceType, String resourceId, boolean generated, Resource parent) {
55 this.resourceId = resourceId;
56 this.resourceType = resourceType;
57 this.generated = generated;
58 this.processingPriority = 0;
59 this.children = new ArrayList<>();
62 this.parent.children.add(this);
65 public String getResourceId() {
69 public void setResourceId(String resourceId) {
70 this.resourceId = resourceId;
73 public WorkflowType getResourceType() {
77 public void setResourceType(WorkflowType resourceType) {
78 this.resourceType = resourceType;
81 public boolean isGenerated() {
85 public void setGenerated(boolean generated) {
86 this.generated = generated;
89 public boolean isBaseVfModule() {
93 public void setBaseVfModule(boolean baseVfModule) {
94 this.baseVfModule = baseVfModule;
97 public String getVirtualLinkKey() {
98 return virtualLinkKey;
101 public void setVirtualLinkKey(String virtualLinkKey) {
102 this.virtualLinkKey = virtualLinkKey;
105 public String getVnfCustomizationId() {
106 return vnfCustomizationId;
109 public void setVnfCustomizationId(String vnfCustomizationId) {
110 this.vnfCustomizationId = vnfCustomizationId;
113 public String getVfModuleCustomizationId() {
114 return vfModuleCustomizationId;
117 public void setVfModuleCustomizationId(String vfModuleCustomizationId) {
118 this.vfModuleCustomizationId = vfModuleCustomizationId;
121 public String getCvnfModuleCustomizationId() {
122 return cvnfModuleCustomizationId;
125 public void setCvnfModuleCustomizationId(String cvnfModuleCustomizationId) {
126 this.cvnfModuleCustomizationId = cvnfModuleCustomizationId;
129 public String getInstanceName() {
133 public void setInstanceName(String instanceName) {
134 this.instanceName = instanceName;
137 public String getModelInvariantId() {
138 return modelInvariantId;
141 public void setModelInvariantId(String modelInvariantId) {
142 this.modelInvariantId = modelInvariantId;
145 public String getModelVersionId() {
146 return modelVersionId;
149 public void setModelVersionId(String modelVersionId) {
150 this.modelVersionId = modelVersionId;
153 public String getModelCustomizationId() {
154 return modelCustomizationId;
157 public void setModelCustomizationId(String modelCustomizationId) {
158 this.modelCustomizationId = modelCustomizationId;
161 public int getProcessingPriority() {
162 return processingPriority == 0 ? (isBaseVfModule() ? Integer.MIN_VALUE + 1 : 0) : processingPriority;
165 public void setProcessingPriority(int processingPriority) {
166 this.processingPriority = processingPriority;
169 public Resource getParent() {
173 public List<Resource> getChildren() {
174 return this.children;