blob: ce8b632050654a13cb8361d4156770f999130636 [file] [log] [blame]
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.yangutils.datamodel;
18
19import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20import org.onosproject.yangutils.parser.Parsable;
21import org.onosproject.yangutils.utils.YangConstructType;
22
23import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
24
25/*
26 * Reference RFC 6020.
27 *
28 * The "rpc" statement is used to define a NETCONF RPC operation. It
29 * takes one argument, which is an identifier, followed by a block of
30 * substatements that holds detailed rpc information. This argument is
31 * the name of the RPC, and is used as the element name directly under
32 * the <rpc> element, as designated by the substitution group
33 * "rpcOperation" in [RFC4741].
34 *
35 * The "rpc" statement defines an rpc node in the schema tree. Under
36 * the rpc node, a schema node with the name "input", and a schema node
37 * with the name "output" are also defined. The nodes "input" and
38 * "output" are defined in the module's namespace.
39 *
40 * The rpc substatements
41 *
42 * +--------------+---------+-------------+------------------+
43 * | substatement | section | cardinality |data model mapping|
44 * +--------------+---------+-------------+------------------+
45 * | description | 7.19.3 | 0..1 | -string |
46 * | grouping | 7.11 | 0..n | -child nodes |
47 * | if-feature | 7.18.2 | 0..n | -TODO |
48 * | input | 7.13.2 | 0..1 | -child nodes |
49 * | output | 7.13.3 | 0..1 | -child nodes |
50 * | reference | 7.19.4 | 0..1 | -string |
51 * | status | 7.19.2 | 0..1 | -YangStatus |
52 * | typedef | 7.3 | 0..n | -child nodes |
53 * +--------------+---------+-------------+------------------+
54 */
55
56/**
Bharat saraswald9822e92016-04-05 15:13:44 +053057 * Represents data model node to maintain information defined in YANG rpc.
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +053058 */
59public class YangRpc extends YangNode implements YangCommonInfo, Parsable,
Bharat saraswald9822e92016-04-05 15:13:44 +053060 CollisionDetector {
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +053061
62 /**
63 * Name of the rpc.
64 */
65 private String name;
66
67 /**
68 * Description of rpc.
69 */
70 private String description;
71
72 /**
73 * Reference of the module.
74 */
75 private String reference;
76
77 /**
78 * Status of the node.
79 */
80 private YangStatusType status = YangStatusType.CURRENT;
81
82 /**
83 * Create a rpc node.
84 */
85 public YangRpc() {
86 super(YangNodeType.RPC_NODE);
87 }
88
89 @Override
90 public String getName() {
91 return name;
92 }
93
94 @Override
95 public void setName(String name) {
96 this.name = name;
97 }
98
99 @Override
100 public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
101 // Detect colliding child.
102 detectCollidingChildUtil(identifierName, dataType, this);
103 }
104
105 @Override
106 public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530107 if (getName().equals(identifierName)) {
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530108 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as rpc \""
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530109 + getName() + "\"");
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530110 }
111 }
112
113 @Override
114 public YangConstructType getYangConstructType() {
115 return YangConstructType.RPC_DATA;
116 }
117
118 @Override
119 public void validateDataOnEntry() throws DataModelException {
120 //TODO: implement the method.
121 }
122
123 @Override
124 public void validateDataOnExit() throws DataModelException {
125 //TODO: implement the method.
126 }
127
128 @Override
129 public String getDescription() {
130 return description;
131 }
132
133 @Override
134 public void setDescription(String description) {
135 this.description = description;
136 }
137
138 @Override
139 public String getReference() {
140 return reference;
141 }
142
143 @Override
144 public void setReference(String reference) {
145 this.reference = reference;
146 }
147
148 @Override
149 public YangStatusType getStatus() {
150 return status;
151 }
152
153 @Override
154 public void setStatus(YangStatusType status) {
155 this.status = status;
156 }
157}