blob: c8452212f2452126407502df9c305d9ea50a0c33 [file] [log] [blame]
sonu gupta1bb37b82016-11-11 16:51:18 +05301/*
2 * Copyright 2016-present Open Networking Laboratory
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
17package org.onosproject.yms.app.ydt;
18
19import org.onosproject.yangutils.datamodel.YangSchemaNode;
20import org.onosproject.yangutils.datamodel.YangSchemaNodeContextInfo;
21import org.onosproject.yangutils.datamodel.YangSchemaNodeIdentifier;
22import org.onosproject.yms.ydt.YdtContext;
23import org.onosproject.yms.ydt.YdtContextOperationType;
24
25import java.util.List;
26
27/**
28 * Abstraction of an entity which represents YANG application data tree context
29 * information. This context information will be used by protocol to obtain
30 * the information associated with YDT application node. This is used when
31 * protocol is walking the application data tree in both visitor and listener
32 * mechanism.
33 */
34public interface YdtAppContext {
35
36 /**
37 * Returns the context of parent node.
38 *
39 * @return context of parent node
40 */
41 YdtAppContext getParent();
42
43 /**
44 * Sets the context of parent node.
45 *
46 * @param parent node
47 */
48 void setParent(YdtAppContext parent);
49
50 /**
51 * Returns the context of first child.
52 *
53 * @return context of first child
54 */
55 YdtAppContext getFirstChild();
56
57 /**
58 * Sets the context of first child.
59 *
60 * @param child node
61 */
62 void setChild(YdtAppContext child);
63
64 /**
65 * Returns the context of last child.
66 *
67 * @return context of last child
68 */
69 YdtAppContext getLastChild();
70
71 /**
72 * Sets the context of last child.
73 *
74 * @param child node
75 */
76 void setLastChild(YdtAppContext child);
77
78 /**
79 * Returns the context of next sibling.
80 *
81 * @return context of next sibling
82 */
83 YdtAppContext getNextSibling();
84
85 /**
86 * Sets the context of next sibling.
87 *
88 * @param nextSibling node
89 */
90 void setNextSibling(YdtAppContext nextSibling);
91
92 /**
93 * Returns the context of previous sibling.
94 *
95 * @return context of previous sibling
96 */
97 YdtAppContext getPreviousSibling();
98
99 /**
100 * Sets the context of previous sibling.
101 *
102 * @param preSibling node
103 */
104 void setPreviousSibling(YdtAppContext preSibling);
105
106 /**
107 * Returns the app tree operation type.
108 *
109 * @return app tree operation type
110 */
111 YdtAppNodeOperationType getOperationType();
112
113 /**
114 * Set the app tree operation type.
115 *
116 * @param opType app tree operation type
117 */
118 void setOperationType(YdtAppNodeOperationType opType);
119
120 /**
121 * Returns the list of nodes with operation type delete.
122 *
123 * @return list of nodes with operation type delete
124 */
125 List<YdtContext> getDeleteNodes();
126
127 /**
128 * Adds the ydt node with operation type delete in module delete node list.
129 *
130 * @param node ydt node with operation type delete/remove
131 */
132 void addDeleteNode(YdtNode node);
133
134 /**
135 * Returns application's root ydtContext.
136 *
137 * @return YdtContext of application root node
138 */
139 YdtContext getModuleContext();
140
141 /**
142 * Sets the application's ydtContext.
143 *
144 * @param moduleNode application's ydtContext
145 */
146 void setModuleContext(YdtContext moduleNode);
147
148 /**
149 * Returns the YangSchemaNode of augmenting application.
150 *
151 * @return YangSchemaNode of augmenting application
152 */
153 YangSchemaNode getAugmentingSchemaNode();
154
155 /**
156 * Sets the YangSchemaNode of augmenting application root node.
157 *
158 * @param schemaNode YangSchemaNode of augmenting application module
159 */
160 void setAugmentingSchemaNode(YangSchemaNode schemaNode);
161
162 /**
163 * Adds a last child to ydt application data tree.
164 *
165 * @param newChild name of child to be added
166 */
167 void addChild(YdtAppContext newChild);
168
169 /**
170 * Returns augmenting node module yang schema node.
171 *
172 * @param id schema node identifier
173 * @param contextInfo Yang Schema node context info
174 * which is having YangSchemaNode and
175 * ContextSwitchedNode
176 * @return augmenting node module yang schema node
177 */
178 YangSchemaNode getAugmentingSchemaNode(
179 YangSchemaNodeIdentifier id,
180 YangSchemaNodeContextInfo contextInfo);
181
182 /**
183 * Updates the app tree operation type.
184 * <p>
185 * If earlier operation type was OTHER_EDIT and now operation type came as
186 * DELETE_ONLY or vice-versa, then update operation type to BOTH.
187 *
188 * @param opType ydt current context operation type
189 */
190 void updateAppOperationType(YdtContextOperationType opType);
191
192 /**
193 * Sets the application data for given request. If in requested parameters
194 * schemaNode is not null then appData will be set with
195 * augmentedSchemaData else with moduleSchemaData object.
196 *
197 * @param moduleNode module node of requested app
198 * @param schemaNode augmented schema node of requested context
199 */
200 void setAppData(YdtNode moduleNode, YangSchemaNode schemaNode);
201
202 /**
203 * Returns the app data for current context.
204 *
205 * @return app data
206 */
207 AppData getAppData();
208
209 /**
210 * Returns the yang schema for requested node.
211 *
212 * @return schema node
213 */
214 YangSchemaNode getYangSchemaNode();
215
216 /**
217 * Adds the given schema node in to application set.
218 *
219 * @param schemaNode schema node to be added
220 * @return true for success; false otherwise
221 */
222 boolean addSchemaToAppSet(YangSchemaNode schemaNode);
223}