Initial OpenECOMP MSO commit
[so.git] / bpmn / MSOGammaBPMN / src / main / groovy / com / att / bpm / 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 com.att.bpm.scripts;
22
23 import groovy.util.Node;
24
25 import java.util.concurrent.ExecutionException;
26
27 import org.camunda.bpm.engine.delegate.BpmnError
28 import org.camunda.bpm.engine.runtime.Execution
29 import org.apache.commons.lang3.*
30
31 import org.openecomp.mso.bpmn.core.WorkflowException
32
33 public class VfModule implements Serializable {
34         
35         /**
36          * Class representing a VF Module Node. Fields of this class include indicators
37          * as to whether the VF Module is the only VF Module in its containing Generic VNF
38          * and whether the VF Module is the base VF Module in its containing Generic VNF.
39          */
40
41         private Node node
42         private Boolean onlyVfModule
43         private Boolean baseVfModule
44
45         /**
46          * Constructor.
47          *
48          * @param node Node representing the VF Module xml.
49          * @param onlyVfModule Is this VF Module the only VF Module in its containing Generic VNF?
50          */
51         public VfModule(Node node, boolean onlyVfModule) {
52                 this.node = node
53                 this.onlyVfModule = onlyVfModule
54                 this.baseVfModule = getElementText('is-base-vf-module').equals('true')
55         }
56
57         /**
58          * Get the Node representing the VF Module xml.
59          *
60          * @return the Node representing the VF Module xml.
61          */
62         public Node getNode() {
63                 return node
64         }
65
66         public String getElementText(String childNodeName) {
67                 def Node childNode = (new MsoUtils()).getChildNode(node, childNodeName)
68                 if (childNode == null) {
69                         return ''
70                 } else {
71                         return childNode.text()
72                 }
73         }
74
75         /**
76          * Is this VF Module the only VF Module in its containing Generic VNF?
77          *
78          * @return true if this VF Module is the only VF Module in its containing Generic VNF;
79          * false otherwise.
80          */
81         public boolean isOnlyVfModule() {
82                 return onlyVfModule
83         }
84
85         /**
86          * Is this VF Module the base VF Module in its containing Generic VNF?
87          *
88          * @return true if this VF Module is the base VF Module in its containing Generic VNF;
89          * false otherwise.
90          */
91         public boolean isBaseVfModule() {
92                 return baseVfModule
93         }
94 }
95