Containerization feature of SO
[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  * 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.common.scripts;
22
23 import org.apache.commons.lang3.*
24 import org.onap.so.logger.MessageEnum
25 import org.onap.so.logger.MsoLogger
26
27
28
29 public class VfModule implements Serializable {
30         private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, VfModule.class);
31
32         
33         /**
34          * Class representing a VF Module Node. Fields of this class include indicators
35          * as to whether the VF Module is the only VF Module in its containing Generic VNF
36          * and whether the VF Module is the base VF Module in its containing Generic VNF.
37          */
38
39         private Node node
40         private Boolean onlyVfModule
41         private Boolean baseVfModule
42
43         /**
44          * Constructor.
45          *
46          * @param node Node representing the VF Module xml.
47          * @param onlyVfModule Is this VF Module the only VF Module in its containing Generic VNF?
48          */
49         public VfModule(Node node, boolean onlyVfModule) {
50                 this.node = node
51                 this.onlyVfModule = onlyVfModule
52                 this.baseVfModule = getElementText('is-base-vf-module').equals('true')
53         }
54
55         /**
56          * Get the Node representing the VF Module xml.
57          *
58          * @return the Node representing the VF Module xml.
59          */
60         public Node getNode() {
61                 return node
62         }
63
64         public String getElementText(String childNodeName) {
65                 def Node childNode = (new MsoUtils()).getChildNode(node, childNodeName)
66                 if (childNode == null) {
67                         return ''
68                 } else {
69                         return childNode.text()
70                 }
71         }
72
73         /**
74          * Is this VF Module the only VF Module in its containing Generic VNF?
75          *
76          * @return true if this VF Module is the only VF Module in its containing Generic VNF;
77          * false otherwise.
78          */
79         public boolean isOnlyVfModule() {
80                 return onlyVfModule
81         }
82
83         /**
84          * Is this VF Module the base VF Module in its containing Generic VNF?
85          *
86          * @return true if this VF Module is the base VF Module in its containing Generic VNF;
87          * false otherwise.
88          */
89         public boolean isBaseVfModule() {
90                 return baseVfModule
91         }
92 }
93