Containerization feature of SO
[so.git] / bpmn / MSOCoreBPMN / src / main / java / org / onap / so / bpmn / core / domain / Resource.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.bpmn.core.domain;
22
23 import java.io.Serializable;
24
25 import com.fasterxml.jackson.annotation.JsonIgnore;
26 import com.fasterxml.jackson.annotation.JsonInclude;
27
28
29
30 public abstract class Resource extends JsonWrapper  implements Serializable {
31
32         private static final long serialVersionUID = 1L;
33         private String resourceId; // TODO name this field just id instead, should be the id of the object as it is in aai
34         protected ResourceType resourceType; // Enum of vnf or network or allotted resource
35         protected ModelInfo modelInfo;
36         private long concurrencyCounter = 1L;
37
38         //private List modules;
39         private ResourceInstance resourceInstance = new ResourceInstance(); // TODO possibly remove
40         private HomingSolution homingSolution = new HomingSolution();
41         @JsonInclude(JsonInclude.Include.NON_NULL)
42         private HomingSolution currentHomingSolution;
43
44         //common parameters for all Resources
45         private String toscaNodeType;
46
47         // GET and SET
48         public String getResourceId() {
49                 return resourceId;
50         }
51         public void setResourceId(String resourceId) {
52                 this.resourceId = resourceId;
53         }
54         public ModelInfo getModelInfo() {
55                 return modelInfo;
56         }
57         public void setModelInfo(ModelInfo modelInfo) {
58                 this.modelInfo = modelInfo;
59         }
60
61         public ResourceInstance getResourceInstance() {
62                 return resourceInstance;
63         }
64         public void setResourceInstance(ResourceInstance resourceInstance) {
65                 this.resourceInstance = resourceInstance;
66         }
67         public HomingSolution getHomingSolution(){
68                 return homingSolution;
69         }
70
71         public void setHomingSolution(HomingSolution homingSolution){
72                 this.homingSolution = homingSolution;
73         }
74         public HomingSolution getCurrentHomingSolution() {
75                 return currentHomingSolution;
76         }
77         public void setCurrentHomingSolution(HomingSolution currentHomingSolution) {
78                 this.currentHomingSolution = currentHomingSolution;
79         }
80         public void setResourceType(ResourceType resourceType) {
81                 this.resourceType = resourceType;
82         }
83
84         public ResourceType getResourceType(){
85                 return resourceType;
86         }
87
88         public String getToscaNodeType() {
89                 return toscaNodeType;
90         }
91         public void setToscaNodeType(String toscaNodeType) {
92                 this.toscaNodeType = toscaNodeType;
93         }
94
95         //Utility methods
96
97         public String getResourceInstanceId() {
98                 return this.getResourceInstance().getInstanceId();
99         }
100         public String getResourceInstanceName() {
101                 return this.getResourceInstance().getInstanceName();
102         }
103         //TODO
104 //      @JsonIgnore
105 //      public String getResourceHomingSolution() {
106 //      }
107
108         public void setResourceInstanceId(String newInstanceId){
109                 this.getResourceInstance().setInstanceId(newInstanceId);
110         }
111         public void setResourceInstanceName(String newInstanceName){
112                 this.getResourceInstance().setInstanceName(newInstanceName);
113         }
114
115         //TODO
116 //      @JsonIgnore
117 //      public String setResourceHomingSolution() {
118 //      }
119         /**
120          * To be used by macro flow to increment concurrency counter after update to it's structure was completed
121          */
122         public void incrementConcurrencyCounter(){
123                 this.concurrencyCounter ++;
124         }
125         /**
126          * Method to get concurrency counter data
127          * @return long value for the counter
128          */
129         @JsonIgnore
130         public long getConcurrencyCounter(){
131                 return concurrencyCounter;
132         }
133
134 }