Merge "Fix DeleteSliceService auth"
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / bpmn / infrastructure / workflow / tasks / Resource.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
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=========================================================
21  */
22
23 package org.onap.so.bpmn.infrastructure.workflow.tasks;
24
25 import java.util.ArrayList;
26 import java.util.Comparator;
27 import java.util.List;
28
29 public class Resource {
30
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;
43
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());
48
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<>();
55         this.parent = parent;
56         if (parent != null)
57             this.parent.children.add(this);
58     }
59
60     public String getResourceId() {
61         return resourceId;
62     }
63
64     public void setResourceId(String resourceId) {
65         this.resourceId = resourceId;
66     }
67
68     public WorkflowType getResourceType() {
69         return resourceType;
70     }
71
72     public void setResourceType(WorkflowType resourceType) {
73         this.resourceType = resourceType;
74     }
75
76     public boolean isGenerated() {
77         return generated;
78     }
79
80     public void setGenerated(boolean generated) {
81         this.generated = generated;
82     }
83
84     public boolean isBaseVfModule() {
85         return baseVfModule;
86     }
87
88     public void setBaseVfModule(boolean baseVfModule) {
89         this.baseVfModule = baseVfModule;
90     }
91
92     public String getVirtualLinkKey() {
93         return virtualLinkKey;
94     }
95
96     public void setVirtualLinkKey(String virtualLinkKey) {
97         this.virtualLinkKey = virtualLinkKey;
98     }
99
100     public String getVnfCustomizationId() {
101         return vnfCustomizationId;
102     }
103
104     public void setVnfCustomizationId(String vnfCustomizationId) {
105         this.vnfCustomizationId = vnfCustomizationId;
106     }
107
108     public String getVfModuleCustomizationId() {
109         return vfModuleCustomizationId;
110     }
111
112     public void setVfModuleCustomizationId(String vfModuleCustomizationId) {
113         this.vfModuleCustomizationId = vfModuleCustomizationId;
114     }
115
116     public String getCvnfModuleCustomizationId() {
117         return cvnfModuleCustomizationId;
118     }
119
120     public void setCvnfModuleCustomizationId(String cvnfModuleCustomizationId) {
121         this.cvnfModuleCustomizationId = cvnfModuleCustomizationId;
122     }
123
124     public String getInstanceName() {
125         return instanceName;
126     }
127
128     public void setInstanceName(String instanceName) {
129         this.instanceName = instanceName;
130     }
131
132     public int getProcessingPriority() {
133         return processingPriority == 0 ? (isBaseVfModule() ? Integer.MIN_VALUE + 1 : 0) : processingPriority;
134     }
135
136     public void setProcessingPriority(int processingPriority) {
137         this.processingPriority = processingPriority;
138     }
139
140     public Resource getParent() {
141         return this.parent;
142     }
143
144     public List<Resource> getChildren() {
145         return this.children;
146     }
147 }