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