Gaurav Agrawal | e3ed0d9 | 2016-03-23 19:04:17 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Gaurav Agrawal | e3ed0d9 | 2016-03-23 19:04:17 +0530 | [diff] [blame] | 3 | * |
| 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 | |
| 17 | package org.onosproject.yangutils.datamodel; |
| 18 | |
| 19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 20 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
| 21 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
Gaurav Agrawal | e3ed0d9 | 2016-03-23 19:04:17 +0530 | [diff] [blame] | 22 | |
| 23 | import 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 saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 57 | * Represents data model node to maintain information defined in YANG rpc. |
Gaurav Agrawal | e3ed0d9 | 2016-03-23 19:04:17 +0530 | [diff] [blame] | 58 | */ |
| 59 | public class YangRpc extends YangNode implements YangCommonInfo, Parsable, |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 60 | CollisionDetector { |
Gaurav Agrawal | e3ed0d9 | 2016-03-23 19:04:17 +0530 | [diff] [blame] | 61 | |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 62 | private static final long serialVersionUID = 806201613L; |
| 63 | |
Gaurav Agrawal | e3ed0d9 | 2016-03-23 19:04:17 +0530 | [diff] [blame] | 64 | /** |
| 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 S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 109 | if (getName().equals(identifierName)) { |
Gaurav Agrawal | e3ed0d9 | 2016-03-23 19:04:17 +0530 | [diff] [blame] | 110 | throw new DataModelException("YANG file error: Duplicate input identifier detected, same as rpc \"" |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 111 | + getName() + "\""); |
Gaurav Agrawal | e3ed0d9 | 2016-03-23 19:04:17 +0530 | [diff] [blame] | 112 | } |
| 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 | } |