Merge "When a node is going down, remove edges in both directions associated with...
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-data-impl / src / test / resources / MyXmlGenerator.groovy
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 import groovy.xml.MarkupBuilder
9 import org.opendaylight.controller.yang.data.impl.MyNodeBuilder
10
11 /**
12  * wrapper class - applies hardcoded builder on given data closure
13  */
14 class MyXmlGenerator {
15
16     def myBuilder
17     
18     MyXmlGenerator() {
19         myBuilder = MyNodeBuilder.newInstance();
20     }
21
22     MyNodeBuilder getBuilder() { 
23       return myBuilder;
24     }
25         
26     void buildTree(data) {
27         data.setDelegate(myBuilder)
28         data()
29     }
30     
31     /**
32      * tests builder execution
33      */
34     static void main(args) {
35         println 'hello'
36         def data = {
37           network(xmlns: 'urn:opendaylight:controller:network') {
38             topologies {
39               topology {
40                 'topology-id'('topId_01')
41                 
42                 nodes {
43                   node {
44                     'node-id'('nodeId_02')
45                     'supporting-ne'('networkId_03')
46                     'termination-points' {
47                       'termination-point' {
48                         'tp-id'('tpId_04')
49                       }
50                     }
51                   }
52                   node {
53                     'node-id'('nodeId_05')
54                     'supporting-ne'('networkId_06')
55                     'termination-points' {
56                       'termination-point' {
57                         'tp-id'('tpId_07')
58                       }
59                     }
60                   }
61                   node {
62                     'node-id'('nodeId_08')
63                     'supporting-ne'('networkId_09')
64                     'termination-points' {
65                       'termination-point' {
66                         'tp-id'('tpId_10')
67                       }
68                       'termination-point' {
69                         'tp-id'('tpId_11')
70                       }
71                     }
72                   }
73                 }
74                 links {
75                   link {
76                     'link-id'('linkId_12')
77                     source {
78                       'source-node'('nodeId_13')
79                       'source-tp'('tpId_13')
80                     }
81                     destination {
82                       'dest-node'('nodeId_14')
83                       'dest-tp'('tpId_14')
84                     }
85                   }
86                   link {
87                     'link-id'('linkId_15')
88                     source {
89                       'source-node'('nodeId_16')
90                       'source-tp'('tpId_16')
91                     }
92                     destination {
93                       'dest-node'('nodeId_17')
94                       'dest-tp'('tpId_17')
95                     }
96                   }
97                 }
98               }
99             }
100             'network-elements' {
101               'network-element' {
102                 'element-id'('ntElementId_18')
103               }
104               'network-element' {
105                 'element-id'('ntElementId_19')
106               }
107             }
108           }
109
110         }
111
112         def xmlGen = new MyXmlGenerator()
113         xmlGen.buildTree(data)
114         println xmlGen.getBuilder().getRootNode()
115     }
116
117 }
118
119
120