Merge "Support for SO to ExtAPI"
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / onap / so / bpmn / common / scripts / VfModule.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (c) 2019 Samsung
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.common.scripts;
24
25
26 public class VfModule implements Serializable {
27         /**
28          * Class representing a VF Module Node. Fields of this class include indicators
29          * as to whether the VF Module is the only VF Module in its containing Generic VNF
30          * and whether the VF Module is the base VF Module in its containing Generic VNF.
31          */
32
33         private Node node
34         private Boolean onlyVfModule
35         private Boolean baseVfModule
36
37         /**
38          * Constructor.
39          *
40          * @param node Node representing the VF Module xml.
41          * @param onlyVfModule Is this VF Module the only VF Module in its containing Generic VNF?
42          */
43         public VfModule(Node node, boolean onlyVfModule) {
44                 this.node = node
45                 this.onlyVfModule = onlyVfModule
46                 this.baseVfModule = getElementText('is-base-vf-module').equals('true')
47         }
48
49         /**
50          * Get the Node representing the VF Module xml.
51          *
52          * @return the Node representing the VF Module xml.
53          */
54         public Node getNode() {
55                 return node
56         }
57
58         public String getElementText(String childNodeName) {
59                 def Node childNode = (new MsoUtils()).getChildNode(node, childNodeName)
60                 if (childNode == null) {
61                         return ''
62                 } else {
63                         return childNode.text()
64                 }
65         }
66
67         /**
68          * Is this VF Module the only VF Module in its containing Generic VNF?
69          *
70          * @return true if this VF Module is the only VF Module in its containing Generic VNF;
71          * false otherwise.
72          */
73         public boolean isOnlyVfModule() {
74                 return onlyVfModule
75         }
76
77         /**
78          * Is this VF Module the base VF Module in its containing Generic VNF?
79          *
80          * @return true if this VF Module is the base VF Module in its containing Generic VNF;
81          * false otherwise.
82          */
83         public boolean isBaseVfModule() {
84                 return baseVfModule
85         }
86 }
87