Merge "first release of SO artifacts"
[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.io.Serializable;
26 import java.util.ArrayList;
27 import java.util.Comparator;
28 import java.util.List;
29
30 public class Resource implements Serializable {
31
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;
46
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());
51
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<>();
58         this.parent = parent;
59         if (parent != null)
60             this.parent.children.add(this);
61     }
62
63     public String getResourceId() {
64         return resourceId;
65     }
66
67     public void setResourceId(String resourceId) {
68         this.resourceId = resourceId;
69     }
70
71     public WorkflowType getResourceType() {
72         return resourceType;
73     }
74
75     public void setResourceType(WorkflowType resourceType) {
76         this.resourceType = resourceType;
77     }
78
79     public boolean isGenerated() {
80         return generated;
81     }
82
83     public void setGenerated(boolean generated) {
84         this.generated = generated;
85     }
86
87     public boolean isBaseVfModule() {
88         return baseVfModule;
89     }
90
91     public void setBaseVfModule(boolean baseVfModule) {
92         this.baseVfModule = baseVfModule;
93     }
94
95     public String getVirtualLinkKey() {
96         return virtualLinkKey;
97     }
98
99     public void setVirtualLinkKey(String virtualLinkKey) {
100         this.virtualLinkKey = virtualLinkKey;
101     }
102
103     public String getVnfCustomizationId() {
104         return vnfCustomizationId;
105     }
106
107     public void setVnfCustomizationId(String vnfCustomizationId) {
108         this.vnfCustomizationId = vnfCustomizationId;
109     }
110
111     public String getVfModuleCustomizationId() {
112         return vfModuleCustomizationId;
113     }
114
115     public void setVfModuleCustomizationId(String vfModuleCustomizationId) {
116         this.vfModuleCustomizationId = vfModuleCustomizationId;
117     }
118
119     public String getCvnfModuleCustomizationId() {
120         return cvnfModuleCustomizationId;
121     }
122
123     public void setCvnfModuleCustomizationId(String cvnfModuleCustomizationId) {
124         this.cvnfModuleCustomizationId = cvnfModuleCustomizationId;
125     }
126
127     public String getInstanceName() {
128         return instanceName;
129     }
130
131     public void setInstanceName(String instanceName) {
132         this.instanceName = instanceName;
133     }
134
135     public String getModelInvariantId() {
136         return modelInvariantId;
137     }
138
139     public void setModelInvariantId(String modelInvariantId) {
140         this.modelInvariantId = modelInvariantId;
141     }
142
143
144     public int getProcessingPriority() {
145         return processingPriority == 0 ? (isBaseVfModule() ? Integer.MIN_VALUE + 1 : 0) : processingPriority;
146     }
147
148     public void setProcessingPriority(int processingPriority) {
149         this.processingPriority = processingPriority;
150     }
151
152     public Resource getParent() {
153         return this.parent;
154     }
155
156     public List<Resource> getChildren() {
157         return this.children;
158     }
159 }