Fix yang module naming
[mdsal.git] / binding2 / mdsal-binding2-java-api-generator / src / main / twirl / org / opendaylight / mdsal / binding / javav2 / java / api / yang / yangTemplateForModule.scala.txt
1 @*
2  * Copyright (c) 2016 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
9 @**********************************************************
10 * Twirl YangTemplate for generating yang snippets.        *
11 * Twirl is transformed to Scala and compiled. Then,       *
12 * it can be called from Java with particular input        *
13 * parameters to render desired output code.               *
14 ***********************************************************@
15
16 @import org.opendaylight.mdsal.binding.javav2.generator.util.FormattingUtils
17 @import org.opendaylight.yangtools.yang.model.api.Module
18 @import org.opendaylight.yangtools.yang.model.api.DocumentedNode
19 @import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement
20 @import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement
21
22 @(module: Module)
23 @if(module != null) {
24     @generateYangSnippet(module)
25 }
26
27 @generateYangSnippet(module: Module) = {
28     module @{module.getName()} {
29         yang-version @module.getYangVersion();
30         namespace "@module.getNamespace().toString()";
31         prefix "@module.getPrefix()";
32
33         @if(module.getImports() != null && !module.getImports().isEmpty()) {
34             @for(moduleImport <- module.getImports()) {
35                 @if(moduleImport != null && moduleImport.getModuleName() != "") {
36                     import @{moduleImport.getModuleName()} {
37                         prefix "@{moduleImport.getPrefix()}";
38                         @if(moduleImport.getRevision().isPresent()) {
39                             revision-date @{moduleImport.getRevision().get().toString()};
40                         }
41                     }
42                 }
43             }
44         }
45         @if(module.getRevision().isPresent()) {
46             @for(effectiveStatement <- module.asInstanceOf[EffectiveStatement[_, _]].effectiveSubstatements()){
47                 @if(effectiveStatement.getDeclared().isInstanceOf[RevisionStatement]){
48                     @if(effectiveStatement.asInstanceOf[DocumentedNode].getDescription().isPresent()){
49                         revision @{module.getRevision().get().toString()} {
50                             description "@{effectiveStatement.asInstanceOf[DocumentedNode].getDescription().get()}";
51                         }
52                     } else {
53                         revision @{module.getRevision().get().toString()};
54                     }
55                 }
56             }
57         }
58         @if(module.getTypeDefinitions() != null && !module.getTypeDefinitions().isEmpty()){
59             @yangTemplateWriteTypeDefs(module.getTypeDefinitions())
60         }
61         @if(module.getChildNodes() != null) {
62             @yangTemplateWriteDataSchemaNodes(module.getChildNodes(), module)
63         }
64         @if(module.getGroupings() != null && !module.getGroupings().isEmpty()) {
65             @yangTemplateWriteGroupingDefs(module.getGroupings(), module)
66         }
67         @if(module.getAugmentations() != null && !module.getAugmentations().isEmpty()) {
68             @yangTemplateWriteAugments(module.getAugmentations(), module)
69         }
70         @if(module.getDeviations() != null && !module.getDeviations().isEmpty()) {
71             @yangTemplateWriteDeviations(module.getDeviations())
72         }
73         @if(module.getExtensionSchemaNodes() != null && !module.getExtensionSchemaNodes().isEmpty()) {
74             @for(extension <- module.getExtensionSchemaNodes()) {
75                 @if(extension != null) {
76                     @yangTemplateWriteExtension(extension)
77                 }
78             }
79         }
80         @if(module.getFeatures() != null && !module.getFeatures().isEmpty()) {
81             @for(feature <- module.getFeatures()) {
82                 @if(feature != null) {
83                     @yangTemplateWriteFeature(feature)
84                 }
85             }
86         }
87         @if(module.getIdentities() != null && !module.getIdentities().isEmpty()) {
88             @for(identity <- module.getIdentities()) {
89                 @if(identity != null) {
90                     @yangTemplateWriteIdentity(identity)
91                 }
92             }
93         }
94         @if(module.getNotifications() != null && !module.getNotifications().isEmpty()) {
95             @for(notification <- module.getNotifications()) {
96                 @if(notification != null) {
97                     @yangTemplateWriteNotification(notification, module)
98                 }
99             }
100         }
101         @if(module.getRpcs() != null && !module.getRpcs().isEmpty()) {
102             @for(rpc <- module.getRpcs()) {
103                 @if(rpc != null) {
104                     @yangTemplateWriteRPC(rpc, module)
105                 }
106             }
107         }
108         @if(module.getUnknownSchemaNodes() != null && !module.getUnknownSchemaNodes().isEmpty()) {
109             @yangTemplateWriteUnknownSchemaNodes(module.getUnknownSchemaNodes(), module)
110         }
111         @if(module.getUses() != null && !module.getUses().isEmpty()) {
112             @yangTemplateWriteUsesNodes(module.getUses(), module)
113         }
114     }
115 }