[MSO-8] Update the maven dependency
[so.git] / bpmn / MSOCommonBPMN / src / main / groovy / org / openecomp / mso / bpmn / common / scripts / VfModule.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
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.openecomp.mso.bpmn.common.scripts;
22
23 import org.apache.commons.lang3.*
24
25 public class VfModule implements Serializable {
26         
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