blob: 62b8dd1d4af71eed6efea8a3af57b1b574a28876 [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;
Bharat saraswal96dfef02016-06-16 00:29:12 +053020import org.onosproject.yangutils.datamodel.utils.Parsable;
21import org.onosproject.yangutils.datamodel.utils.YangConstructType;
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +053022
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
Bharat saraswal96dfef02016-06-16 00:29:12 +053062 private static final long serialVersionUID = 806201613L;
63
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +053064 /**
65 * Name of the rpc.
66 */
67 private String name;
68
69 /**
70 * Description of rpc.
71 */
72 private String description;
73
74 /**
75 * Reference of the module.
76 */
77 private String reference;
78
79 /**
80 * Status of the node.
81 */
82 private YangStatusType status = YangStatusType.CURRENT;
83
84 /**
85 * Create a rpc node.
86 */
87 public YangRpc() {
88 super(YangNodeType.RPC_NODE);
89 }
90
91 @Override
92 public String getName() {
93 return name;
94 }
95
96 @Override
97 public void setName(String name) {
98 this.name = name;
99 }
100
101 @Override
102 public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
103 // Detect colliding child.
104 detectCollidingChildUtil(identifierName, dataType, this);
105 }
106
107 @Override
108 public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530109 if (getName().equals(identifierName)) {
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530110 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as rpc \""
Vinod Kumar Sd4deb062016-04-15 18:08:57 +0530111 + getName() + "\"");
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530112 }
113 }
114
115 @Override
116 public YangConstructType getYangConstructType() {
117 return YangConstructType.RPC_DATA;
118 }
119
120 @Override
121 public void validateDataOnEntry() throws DataModelException {
122 //TODO: implement the method.
123 }
124
125 @Override
126 public void validateDataOnExit() throws DataModelException {
127 //TODO: implement the method.
128 }
129
130 @Override
131 public String getDescription() {
132 return description;
133 }
134
135 @Override
136 public void setDescription(String description) {
137 this.description = description;
138 }
139
140 @Override
141 public String getReference() {
142 return reference;
143 }
144
145 @Override
146 public void setReference(String reference) {
147 this.reference = reference;
148 }
149
150 @Override
151 public YangStatusType getStatus() {
152 return status;
153 }
154
155 @Override
156 public void setStatus(YangStatusType status) {
157 this.status = status;
158 }
159}