VinodKumarS-Huawei

[ONOS-4636]YANG Grouping linking bug fix + YANG Code review comment fix

Change-Id: I68ee8dd08266a02593e217cef1a9bb010037d673
Showing 72 changed files with 1726 additions and 598 deletions
...@@ -79,7 +79,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -79,7 +79,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
79 /** 79 /**
80 * Representation of data model node to maintain information defined in YANG augment. 80 * Representation of data model node to maintain information defined in YANG augment.
81 */ 81 */
82 -public class YangAugment extends YangNode 82 +public class YangAugment
83 + extends YangNode
83 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector { 84 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector {
84 85
85 /** 86 /**
...@@ -163,13 +164,15 @@ public class YangAugment extends YangNode ...@@ -163,13 +164,15 @@ public class YangAugment extends YangNode
163 } 164 }
164 165
165 @Override 166 @Override
166 - public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { 167 + public void detectCollidingChild(String identifierName, YangConstructType dataType)
168 + throws DataModelException {
167 // Detect colliding child. 169 // Detect colliding child.
168 detectCollidingChildUtil(identifierName, dataType, this); 170 detectCollidingChildUtil(identifierName, dataType, this);
169 } 171 }
170 172
171 @Override 173 @Override
172 - public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 174 + public void detectSelfCollision(String identifierName, YangConstructType dataType)
175 + throws DataModelException {
173 if (this.getName().equals(identifierName)) { 176 if (this.getName().equals(identifierName)) {
174 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as input \"" 177 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as input \""
175 + this.getName() + "\""); 178 + this.getName() + "\"");
...@@ -191,7 +194,8 @@ public class YangAugment extends YangNode ...@@ -191,7 +194,8 @@ public class YangAugment extends YangNode
191 * 194 *
192 * @param leafsList the list of leaf to set 195 * @param leafsList the list of leaf to set
193 */ 196 */
194 - private void setListOfLeaf(List<YangLeaf> leafsList) { 197 + @Override
198 + public void setListOfLeaf(List<YangLeaf> leafsList) {
195 listOfLeaf = leafsList; 199 listOfLeaf = leafsList;
196 } 200 }
197 201
...@@ -224,7 +228,8 @@ public class YangAugment extends YangNode ...@@ -224,7 +228,8 @@ public class YangAugment extends YangNode
224 * 228 *
225 * @param listOfLeafList the list of leaf-list to set 229 * @param listOfLeafList the list of leaf-list to set
226 */ 230 */
227 - private void setListOfLeafList(List<YangLeafList> listOfLeafList) { 231 + @Override
232 + public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
228 this.listOfLeafList = listOfLeafList; 233 this.listOfLeafList = listOfLeafList;
229 } 234 }
230 235
...@@ -298,7 +303,8 @@ public class YangAugment extends YangNode ...@@ -298,7 +303,8 @@ public class YangAugment extends YangNode
298 * @throws DataModelException a violation of data model rules 303 * @throws DataModelException a violation of data model rules
299 */ 304 */
300 @Override 305 @Override
301 - public void validateDataOnEntry() throws DataModelException { 306 + public void validateDataOnEntry()
307 + throws DataModelException {
302 // TODO auto-generated method stub, to be implemented by parser 308 // TODO auto-generated method stub, to be implemented by parser
303 } 309 }
304 310
...@@ -308,7 +314,8 @@ public class YangAugment extends YangNode ...@@ -308,7 +314,8 @@ public class YangAugment extends YangNode
308 * @throws DataModelException a violation of data model rules 314 * @throws DataModelException a violation of data model rules
309 */ 315 */
310 @Override 316 @Override
311 - public void validateDataOnExit() throws DataModelException { 317 + public void validateDataOnExit()
318 + throws DataModelException {
312 // TODO auto-generated method stub, to be implemented by parser 319 // TODO auto-generated method stub, to be implemented by parser
313 } 320 }
314 321
......
...@@ -88,10 +88,12 @@ import static org.onosproject.yangutils.utils.YangConstructType.CASE_DATA; ...@@ -88,10 +88,12 @@ import static org.onosproject.yangutils.utils.YangConstructType.CASE_DATA;
88 * | when | 7.19.5 | 0..1 |-TODO | 88 * | when | 7.19.5 | 0..1 |-TODO |
89 * +--------------+---------+-------------+------------------+ 89 * +--------------+---------+-------------+------------------+
90 */ 90 */
91 +
91 /** 92 /**
92 * Represents data model node to maintain information defined in YANG case. 93 * Represents data model node to maintain information defined in YANG case.
93 */ 94 */
94 -public class YangCase extends YangNode 95 +public class YangCase
96 + extends YangNode
95 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder { 97 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder {
96 98
97 /** 99 /**
...@@ -188,7 +190,8 @@ public class YangCase extends YangNode ...@@ -188,7 +190,8 @@ public class YangCase extends YangNode
188 * 190 *
189 * @param leafsList the list of leaf to set 191 * @param leafsList the list of leaf to set
190 */ 192 */
191 - private void setListOfLeaf(List<YangLeaf> leafsList) { 193 + @Override
194 + public void setListOfLeaf(List<YangLeaf> leafsList) {
192 listOfLeaf = leafsList; 195 listOfLeaf = leafsList;
193 } 196 }
194 197
...@@ -221,7 +224,8 @@ public class YangCase extends YangNode ...@@ -221,7 +224,8 @@ public class YangCase extends YangNode
221 * 224 *
222 * @param listOfLeafList the list of leaf-list to set 225 * @param listOfLeafList the list of leaf-list to set
223 */ 226 */
224 - private void setListOfLeafList(List<YangLeafList> listOfLeafList) { 227 + @Override
228 + public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
225 this.listOfLeafList = listOfLeafList; 229 this.listOfLeafList = listOfLeafList;
226 } 230 }
227 231
...@@ -295,7 +299,8 @@ public class YangCase extends YangNode ...@@ -295,7 +299,8 @@ public class YangCase extends YangNode
295 * @throws DataModelException a violation of data model rules 299 * @throws DataModelException a violation of data model rules
296 */ 300 */
297 @Override 301 @Override
298 - public void validateDataOnEntry() throws DataModelException { 302 + public void validateDataOnEntry()
303 + throws DataModelException {
299 // TODO auto-generated method stub, to be implemented by parser 304 // TODO auto-generated method stub, to be implemented by parser
300 } 305 }
301 306
...@@ -305,12 +310,14 @@ public class YangCase extends YangNode ...@@ -305,12 +310,14 @@ public class YangCase extends YangNode
305 * @throws DataModelException a violation of data model rules 310 * @throws DataModelException a violation of data model rules
306 */ 311 */
307 @Override 312 @Override
308 - public void validateDataOnExit() throws DataModelException { 313 + public void validateDataOnExit()
314 + throws DataModelException {
309 // TODO auto-generated method stub, to be implemented by parser 315 // TODO auto-generated method stub, to be implemented by parser
310 } 316 }
311 317
312 @Override 318 @Override
313 - public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { 319 + public void detectCollidingChild(String identifierName, YangConstructType dataType)
320 + throws DataModelException {
314 if (!(getParent() instanceof YangChoice)) { 321 if (!(getParent() instanceof YangChoice)) {
315 throw new DataModelException("Internal Data Model Tree Error: Invalid/Missing holder in case " + 322 throw new DataModelException("Internal Data Model Tree Error: Invalid/Missing holder in case " +
316 getName()); 323 getName());
...@@ -320,7 +327,8 @@ public class YangCase extends YangNode ...@@ -320,7 +327,8 @@ public class YangCase extends YangNode
320 } 327 }
321 328
322 @Override 329 @Override
323 - public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 330 + public void detectSelfCollision(String identifierName, YangConstructType dataType)
331 + throws DataModelException {
324 332
325 if (dataType == CASE_DATA) { 333 if (dataType == CASE_DATA) {
326 if (getName().equals(identifierName)) { 334 if (getName().equals(identifierName)) {
......
...@@ -87,7 +87,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -87,7 +87,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
87 /** 87 /**
88 * Represents data model node to maintain information defined in YANG container. 88 * Represents data model node to maintain information defined in YANG container.
89 */ 89 */
90 -public class YangContainer extends YangNode 90 +public class YangContainer
91 + extends YangNode
91 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder { 92 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder {
92 93
93 /** 94 /**
...@@ -211,7 +212,8 @@ public class YangContainer extends YangNode ...@@ -211,7 +212,8 @@ public class YangContainer extends YangNode
211 * 212 *
212 * @param leafsList the list of leaf to set 213 * @param leafsList the list of leaf to set
213 */ 214 */
214 - private void setListOfLeaf(List<YangLeaf> leafsList) { 215 + @Override
216 + public void setListOfLeaf(List<YangLeaf> leafsList) {
215 listOfLeaf = leafsList; 217 listOfLeaf = leafsList;
216 } 218 }
217 219
...@@ -245,7 +247,8 @@ public class YangContainer extends YangNode ...@@ -245,7 +247,8 @@ public class YangContainer extends YangNode
245 * 247 *
246 * @param listOfLeafList the list of leaf-list to set 248 * @param listOfLeafList the list of leaf-list to set
247 */ 249 */
248 - private void setListOfLeafList(List<YangLeafList> listOfLeafList) { 250 + @Override
251 + public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
249 this.listOfLeafList = listOfLeafList; 252 this.listOfLeafList = listOfLeafList;
250 } 253 }
251 254
...@@ -338,7 +341,8 @@ public class YangContainer extends YangNode ...@@ -338,7 +341,8 @@ public class YangContainer extends YangNode
338 * @throws DataModelException a violation of data model rules 341 * @throws DataModelException a violation of data model rules
339 */ 342 */
340 @Override 343 @Override
341 - public void validateDataOnEntry() throws DataModelException { 344 + public void validateDataOnEntry()
345 + throws DataModelException {
342 // TODO auto-generated method stub, to be implemented by parser 346 // TODO auto-generated method stub, to be implemented by parser
343 } 347 }
344 348
...@@ -348,7 +352,8 @@ public class YangContainer extends YangNode ...@@ -348,7 +352,8 @@ public class YangContainer extends YangNode
348 * @throws DataModelException a violation of data model rules 352 * @throws DataModelException a violation of data model rules
349 */ 353 */
350 @Override 354 @Override
351 - public void validateDataOnExit() throws DataModelException { 355 + public void validateDataOnExit()
356 + throws DataModelException {
352 List<YangLeaf> leaves = getListOfLeaf(); 357 List<YangLeaf> leaves = getListOfLeaf();
353 List<YangLeafList> leafLists = getListOfLeafList(); 358 List<YangLeafList> leafLists = getListOfLeafList();
354 359
...@@ -397,7 +402,8 @@ public class YangContainer extends YangNode ...@@ -397,7 +402,8 @@ public class YangContainer extends YangNode
397 * @param leafLists list of leaf-list attributes of container 402 * @param leafLists list of leaf-list attributes of container
398 * @throws DataModelException a violation of data model rules 403 * @throws DataModelException a violation of data model rules
399 */ 404 */
400 - private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException { 405 + private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists)
406 + throws DataModelException {
401 407
402 /* 408 /*
403 * If a node has "config" set to "false", no node underneath it can have 409 * If a node has "config" set to "false", no node underneath it can have
...@@ -423,13 +429,15 @@ public class YangContainer extends YangNode ...@@ -423,13 +429,15 @@ public class YangContainer extends YangNode
423 } 429 }
424 430
425 @Override 431 @Override
426 - public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { 432 + public void detectCollidingChild(String identifierName, YangConstructType dataType)
433 + throws DataModelException {
427 // Asks helper to detect colliding child. 434 // Asks helper to detect colliding child.
428 detectCollidingChildUtil(identifierName, dataType, this); 435 detectCollidingChildUtil(identifierName, dataType, this);
429 } 436 }
430 437
431 @Override 438 @Override
432 - public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 439 + public void detectSelfCollision(String identifierName, YangConstructType dataType)
440 + throws DataModelException {
433 if (getName().equals(identifierName)) { 441 if (getName().equals(identifierName)) {
434 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as container \"" 442 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as container \""
435 + getName() + "\""); 443 + getName() + "\"");
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
17 package org.onosproject.yangutils.datamodel; 17 package org.onosproject.yangutils.datamodel;
18 18
19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 -import org.onosproject.yangutils.linker.impl.ResolvableStatus; 20 +import org.onosproject.yangutils.linker.ResolvableStatus;
21 +
21 import com.google.common.base.Strings; 22 import com.google.common.base.Strings;
22 23
23 import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY; 24 import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY;
...@@ -30,8 +31,8 @@ import static org.onosproject.yangutils.datamodel.YangDataTypes.IDENTITYREF; ...@@ -30,8 +31,8 @@ import static org.onosproject.yangutils.datamodel.YangDataTypes.IDENTITYREF;
30 import static org.onosproject.yangutils.datamodel.YangDataTypes.LEAFREF; 31 import static org.onosproject.yangutils.datamodel.YangDataTypes.LEAFREF;
31 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; 32 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
32 import static org.onosproject.yangutils.datamodel.YangDataTypes.UNION; 33 import static org.onosproject.yangutils.datamodel.YangDataTypes.UNION;
33 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.INTRA_FILE_RESOLVED; 34 +import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED;
34 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.RESOLVED; 35 +import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
35 import static org.onosproject.yangutils.utils.RestrictionResolver.isOfRangeRestrictedType; 36 import static org.onosproject.yangutils.utils.RestrictionResolver.isOfRangeRestrictedType;
36 import static org.onosproject.yangutils.utils.RestrictionResolver.processLengthRestriction; 37 import static org.onosproject.yangutils.utils.RestrictionResolver.processLengthRestriction;
37 import static org.onosproject.yangutils.utils.RestrictionResolver.processRangeRestriction; 38 import static org.onosproject.yangutils.utils.RestrictionResolver.processRangeRestriction;
...@@ -41,7 +42,8 @@ import static org.onosproject.yangutils.utils.RestrictionResolver.processRangeRe ...@@ -41,7 +42,8 @@ import static org.onosproject.yangutils.utils.RestrictionResolver.processRangeRe
41 * 42 *
42 * @param <T> extended information. 43 * @param <T> extended information.
43 */ 44 */
44 -public class YangDerivedInfo<T> implements LocationInfo { 45 +public class YangDerivedInfo<T>
46 + implements LocationInfo, Cloneable {
45 47
46 /** 48 /**
47 * YANG typedef reference. 49 * YANG typedef reference.
...@@ -224,8 +226,11 @@ public class YangDerivedInfo<T> implements LocationInfo { ...@@ -224,8 +226,11 @@ public class YangDerivedInfo<T> implements LocationInfo {
224 * @return resolution status 226 * @return resolution status
225 * @throws DataModelException a violation in data mode rule 227 * @throws DataModelException a violation in data mode rule
226 */ 228 */
227 - public ResolvableStatus resolve() throws DataModelException { 229 + public ResolvableStatus resolve()
230 + throws DataModelException {
231 +
228 YangType<?> baseType = getReferredTypeDef().getTypeDefBaseType(); 232 YangType<?> baseType = getReferredTypeDef().getTypeDefBaseType();
233 +
229 /* 234 /*
230 * Checks the data type of the referred typedef, if it's derived, 235 * Checks the data type of the referred typedef, if it's derived,
231 * obtain effective built-in type and restrictions from it's derived 236 * obtain effective built-in type and restrictions from it's derived
...@@ -238,6 +243,7 @@ public class YangDerivedInfo<T> implements LocationInfo { ...@@ -238,6 +243,7 @@ public class YangDerivedInfo<T> implements LocationInfo {
238 if (baseType.getResolvableStatus() != INTRA_FILE_RESOLVED && baseType.getResolvableStatus() != RESOLVED) { 243 if (baseType.getResolvableStatus() != INTRA_FILE_RESOLVED && baseType.getResolvableStatus() != RESOLVED) {
239 throw new DataModelException("Linker Error: Referred typedef is not resolved for type."); 244 throw new DataModelException("Linker Error: Referred typedef is not resolved for type.");
240 } 245 }
246 +
241 /* 247 /*
242 * Check if the referred typedef is intra file resolved, if yes sets 248 * Check if the referred typedef is intra file resolved, if yes sets
243 * current status also to intra file resolved . 249 * current status also to intra file resolved .
...@@ -401,6 +407,7 @@ public class YangDerivedInfo<T> implements LocationInfo { ...@@ -401,6 +407,7 @@ public class YangDerivedInfo<T> implements LocationInfo {
401 } 407 }
402 } 408 }
403 } 409 }
410 +
404 /* 411 /*
405 * Check if the data type is the one which can't be restricted, in 412 * Check if the data type is the one which can't be restricted, in
406 * this case check whether no self restrictions should be present. 413 * this case check whether no self restrictions should be present.
...@@ -414,6 +421,7 @@ public class YangDerivedInfo<T> implements LocationInfo { ...@@ -414,6 +421,7 @@ public class YangDerivedInfo<T> implements LocationInfo {
414 throw new DataModelException("YANG file error: Restrictions can't be applied to a given type"); 421 throw new DataModelException("YANG file error: Restrictions can't be applied to a given type");
415 } 422 }
416 } 423 }
424 +
417 // Throw exception for unsupported types 425 // Throw exception for unsupported types
418 throw new DataModelException("Linker error: Unable to process the derived type."); 426 throw new DataModelException("Linker error: Unable to process the derived type.");
419 } 427 }
...@@ -424,7 +432,8 @@ public class YangDerivedInfo<T> implements LocationInfo { ...@@ -424,7 +432,8 @@ public class YangDerivedInfo<T> implements LocationInfo {
424 * @param refStringRestriction referred string restriction of typedef 432 * @param refStringRestriction referred string restriction of typedef
425 * @throws DataModelException a violation in data model rule 433 * @throws DataModelException a violation in data model rule
426 */ 434 */
427 - private void resolveStringRestriction(YangStringRestriction refStringRestriction) throws DataModelException { 435 + private void resolveStringRestriction(YangStringRestriction refStringRestriction)
436 + throws DataModelException {
428 YangStringRestriction curStringRestriction = null; 437 YangStringRestriction curStringRestriction = null;
429 YangRangeRestriction refRangeRestriction = null; 438 YangRangeRestriction refRangeRestriction = null;
430 YangPatternRestriction refPatternRestriction = null; 439 YangPatternRestriction refPatternRestriction = null;
...@@ -522,7 +531,8 @@ public class YangDerivedInfo<T> implements LocationInfo { ...@@ -522,7 +531,8 @@ public class YangDerivedInfo<T> implements LocationInfo {
522 * @return resolved length restriction 531 * @return resolved length restriction
523 * @throws DataModelException a violation in data model rule 532 * @throws DataModelException a violation in data model rule
524 */ 533 */
525 - private YangRangeRestriction resolveLengthRestriction(YangRangeRestriction refLengthRestriction) throws 534 + private YangRangeRestriction resolveLengthRestriction(YangRangeRestriction refLengthRestriction)
535 + throws
526 DataModelException { 536 DataModelException {
527 537
528 /* 538 /*
...@@ -572,7 +582,8 @@ public class YangDerivedInfo<T> implements LocationInfo { ...@@ -572,7 +582,8 @@ public class YangDerivedInfo<T> implements LocationInfo {
572 * @param curRestriction self restriction 582 * @param curRestriction self restriction
573 */ 583 */
574 private void resolveLengthAndRangeRestriction(YangRangeRestriction refRestriction, 584 private void resolveLengthAndRangeRestriction(YangRangeRestriction refRestriction,
575 - YangRangeRestriction curRestriction) throws DataModelException { 585 + YangRangeRestriction curRestriction)
586 + throws DataModelException {
576 for (Object curInterval : curRestriction.getAscendingRangeIntervals()) { 587 for (Object curInterval : curRestriction.getAscendingRangeIntervals()) {
577 if (!(curInterval instanceof YangRangeInterval)) { 588 if (!(curInterval instanceof YangRangeInterval)) {
578 throw new DataModelException("Linker error: Current range intervals not processed correctly."); 589 throw new DataModelException("Linker error: Current range intervals not processed correctly.");
...@@ -594,7 +605,8 @@ public class YangDerivedInfo<T> implements LocationInfo { ...@@ -594,7 +605,8 @@ public class YangDerivedInfo<T> implements LocationInfo {
594 * @param refRangeRestriction referred range restriction of typedef 605 * @param refRangeRestriction referred range restriction of typedef
595 * @throws DataModelException a violation in data model rule 606 * @throws DataModelException a violation in data model rule
596 */ 607 */
597 - private void resolveRangeRestriction(YangRangeRestriction refRangeRestriction) throws DataModelException { 608 + private void resolveRangeRestriction(YangRangeRestriction refRangeRestriction)
609 + throws DataModelException {
598 610
599 /* 611 /*
600 * Check that string restriction should be null when built-in type is 612 * Check that string restriction should be null when built-in type is
......
...@@ -31,7 +31,9 @@ import org.onosproject.yangutils.utils.YangConstructType; ...@@ -31,7 +31,9 @@ import org.onosproject.yangutils.utils.YangConstructType;
31 /** 31 /**
32 * Represents the enumeration data type information. 32 * Represents the enumeration data type information.
33 */ 33 */
34 -public class YangEnumeration extends YangNode implements Parsable, CollisionDetector { 34 +public class YangEnumeration
35 + extends YangNode
36 + implements Parsable, CollisionDetector {
35 37
36 // Enumeration info set. 38 // Enumeration info set.
37 private SortedSet<YangEnum> enumSet; 39 private SortedSet<YangEnum> enumSet;
...@@ -71,7 +73,8 @@ public class YangEnumeration extends YangNode implements Parsable, CollisionDete ...@@ -71,7 +73,8 @@ public class YangEnumeration extends YangNode implements Parsable, CollisionDete
71 * @param enumInfo the ENUM information to be added 73 * @param enumInfo the ENUM information to be added
72 * @throws DataModelException due to violation in data model rules 74 * @throws DataModelException due to violation in data model rules
73 */ 75 */
74 - public void addEnumInfo(YangEnum enumInfo) throws DataModelException { 76 + public void addEnumInfo(YangEnum enumInfo)
77 + throws DataModelException {
75 if (!getEnumSet().add(enumInfo)) { 78 if (!getEnumSet().add(enumInfo)) {
76 throw new DataModelException("YANG ENUM already exists"); 79 throw new DataModelException("YANG ENUM already exists");
77 } 80 }
...@@ -113,7 +116,8 @@ public class YangEnumeration extends YangNode implements Parsable, CollisionDete ...@@ -113,7 +116,8 @@ public class YangEnumeration extends YangNode implements Parsable, CollisionDete
113 * @throws DataModelException a violation of data model rules 116 * @throws DataModelException a violation of data model rules
114 */ 117 */
115 @Override 118 @Override
116 - public void validateDataOnEntry() throws DataModelException { 119 + public void validateDataOnEntry()
120 + throws DataModelException {
117 // TODO auto-generated method stub, to be implemented by parser 121 // TODO auto-generated method stub, to be implemented by parser
118 } 122 }
119 123
...@@ -123,21 +127,24 @@ public class YangEnumeration extends YangNode implements Parsable, CollisionDete ...@@ -123,21 +127,24 @@ public class YangEnumeration extends YangNode implements Parsable, CollisionDete
123 * @throws DataModelException a violation of data model rules 127 * @throws DataModelException a violation of data model rules
124 */ 128 */
125 @Override 129 @Override
126 - public void validateDataOnExit() throws DataModelException { 130 + public void validateDataOnExit()
131 + throws DataModelException {
127 // TODO auto-generated method stub, to be implemented by parser 132 // TODO auto-generated method stub, to be implemented by parser
128 } 133 }
129 134
130 @Override 135 @Override
131 - public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { 136 + public void detectCollidingChild(String identifierName, YangConstructType dataType)
137 + throws DataModelException {
132 /* 138 /*
133 - Do nothing.The implementation for this is not required. 139 + Do nothing, since it is not part of the schema tree, it is only type of an existing node in schema tree.
134 */ 140 */
135 } 141 }
136 142
137 @Override 143 @Override
138 - public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 144 + public void detectSelfCollision(String identifierName, YangConstructType dataType)
145 + throws DataModelException {
139 /* 146 /*
140 - Do nothing.The implementation for this is not required. 147 + Do nothing, since it is not part of the schema tree, it is only type of an existing node in schema tree.
141 */ 148 */
142 } 149 }
143 } 150 }
......
...@@ -77,7 +77,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -77,7 +77,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
77 /** 77 /**
78 * Represents data model node to maintain information defined in YANG grouping. 78 * Represents data model node to maintain information defined in YANG grouping.
79 */ 79 */
80 -public class YangGrouping extends YangNode 80 +public class YangGrouping
81 + extends YangNode
81 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector { 82 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector {
82 83
83 /** 84 /**
...@@ -174,7 +175,8 @@ public class YangGrouping extends YangNode ...@@ -174,7 +175,8 @@ public class YangGrouping extends YangNode
174 * 175 *
175 * @param leafsList the list of leaf to set 176 * @param leafsList the list of leaf to set
176 */ 177 */
177 - private void setListOfLeaf(List<YangLeaf> leafsList) { 178 + @Override
179 + public void setListOfLeaf(List<YangLeaf> leafsList) {
178 listOfLeaf = leafsList; 180 listOfLeaf = leafsList;
179 } 181 }
180 182
...@@ -203,7 +205,8 @@ public class YangGrouping extends YangNode ...@@ -203,7 +205,8 @@ public class YangGrouping extends YangNode
203 * 205 *
204 * @param listOfLeafList the list of leaf-list to set 206 * @param listOfLeafList the list of leaf-list to set
205 */ 207 */
206 - private void setListOfLeafList(List<YangLeafList> listOfLeafList) { 208 + @Override
209 + public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
207 this.listOfLeafList = listOfLeafList; 210 this.listOfLeafList = listOfLeafList;
208 } 211 }
209 212
...@@ -273,7 +276,8 @@ public class YangGrouping extends YangNode ...@@ -273,7 +276,8 @@ public class YangGrouping extends YangNode
273 * @throws DataModelException a violation of data model rules 276 * @throws DataModelException a violation of data model rules
274 */ 277 */
275 @Override 278 @Override
276 - public void validateDataOnEntry() throws DataModelException { 279 + public void validateDataOnEntry()
280 + throws DataModelException {
277 // TODO auto-generated method stub, to be implemented by parser 281 // TODO auto-generated method stub, to be implemented by parser
278 } 282 }
279 283
...@@ -283,7 +287,8 @@ public class YangGrouping extends YangNode ...@@ -283,7 +287,8 @@ public class YangGrouping extends YangNode
283 * @throws DataModelException a violation of data model rules 287 * @throws DataModelException a violation of data model rules
284 */ 288 */
285 @Override 289 @Override
286 - public void validateDataOnExit() throws DataModelException { 290 + public void validateDataOnExit()
291 + throws DataModelException {
287 // TODO auto-generated method stub, to be implemented by parser 292 // TODO auto-generated method stub, to be implemented by parser
288 } 293 }
289 294
...@@ -299,13 +304,15 @@ public class YangGrouping extends YangNode ...@@ -299,13 +304,15 @@ public class YangGrouping extends YangNode
299 * module. 304 * module.
300 */ 305 */
301 @Override 306 @Override
302 - public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { 307 + public void detectCollidingChild(String identifierName, YangConstructType dataType)
308 + throws DataModelException {
303 // Asks helper to detect colliding child. 309 // Asks helper to detect colliding child.
304 detectCollidingChildUtil(identifierName, dataType, this); 310 detectCollidingChildUtil(identifierName, dataType, this);
305 } 311 }
306 312
307 @Override 313 @Override
308 - public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 314 + public void detectSelfCollision(String identifierName, YangConstructType dataType)
315 + throws DataModelException {
309 if (getName().equals(identifierName)) { 316 if (getName().equals(identifierName)) {
310 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as grouping \"" + 317 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as grouping \"" +
311 getName() + "\""); 318 getName() + "\"");
......
...@@ -68,7 +68,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -68,7 +68,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
68 /** 68 /**
69 * Represents data model node to maintain information defined in YANG input. 69 * Represents data model node to maintain information defined in YANG input.
70 */ 70 */
71 -public class YangInput extends YangNode 71 +public class YangInput
72 + extends YangNode
72 implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentationHolder { 73 implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentationHolder {
73 74
74 /** 75 /**
...@@ -96,13 +97,15 @@ public class YangInput extends YangNode ...@@ -96,13 +97,15 @@ public class YangInput extends YangNode
96 } 97 }
97 98
98 @Override 99 @Override
99 - public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { 100 + public void detectCollidingChild(String identifierName, YangConstructType dataType)
101 + throws DataModelException {
100 // Detect colliding child. 102 // Detect colliding child.
101 detectCollidingChildUtil(identifierName, dataType, this); 103 detectCollidingChildUtil(identifierName, dataType, this);
102 } 104 }
103 105
104 @Override 106 @Override
105 - public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 107 + public void detectSelfCollision(String identifierName, YangConstructType dataType)
108 + throws DataModelException {
106 if (this.getName().equals(identifierName)) { 109 if (this.getName().equals(identifierName)) {
107 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as input \"" 110 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as input \""
108 + this.getName() + "\""); 111 + this.getName() + "\"");
...@@ -115,12 +118,14 @@ public class YangInput extends YangNode ...@@ -115,12 +118,14 @@ public class YangInput extends YangNode
115 } 118 }
116 119
117 @Override 120 @Override
118 - public void validateDataOnEntry() throws DataModelException { 121 + public void validateDataOnEntry()
122 + throws DataModelException {
119 //TODO: implement the method. 123 //TODO: implement the method.
120 } 124 }
121 125
122 @Override 126 @Override
123 - public void validateDataOnExit() throws DataModelException { 127 + public void validateDataOnExit()
128 + throws DataModelException {
124 //TODO: implement the method. 129 //TODO: implement the method.
125 } 130 }
126 131
...@@ -130,6 +135,12 @@ public class YangInput extends YangNode ...@@ -130,6 +135,12 @@ public class YangInput extends YangNode
130 } 135 }
131 136
132 @Override 137 @Override
138 + public void setListOfLeaf(List<YangLeaf> leafsList) {
139 + listOfLeaf = leafsList;
140 + }
141 +
142 +
143 + @Override
133 public void addLeaf(YangLeaf leaf) { 144 public void addLeaf(YangLeaf leaf) {
134 getListOfLeaf().add(leaf); 145 getListOfLeaf().add(leaf);
135 } 146 }
...@@ -140,6 +151,11 @@ public class YangInput extends YangNode ...@@ -140,6 +151,11 @@ public class YangInput extends YangNode
140 } 151 }
141 152
142 @Override 153 @Override
154 + public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
155 + this.listOfLeafList = listOfLeafList;
156 + }
157 +
158 + @Override
143 public void addLeafList(YangLeafList leafList) { 159 public void addLeafList(YangLeafList leafList) {
144 getListOfLeafList().add(leafList); 160 getListOfLeafList().add(leafList);
145 } 161 }
......
...@@ -58,7 +58,7 @@ import org.onosproject.yangutils.utils.YangConstructType; ...@@ -58,7 +58,7 @@ import org.onosproject.yangutils.utils.YangConstructType;
58 * Represents leaf data represented in YANG. 58 * Represents leaf data represented in YANG.
59 */ 59 */
60 public class YangLeaf 60 public class YangLeaf
61 - implements YangCommonInfo, Parsable { 61 + implements YangCommonInfo, Parsable, Cloneable {
62 62
63 /** 63 /**
64 * Name of leaf. 64 * Name of leaf.
...@@ -107,6 +107,11 @@ public class YangLeaf ...@@ -107,6 +107,11 @@ public class YangLeaf
107 private String defaultValueInString; 107 private String defaultValueInString;
108 108
109 /** 109 /**
110 + * YANG Node in which the leaf is contained.
111 + */
112 + YangLeavesHolder containedIn;
113 +
114 + /**
110 * Creates a YANG leaf. 115 * Creates a YANG leaf.
111 */ 116 */
112 public YangLeaf() { 117 public YangLeaf() {
...@@ -281,6 +286,30 @@ public class YangLeaf ...@@ -281,6 +286,30 @@ public class YangLeaf
281 } 286 }
282 287
283 /** 288 /**
289 + * Retrieves the YANG node in which the leaf is defined.
290 + *
291 + * @return the YANG node in which the leaf is defined
292 + */
293 + public YangLeavesHolder getContainedIn() {
294 + return containedIn;
295 + }
296 +
297 + /**
298 + * Assigns the YANG node in which the leaf is defined.
299 + *
300 + * @param containedIn the YANG node in which the leaf is defined
301 + */
302 + public void setContainedIn(YangLeavesHolder containedIn) {
303 + this.containedIn = containedIn;
304 + }
305 +
306 + @Override
307 + public YangLeaf clone()
308 + throws CloneNotSupportedException {
309 + return (YangLeaf) super.clone();
310 + }
311 +
312 + /**
284 * Returns the type of the parsed data. 313 * Returns the type of the parsed data.
285 * 314 *
286 * @return returns LEAF_DATA 315 * @return returns LEAF_DATA
......
...@@ -54,7 +54,7 @@ import org.onosproject.yangutils.utils.YangConstructType; ...@@ -54,7 +54,7 @@ import org.onosproject.yangutils.utils.YangConstructType;
54 * Represents leaf-list data represented in YANG. 54 * Represents leaf-list data represented in YANG.
55 */ 55 */
56 public class YangLeafList 56 public class YangLeafList
57 - implements YangCommonInfo, Parsable { 57 + implements YangCommonInfo, Parsable, Cloneable {
58 58
59 /** 59 /**
60 * Name of leaf-list. 60 * Name of leaf-list.
...@@ -124,6 +124,11 @@ public class YangLeafList ...@@ -124,6 +124,11 @@ public class YangLeafList
124 private YangType<?> dataType; 124 private YangType<?> dataType;
125 125
126 /** 126 /**
127 + * YANG Node in which the leaf is contained.
128 + */
129 + YangLeavesHolder containedIn;
130 +
131 + /**
127 * Creates a YANG leaf-list. 132 * Creates a YANG leaf-list.
128 */ 133 */
129 public YangLeafList() { 134 public YangLeafList() {
...@@ -298,6 +303,30 @@ public class YangLeafList ...@@ -298,6 +303,30 @@ public class YangLeafList
298 } 303 }
299 304
300 /** 305 /**
306 + * Retrieves the YANG node in which the leaf is defined.
307 + *
308 + * @return the YANG node in which the leaf is defined
309 + */
310 + public YangLeavesHolder getContainedIn() {
311 + return containedIn;
312 + }
313 +
314 + /**
315 + * Assigns the YANG node in which the leaf is defined.
316 + *
317 + * @param containedIn the YANG node in which the leaf is defined
318 + */
319 + public void setContainedIn(YangLeavesHolder containedIn) {
320 + this.containedIn = containedIn;
321 + }
322 +
323 + @Override
324 + public YangLeafList clone()
325 + throws CloneNotSupportedException {
326 + return (YangLeafList) super.clone();
327 + }
328 +
329 + /**
301 * Returns the type of the parsed data. 330 * Returns the type of the parsed data.
302 * 331 *
303 * @return returns LEAF_LIST_DATA 332 * @return returns LEAF_LIST_DATA
......
...@@ -33,6 +33,13 @@ public interface YangLeavesHolder { ...@@ -33,6 +33,13 @@ public interface YangLeavesHolder {
33 List<YangLeaf> getListOfLeaf(); 33 List<YangLeaf> getListOfLeaf();
34 34
35 /** 35 /**
36 + * Sets the list of leaves.
37 + *
38 + * @param leafsList the list of leaf to set
39 + */
40 + void setListOfLeaf(List<YangLeaf> leafsList);
41 +
42 + /**
36 * Adds leaf in data holder like container / list. 43 * Adds leaf in data holder like container / list.
37 * 44 *
38 * @param leaf the leaf to be added 45 * @param leaf the leaf to be added
...@@ -47,6 +54,13 @@ public interface YangLeavesHolder { ...@@ -47,6 +54,13 @@ public interface YangLeavesHolder {
47 List<YangLeafList> getListOfLeafList(); 54 List<YangLeafList> getListOfLeafList();
48 55
49 /** 56 /**
57 + * Sets the list of leaf-list.
58 + *
59 + * @param listOfLeafList the list of leaf-list to set
60 + */
61 + void setListOfLeafList(List<YangLeafList> listOfLeafList);
62 +
63 + /**
50 * Adds leaf-list in data holder like container / list. 64 * Adds leaf-list in data holder like container / list.
51 * 65 *
52 * @param leafList the leaf-list to be added 66 * @param leafList the leaf-list to be added
......
...@@ -67,7 +67,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -67,7 +67,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
67 /** 67 /**
68 * Represents list data represented in YANG. 68 * Represents list data represented in YANG.
69 */ 69 */
70 -public class YangList extends YangNode 70 +public class YangList
71 + extends YangNode
71 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder { 72 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder {
72 73
73 /** 74 /**
...@@ -254,7 +255,8 @@ public class YangList extends YangNode ...@@ -254,7 +255,8 @@ public class YangList extends YangNode
254 * @param key key field name. 255 * @param key key field name.
255 * @throws DataModelException a violation of data model rules 256 * @throws DataModelException a violation of data model rules
256 */ 257 */
257 - public void addKey(String key) throws DataModelException { 258 + public void addKey(String key)
259 + throws DataModelException {
258 if (getKeyList() == null) { 260 if (getKeyList() == null) {
259 setKeyList(new LinkedList<String>()); 261 setKeyList(new LinkedList<String>());
260 } 262 }
...@@ -282,7 +284,8 @@ public class YangList extends YangNode ...@@ -282,7 +284,8 @@ public class YangList extends YangNode
282 * 284 *
283 * @param leafsList the list of leaf to set 285 * @param leafsList the list of leaf to set
284 */ 286 */
285 - private void setListOfLeaf(List<YangLeaf> leafsList) { 287 + @Override
288 + public void setListOfLeaf(List<YangLeaf> leafsList) {
286 listOfLeaf = leafsList; 289 listOfLeaf = leafsList;
287 } 290 }
288 291
...@@ -315,7 +318,8 @@ public class YangList extends YangNode ...@@ -315,7 +318,8 @@ public class YangList extends YangNode
315 * 318 *
316 * @param listOfLeafList the list of leaf-list to set 319 * @param listOfLeafList the list of leaf-list to set
317 */ 320 */
318 - private void setListOfLeafList(List<YangLeafList> listOfLeafList) { 321 + @Override
322 + public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
319 this.listOfLeafList = listOfLeafList; 323 this.listOfLeafList = listOfLeafList;
320 } 324 }
321 325
...@@ -425,7 +429,8 @@ public class YangList extends YangNode ...@@ -425,7 +429,8 @@ public class YangList extends YangNode
425 * @throws DataModelException a violation of data model rules 429 * @throws DataModelException a violation of data model rules
426 */ 430 */
427 @Override 431 @Override
428 - public void validateDataOnEntry() throws DataModelException { 432 + public void validateDataOnEntry()
433 + throws DataModelException {
429 // TODO auto-generated method stub, to be implemented by parser 434 // TODO auto-generated method stub, to be implemented by parser
430 } 435 }
431 436
...@@ -435,7 +440,8 @@ public class YangList extends YangNode ...@@ -435,7 +440,8 @@ public class YangList extends YangNode
435 * @throws DataModelException a violation of data model rules 440 * @throws DataModelException a violation of data model rules
436 */ 441 */
437 @Override 442 @Override
438 - public void validateDataOnExit() throws DataModelException { 443 + public void validateDataOnExit()
444 + throws DataModelException {
439 List<String> keys = getKeyList(); 445 List<String> keys = getKeyList();
440 List<YangLeaf> leaves = getListOfLeaf(); 446 List<YangLeaf> leaves = getListOfLeaf();
441 List<YangLeafList> leafLists = getListOfLeafList(); 447 List<YangLeafList> leafLists = getListOfLeafList();
...@@ -493,7 +499,8 @@ public class YangList extends YangNode ...@@ -493,7 +499,8 @@ public class YangList extends YangNode
493 * @param leafLists list of leaf-list attributes of YANG list 499 * @param leafLists list of leaf-list attributes of YANG list
494 * @throws DataModelException a violation of data model rules 500 * @throws DataModelException a violation of data model rules
495 */ 501 */
496 - private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException { 502 + private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists)
503 + throws DataModelException {
497 504
498 /* 505 /*
499 * If a node has "config" set to "false", no node underneath it can have 506 * If a node has "config" set to "false", no node underneath it can have
...@@ -526,7 +533,8 @@ public class YangList extends YangNode ...@@ -526,7 +533,8 @@ public class YangList extends YangNode
526 * @param keys list of key attributes of list 533 * @param keys list of key attributes of list
527 * @throws DataModelException a violation of data model rules 534 * @throws DataModelException a violation of data model rules
528 */ 535 */
529 - private void validateKey(List<YangLeaf> leaves, List<YangLeafList> leafLists, List<String> keys) throws 536 + private void validateKey(List<YangLeaf> leaves, List<YangLeafList> leafLists, List<String> keys)
537 + throws
530 DataModelException { 538 DataModelException {
531 boolean leafFound = false; 539 boolean leafFound = false;
532 List<YangLeaf> keyLeaves = new LinkedList<>(); 540 List<YangLeaf> keyLeaves = new LinkedList<>();
...@@ -595,13 +603,15 @@ public class YangList extends YangNode ...@@ -595,13 +603,15 @@ public class YangList extends YangNode
595 } 603 }
596 604
597 @Override 605 @Override
598 - public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { 606 + public void detectCollidingChild(String identifierName, YangConstructType dataType)
607 + throws DataModelException {
599 // Asks helper to detect colliding child. 608 // Asks helper to detect colliding child.
600 detectCollidingChildUtil(identifierName, dataType, this); 609 detectCollidingChildUtil(identifierName, dataType, this);
601 } 610 }
602 611
603 @Override 612 @Override
604 - public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 613 + public void detectSelfCollision(String identifierName, YangConstructType dataType)
614 + throws DataModelException {
605 if (getName().equals(identifierName)) { 615 if (getName().equals(identifierName)) {
606 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as list \"" + 616 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as list \"" +
607 getName() + "\""); 617 getName() + "\"");
......
...@@ -19,9 +19,11 @@ import java.util.Iterator; ...@@ -19,9 +19,11 @@ import java.util.Iterator;
19 import java.util.LinkedList; 19 import java.util.LinkedList;
20 import java.util.List; 20 import java.util.List;
21 import java.util.Set; 21 import java.util.Set;
22 +
22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 import org.onosproject.yangutils.linker.exceptions.LinkerException; 24 import org.onosproject.yangutils.linker.exceptions.LinkerException;
24 -import org.onosproject.yangutils.linker.impl.YangReferenceResolver; 25 +import org.onosproject.yangutils.linker.ResolvableType;
26 +import org.onosproject.yangutils.linker.YangReferenceResolver;
25 import org.onosproject.yangutils.linker.impl.YangResolutionInfo; 27 import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
26 import org.onosproject.yangutils.parser.Parsable; 28 import org.onosproject.yangutils.parser.Parsable;
27 import org.onosproject.yangutils.plugin.manager.YangFileInfo; 29 import org.onosproject.yangutils.plugin.manager.YangFileInfo;
...@@ -74,7 +76,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi ...@@ -74,7 +76,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi
74 /** 76 /**
75 * Represents data model node to maintain information defined in YANG module. 77 * Represents data model node to maintain information defined in YANG module.
76 */ 78 */
77 -public class YangModule extends YangNode 79 +public class YangModule
80 + extends YangNode
78 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver, 81 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
79 RpcNotificationContainer { 82 RpcNotificationContainer {
80 83
...@@ -85,7 +88,7 @@ public class YangModule extends YangNode ...@@ -85,7 +88,7 @@ public class YangModule extends YangNode
85 88
86 /** 89 /**
87 * Reference:RFC 6020. 90 * Reference:RFC 6020.
88 - * <p> 91 + *
89 * The "contact" statement provides contact information for the module. The 92 * The "contact" statement provides contact information for the module. The
90 * argument is a string that is used to specify contact information for the 93 * argument is a string that is used to specify contact information for the
91 * person or persons to whom technical queries concerning this module should 94 * person or persons to whom technical queries concerning this module should
...@@ -96,7 +99,7 @@ public class YangModule extends YangNode ...@@ -96,7 +99,7 @@ public class YangModule extends YangNode
96 99
97 /** 100 /**
98 * Reference:RFC 6020. 101 * Reference:RFC 6020.
99 - * <p> 102 + *
100 * The "description" statement takes as an argument a string that contains a 103 * The "description" statement takes as an argument a string that contains a
101 * human-readable textual description of this definition. The text is 104 * human-readable textual description of this definition. The text is
102 * provided in a language (or languages) chosen by the module developer; for 105 * provided in a language (or languages) chosen by the module developer; for
...@@ -131,7 +134,7 @@ public class YangModule extends YangNode ...@@ -131,7 +134,7 @@ public class YangModule extends YangNode
131 134
132 /** 135 /**
133 * Reference:RFC 6020. 136 * Reference:RFC 6020.
134 - * <p> 137 + *
135 * The "organization" statement defines the party responsible for this 138 * The "organization" statement defines the party responsible for this
136 * module. The argument is a string that is used to specify a textual 139 * module. The argument is a string that is used to specify a textual
137 * description of the organization(s) under whose auspices this module was 140 * description of the organization(s) under whose auspices this module was
...@@ -193,7 +196,12 @@ public class YangModule extends YangNode ...@@ -193,7 +196,12 @@ public class YangModule extends YangNode
193 * matching "typedef" or "grouping" statement among the immediate 196 * matching "typedef" or "grouping" statement among the immediate
194 * sub-statements of each ancestor statement. 197 * sub-statements of each ancestor statement.
195 */ 198 */
196 - private List<YangResolutionInfo> unresolvedResolutionList; 199 + private List<YangResolutionInfo> derivedTypeResolutionList;
200 +
201 + /**
202 + * uses resolution list.
203 + */
204 + private List<YangResolutionInfo> usesResolutionList;
197 205
198 /** 206 /**
199 * Creates a YANG node of module type. 207 * Creates a YANG node of module type.
...@@ -201,7 +209,8 @@ public class YangModule extends YangNode ...@@ -201,7 +209,8 @@ public class YangModule extends YangNode
201 public YangModule() { 209 public YangModule() {
202 210
203 super(YangNodeType.MODULE_NODE); 211 super(YangNodeType.MODULE_NODE);
204 - unresolvedResolutionList = new LinkedList<YangResolutionInfo>(); 212 + derivedTypeResolutionList = new LinkedList<YangResolutionInfo>();
213 + usesResolutionList = new LinkedList<YangResolutionInfo>();
205 importList = new LinkedList<YangImport>(); 214 importList = new LinkedList<YangImport>();
206 includeList = new LinkedList<YangInclude>(); 215 includeList = new LinkedList<YangInclude>();
207 listOfLeaf = new LinkedList<YangLeaf>(); 216 listOfLeaf = new LinkedList<YangLeaf>();
...@@ -326,6 +335,11 @@ public class YangModule extends YangNode ...@@ -326,6 +335,11 @@ public class YangModule extends YangNode
326 return listOfLeaf; 335 return listOfLeaf;
327 } 336 }
328 337
338 + @Override
339 + public void setListOfLeaf(List<YangLeaf> leafsList) {
340 + listOfLeaf = leafsList;
341 + }
342 +
329 /** 343 /**
330 * Adds a leaf in module. 344 * Adds a leaf in module.
331 * 345 *
...@@ -346,6 +360,12 @@ public class YangModule extends YangNode ...@@ -346,6 +360,12 @@ public class YangModule extends YangNode
346 return listOfLeafList; 360 return listOfLeafList;
347 } 361 }
348 362
363 + @Override
364 + public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
365 + this.listOfLeafList = listOfLeafList;
366 + }
367 +
368 +
349 /** 369 /**
350 * Adds a leaf-list in module. 370 * Adds a leaf-list in module.
351 * 371 *
...@@ -413,17 +433,19 @@ public class YangModule extends YangNode ...@@ -413,17 +433,19 @@ public class YangModule extends YangNode
413 } 433 }
414 434
415 @Override 435 @Override
416 - public void resolveSelfFileLinking() throws DataModelException { 436 + public void resolveSelfFileLinking(ResolvableType type)
437 + throws DataModelException {
417 // Get the list to be resolved. 438 // Get the list to be resolved.
418 - List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(); 439 + List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
419 // Resolve linking for a resolution list. 440 // Resolve linking for a resolution list.
420 resolveLinkingForResolutionList(resolutionList, this); 441 resolveLinkingForResolutionList(resolutionList, this);
421 } 442 }
422 443
423 @Override 444 @Override
424 - public void resolveInterFileLinking() throws DataModelException { 445 + public void resolveInterFileLinking(ResolvableType type)
446 + throws DataModelException {
425 // Get the list to be resolved. 447 // Get the list to be resolved.
426 - List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(); 448 + List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
427 // Resolve linking for a resolution list. 449 // Resolve linking for a resolution list.
428 linkInterFileReferences(resolutionList, this); 450 linkInterFileReferences(resolutionList, this);
429 } 451 }
...@@ -500,7 +522,8 @@ public class YangModule extends YangNode ...@@ -500,7 +522,8 @@ public class YangModule extends YangNode
500 * @throws DataModelException a violation of data model rules 522 * @throws DataModelException a violation of data model rules
501 */ 523 */
502 @Override 524 @Override
503 - public void validateDataOnEntry() throws DataModelException { 525 + public void validateDataOnEntry()
526 + throws DataModelException {
504 /* 527 /*
505 * Module is root in the data model tree, hence there is no entry 528 * Module is root in the data model tree, hence there is no entry
506 * validation 529 * validation
...@@ -513,7 +536,8 @@ public class YangModule extends YangNode ...@@ -513,7 +536,8 @@ public class YangModule extends YangNode
513 * @throws DataModelException a violation of data model rules 536 * @throws DataModelException a violation of data model rules
514 */ 537 */
515 @Override 538 @Override
516 - public void validateDataOnExit() throws DataModelException { 539 + public void validateDataOnExit()
540 + throws DataModelException {
517 /* 541 /*
518 * TODO: perform symbol linking for the imported or included YANG info. 542 * TODO: perform symbol linking for the imported or included YANG info.
519 * TODO: perform symbol resolution for referred YANG entities. 543 * TODO: perform symbol resolution for referred YANG entities.
...@@ -521,29 +545,47 @@ public class YangModule extends YangNode ...@@ -521,29 +545,47 @@ public class YangModule extends YangNode
521 } 545 }
522 546
523 @Override 547 @Override
524 - public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { 548 + public void detectCollidingChild(String identifierName, YangConstructType dataType)
549 + throws DataModelException {
525 // Asks helper to detect colliding child. 550 // Asks helper to detect colliding child.
526 detectCollidingChildUtil(identifierName, dataType, this); 551 detectCollidingChildUtil(identifierName, dataType, this);
527 } 552 }
528 553
529 @Override 554 @Override
530 - public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 555 + public void detectSelfCollision(String identifierName, YangConstructType dataType)
556 + throws DataModelException {
531 // Not required as module doesn't have any parent. 557 // Not required as module doesn't have any parent.
532 } 558 }
533 559
534 @Override 560 @Override
535 - public List<YangResolutionInfo> getUnresolvedResolutionList() { 561 + public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) {
536 - return unresolvedResolutionList; 562 + if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
563 + return derivedTypeResolutionList;
564 + } else {
565 + return usesResolutionList;
566 + }
567 +
537 } 568 }
538 569
539 @Override 570 @Override
540 - public void addToResolutionList(YangResolutionInfo resolutionInfo) { 571 + public void addToResolutionList(YangResolutionInfo resolutionInfo,
541 - unresolvedResolutionList.add(resolutionInfo); 572 + ResolvableType type) {
573 + if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
574 + derivedTypeResolutionList.add(resolutionInfo);
575 + } else if (type == ResolvableType.YANG_USES) {
576 + usesResolutionList.add(resolutionInfo);
577 + }
542 } 578 }
543 579
544 @Override 580 @Override
545 - public void setResolutionList(List<YangResolutionInfo> resolutionList) { 581 + public void setResolutionList(List<YangResolutionInfo> resolutionList,
546 - unresolvedResolutionList = resolutionList; 582 + ResolvableType type) {
583 + if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
584 + derivedTypeResolutionList = resolutionList;
585 + } else if (type == ResolvableType.YANG_USES) {
586 + usesResolutionList = resolutionList;
587 + }
588 +
547 } 589 }
548 590
549 @Override 591 @Override
......
...@@ -16,12 +16,6 @@ ...@@ -16,12 +16,6 @@
16 package org.onosproject.yangutils.datamodel; 16 package org.onosproject.yangutils.datamodel;
17 17
18 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 18 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
19 -import org.onosproject.yangutils.parser.Parsable;
20 -import org.onosproject.yangutils.translator.tojava.TraversalType;
21 -
22 -import static org.onosproject.yangutils.translator.tojava.TraversalType.CHILD;
23 -import static org.onosproject.yangutils.translator.tojava.TraversalType.PARENT;
24 -import static org.onosproject.yangutils.translator.tojava.TraversalType.SIBILING;
25 19
26 /** 20 /**
27 * Represents base class of a node in data model tree. 21 * Represents base class of a node in data model tree.
...@@ -229,179 +223,4 @@ public abstract class YangNode ...@@ -229,179 +223,4 @@ public abstract class YangNode
229 newChild.setPreviousSibling(curNode); 223 newChild.setPreviousSibling(curNode);
230 } 224 }
231 } 225 }
232 -
233 - /**
234 - * Clone the current node contents and create a new node.
235 - *
236 - * @return cloned node
237 - * @throws CloneNotSupportedException clone is not supported by the referred
238 - * node
239 - */
240 - @Override
241 - public YangNode clone()
242 - throws CloneNotSupportedException {
243 - YangNode clonedNode = (YangNode) super.clone();
244 - clonedNode.setParent(null);
245 - clonedNode.setChild(null);
246 - clonedNode.setNextSibling(null);
247 - clonedNode.setPreviousSibling(null);
248 - return clonedNode;
249 - }
250 -
251 - /**
252 - * Clone the subtree from the specified source node to the mentioned target
253 - * node. The source and target root node cloning is carried out by the
254 - * caller.
255 - *
256 - * @param srcRootNode source node for sub tree cloning
257 - * @param dstRootNode destination node where the sub tree needs to be cloned
258 - * @throws DataModelException data model error
259 - */
260 - public static void cloneSubTree(YangNode srcRootNode, YangNode dstRootNode)
261 - throws DataModelException {
262 -
263 - YangNode nextNodeToClone = srcRootNode;
264 - TraversalType curTraversal;
265 -
266 - YangNode clonedTreeCurNode = dstRootNode;
267 - YangNode newNode = null;
268 -
269 - nextNodeToClone = nextNodeToClone.getChild();
270 - if (nextNodeToClone == null) {
271 - return;
272 - } else {
273 - /**
274 - * Root level cloning is taken care in the caller.
275 - */
276 - curTraversal = CHILD;
277 - }
278 -
279 - /**
280 - * Caller ensures the cloning of the root nodes
281 - */
282 - try {
283 - while (nextNodeToClone != srcRootNode) {
284 - if (nextNodeToClone == null) {
285 - throw new DataModelException("Internal error: Cloning failed, source tree null pointer reached");
286 - }
287 - if (curTraversal != PARENT) {
288 - newNode = nextNodeToClone.clone();
289 - detectCollisionWhileCloning(clonedTreeCurNode, newNode, curTraversal);
290 - }
291 -
292 - if (curTraversal == CHILD) {
293 -
294 - /**
295 - * add the new node to the cloned tree.
296 - */
297 - clonedTreeCurNode.addChild(newNode);
298 -
299 - /**
300 - * update the cloned tree's traversal current node as the
301 - * new node.
302 - */
303 - clonedTreeCurNode = newNode;
304 - } else if (curTraversal == SIBILING) {
305 -
306 - clonedTreeCurNode.addNextSibling(newNode);
307 - clonedTreeCurNode = newNode;
308 - } else if (curTraversal == PARENT) {
309 - clonedTreeCurNode = clonedTreeCurNode.getParent();
310 - }
311 -
312 - if (curTraversal != PARENT && nextNodeToClone.getChild() != null) {
313 - curTraversal = CHILD;
314 -
315 - /**
316 - * update the traversal's current node.
317 - */
318 - nextNodeToClone = nextNodeToClone.getChild();
319 -
320 - } else if (nextNodeToClone.getNextSibling() != null) {
321 -
322 - curTraversal = SIBILING;
323 -
324 - nextNodeToClone = nextNodeToClone.getNextSibling();
325 - } else {
326 - curTraversal = PARENT;
327 - nextNodeToClone = nextNodeToClone.getParent();
328 - }
329 - }
330 - } catch (CloneNotSupportedException e) {
331 - throw new DataModelException("Failed to clone the tree");
332 - }
333 -
334 - }
335 -
336 - /**
337 - * Detects collision when the grouping is deep copied to the uses's parent.
338 - *
339 - * @param currentNode parent/previous sibling node for the new node
340 - * @param newNode node which has to be added
341 - * @param addAs traversal type of the node
342 - * @throws DataModelException data model error
343 - */
344 - private static void detectCollisionWhileCloning(YangNode currentNode, YangNode newNode, TraversalType addAs)
345 - throws DataModelException {
346 - if (!(currentNode instanceof CollisionDetector)
347 - || !(newNode instanceof Parsable)) {
348 - throw new DataModelException("Node in data model tree does not support collision detection");
349 - }
350 -
351 - CollisionDetector collisionDetector = (CollisionDetector) currentNode;
352 - Parsable parsable = (Parsable) newNode;
353 - if (addAs == TraversalType.CHILD) {
354 - collisionDetector.detectCollidingChild(newNode.getName(), parsable.getYangConstructType());
355 - } else if (addAs == TraversalType.SIBILING) {
356 - currentNode = currentNode.getParent();
357 - if (!(currentNode instanceof CollisionDetector)) {
358 - throw new DataModelException("Node in data model tree does not support collision detection");
359 - }
360 - collisionDetector = (CollisionDetector) currentNode;
361 - collisionDetector.detectCollidingChild(newNode.getName(), parsable.getYangConstructType());
362 - } else {
363 - throw new DataModelException("Errored tree cloning");
364 - }
365 -
366 - }
367 -
368 - /**
369 - * Add a new next sibling.
370 - *
371 - * @param newSibling new sibling to be added
372 - * @throws DataModelException data model error
373 - */
374 - private void addNextSibling(YangNode newSibling)
375 - throws DataModelException {
376 -
377 - if (newSibling.getNodeType() == null) {
378 - throw new DataModelException("Cloned abstract node cannot be inserted into a tree");
379 - }
380 -
381 - if (newSibling.getParent() == null) {
382 - /**
383 - * Since the siblings needs to have a common parent, set the parent
384 - * as the current node's parent
385 - */
386 - newSibling.setParent(getParent());
387 -
388 - } else {
389 - throw new DataModelException("Node is already part of a tree, and cannot be added as a sibling");
390 - }
391 -
392 - if (newSibling.getPreviousSibling() == null) {
393 - newSibling.setPreviousSibling(this);
394 - setNextSibling(newSibling);
395 - } else {
396 - throw new DataModelException("New sibling to be added is not atomic, it already has a previous sibling");
397 - }
398 -
399 - if (newSibling.getChild() != null) {
400 - throw new DataModelException("Sibling to be added is not atomic, it already has a child");
401 - }
402 -
403 - if (newSibling.getNextSibling() != null) {
404 - throw new DataModelException("Sibling to be added is not atomic, it already has a next sibling");
405 - }
406 - }
407 } 226 }
......
...@@ -74,7 +74,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -74,7 +74,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
74 /** 74 /**
75 * Represents data model node to maintain information defined in YANG notification. 75 * Represents data model node to maintain information defined in YANG notification.
76 */ 76 */
77 -public class YangNotification extends YangNode 77 +public class YangNotification
78 + extends YangNode
78 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder { 79 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder {
79 80
80 /** 81 /**
...@@ -117,13 +118,15 @@ public class YangNotification extends YangNode ...@@ -117,13 +118,15 @@ public class YangNotification extends YangNode
117 } 118 }
118 119
119 @Override 120 @Override
120 - public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { 121 + public void detectCollidingChild(String identifierName, YangConstructType dataType)
122 + throws DataModelException {
121 // Detect colliding child. 123 // Detect colliding child.
122 detectCollidingChildUtil(identifierName, dataType, this); 124 detectCollidingChildUtil(identifierName, dataType, this);
123 } 125 }
124 126
125 @Override 127 @Override
126 - public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 128 + public void detectSelfCollision(String identifierName, YangConstructType dataType)
129 + throws DataModelException {
127 if (this.getName().equals(identifierName)) { 130 if (this.getName().equals(identifierName)) {
128 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as notification \"" 131 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as notification \""
129 + this.getName() + "\""); 132 + this.getName() + "\"");
...@@ -136,12 +139,14 @@ public class YangNotification extends YangNode ...@@ -136,12 +139,14 @@ public class YangNotification extends YangNode
136 } 139 }
137 140
138 @Override 141 @Override
139 - public void validateDataOnEntry() throws DataModelException { 142 + public void validateDataOnEntry()
143 + throws DataModelException {
140 //TODO: implement the method. 144 //TODO: implement the method.
141 } 145 }
142 146
143 @Override 147 @Override
144 - public void validateDataOnExit() throws DataModelException { 148 + public void validateDataOnExit()
149 + throws DataModelException {
145 //TODO: implement the method. 150 //TODO: implement the method.
146 } 151 }
147 152
...@@ -161,6 +166,11 @@ public class YangNotification extends YangNode ...@@ -161,6 +166,11 @@ public class YangNotification extends YangNode
161 } 166 }
162 167
163 @Override 168 @Override
169 + public void setListOfLeaf(List<YangLeaf> leafsList) {
170 + listOfLeaf = leafsList;
171 + }
172 +
173 + @Override
164 public void addLeaf(YangLeaf leaf) { 174 public void addLeaf(YangLeaf leaf) {
165 getListOfLeaf().add(leaf); 175 getListOfLeaf().add(leaf);
166 } 176 }
...@@ -171,6 +181,11 @@ public class YangNotification extends YangNode ...@@ -171,6 +181,11 @@ public class YangNotification extends YangNode
171 } 181 }
172 182
173 @Override 183 @Override
184 + public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
185 + this.listOfLeafList = listOfLeafList;
186 + }
187 +
188 + @Override
174 public void addLeafList(YangLeafList leafList) { 189 public void addLeafList(YangLeafList leafList) {
175 getListOfLeafList().add(leafList); 190 getListOfLeafList().add(leafList);
176 } 191 }
......
...@@ -67,7 +67,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -67,7 +67,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
67 /** 67 /**
68 * Represents data model node to maintain information defined in YANG output. 68 * Represents data model node to maintain information defined in YANG output.
69 */ 69 */
70 -public class YangOutput extends YangNode 70 +public class YangOutput
71 + extends YangNode
71 implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentationHolder { 72 implements YangLeavesHolder, Parsable, CollisionDetector, YangAugmentationHolder {
72 73
73 /** 74 /**
...@@ -95,13 +96,15 @@ public class YangOutput extends YangNode ...@@ -95,13 +96,15 @@ public class YangOutput extends YangNode
95 } 96 }
96 97
97 @Override 98 @Override
98 - public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { 99 + public void detectCollidingChild(String identifierName, YangConstructType dataType)
100 + throws DataModelException {
99 // Detect colliding child. 101 // Detect colliding child.
100 detectCollidingChildUtil(identifierName, dataType, this); 102 detectCollidingChildUtil(identifierName, dataType, this);
101 } 103 }
102 104
103 @Override 105 @Override
104 - public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 106 + public void detectSelfCollision(String identifierName, YangConstructType dataType)
107 + throws DataModelException {
105 if (this.getName().equals(identifierName)) { 108 if (this.getName().equals(identifierName)) {
106 throw new DataModelException("YANG file error: Duplicate identifier detected, same as output \"" 109 throw new DataModelException("YANG file error: Duplicate identifier detected, same as output \""
107 + this.getName() + "\""); 110 + this.getName() + "\"");
...@@ -114,12 +117,14 @@ public class YangOutput extends YangNode ...@@ -114,12 +117,14 @@ public class YangOutput extends YangNode
114 } 117 }
115 118
116 @Override 119 @Override
117 - public void validateDataOnEntry() throws DataModelException { 120 + public void validateDataOnEntry()
121 + throws DataModelException {
118 //TODO: implement the method. 122 //TODO: implement the method.
119 } 123 }
120 124
121 @Override 125 @Override
122 - public void validateDataOnExit() throws DataModelException { 126 + public void validateDataOnExit()
127 + throws DataModelException {
123 //TODO: implement the method. 128 //TODO: implement the method.
124 } 129 }
125 130
...@@ -134,11 +139,22 @@ public class YangOutput extends YangNode ...@@ -134,11 +139,22 @@ public class YangOutput extends YangNode
134 } 139 }
135 140
136 @Override 141 @Override
142 + public void setListOfLeaf(List<YangLeaf> leafsList) {
143 + listOfLeaf = leafsList;
144 + }
145 +
146 + @Override
137 public List<YangLeafList> getListOfLeafList() { 147 public List<YangLeafList> getListOfLeafList() {
138 return listOfLeafList; 148 return listOfLeafList;
139 } 149 }
140 150
141 @Override 151 @Override
152 + public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
153 + this.listOfLeafList = listOfLeafList;
154 + }
155 +
156 +
157 + @Override
142 public void addLeafList(YangLeafList leafList) { 158 public void addLeafList(YangLeafList leafList) {
143 getListOfLeafList().add(leafList); 159 getListOfLeafList().add(leafList);
144 } 160 }
......
...@@ -19,9 +19,11 @@ import java.util.Iterator; ...@@ -19,9 +19,11 @@ import java.util.Iterator;
19 import java.util.LinkedList; 19 import java.util.LinkedList;
20 import java.util.List; 20 import java.util.List;
21 import java.util.Set; 21 import java.util.Set;
22 +
22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23 import org.onosproject.yangutils.linker.exceptions.LinkerException; 24 import org.onosproject.yangutils.linker.exceptions.LinkerException;
24 -import org.onosproject.yangutils.linker.impl.YangReferenceResolver; 25 +import org.onosproject.yangutils.linker.ResolvableType;
26 +import org.onosproject.yangutils.linker.YangReferenceResolver;
25 import org.onosproject.yangutils.linker.impl.YangResolutionInfo; 27 import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
26 import org.onosproject.yangutils.parser.Parsable; 28 import org.onosproject.yangutils.parser.Parsable;
27 import org.onosproject.yangutils.plugin.manager.YangFileInfo; 29 import org.onosproject.yangutils.plugin.manager.YangFileInfo;
...@@ -82,7 +84,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi ...@@ -82,7 +84,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi
82 /** 84 /**
83 * Represents data model node to maintain information defined in YANG sub-module. 85 * Represents data model node to maintain information defined in YANG sub-module.
84 */ 86 */
85 -public class YangSubModule extends YangNode 87 +public class YangSubModule
88 + extends YangNode
86 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver, 89 implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
87 RpcNotificationContainer { 90 RpcNotificationContainer {
88 91
...@@ -156,6 +159,7 @@ public class YangSubModule extends YangNode ...@@ -156,6 +159,7 @@ public class YangSubModule extends YangNode
156 * Prefix of parent module. 159 * Prefix of parent module.
157 */ 160 */
158 private String prefix; 161 private String prefix;
162 +
159 /*- 163 /*-
160 * Reference RFC 6020. 164 * Reference RFC 6020.
161 * 165 *
...@@ -190,14 +194,20 @@ public class YangSubModule extends YangNode ...@@ -190,14 +194,20 @@ public class YangSubModule extends YangNode
190 * matching "typedef" or "grouping" statement among the immediate 194 * matching "typedef" or "grouping" statement among the immediate
191 * sub-statements of each ancestor statement. 195 * sub-statements of each ancestor statement.
192 */ 196 */
193 - private List<YangResolutionInfo> unresolvedResolutionList; 197 + private List<YangResolutionInfo> derivedTypeResolutionList;
198 +
199 + /**
200 + * uses resolution list.
201 + */
202 + private List<YangResolutionInfo> usesResolutionList;
194 203
195 /** 204 /**
196 * Creates a sub module node. 205 * Creates a sub module node.
197 */ 206 */
198 public YangSubModule() { 207 public YangSubModule() {
199 super(YangNodeType.SUB_MODULE_NODE); 208 super(YangNodeType.SUB_MODULE_NODE);
200 - unresolvedResolutionList = new LinkedList<YangResolutionInfo>(); 209 + derivedTypeResolutionList = new LinkedList<YangResolutionInfo>();
210 + usesResolutionList = new LinkedList<YangResolutionInfo>();
201 importList = new LinkedList<YangImport>(); 211 importList = new LinkedList<YangImport>();
202 includeList = new LinkedList<YangInclude>(); 212 includeList = new LinkedList<YangInclude>();
203 listOfLeaf = new LinkedList<YangLeaf>(); 213 listOfLeaf = new LinkedList<YangLeaf>();
...@@ -341,17 +351,19 @@ public class YangSubModule extends YangNode ...@@ -341,17 +351,19 @@ public class YangSubModule extends YangNode
341 } 351 }
342 352
343 @Override 353 @Override
344 - public void resolveSelfFileLinking() throws DataModelException { 354 + public void resolveSelfFileLinking(ResolvableType type)
355 + throws DataModelException {
345 // Get the list to be resolved. 356 // Get the list to be resolved.
346 - List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(); 357 + List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
347 // Resolve linking for a resolution list. 358 // Resolve linking for a resolution list.
348 resolveLinkingForResolutionList(resolutionList, this); 359 resolveLinkingForResolutionList(resolutionList, this);
349 } 360 }
350 361
351 @Override 362 @Override
352 - public void resolveInterFileLinking() throws DataModelException { 363 + public void resolveInterFileLinking(ResolvableType type)
364 + throws DataModelException {
353 // Get the list to be resolved. 365 // Get the list to be resolved.
354 - List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(); 366 + List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type);
355 // Resolve linking for a resolution list. 367 // Resolve linking for a resolution list.
356 linkInterFileReferences(resolutionList, this); 368 linkInterFileReferences(resolutionList, this);
357 } 369 }
...@@ -366,6 +378,11 @@ public class YangSubModule extends YangNode ...@@ -366,6 +378,11 @@ public class YangSubModule extends YangNode
366 return listOfLeaf; 378 return listOfLeaf;
367 } 379 }
368 380
381 + @Override
382 + public void setListOfLeaf(List<YangLeaf> leafsList) {
383 + listOfLeaf = leafsList;
384 + }
385 +
369 /** 386 /**
370 * Adds a leaf. 387 * Adds a leaf.
371 * 388 *
...@@ -386,6 +403,11 @@ public class YangSubModule extends YangNode ...@@ -386,6 +403,11 @@ public class YangSubModule extends YangNode
386 return listOfLeafList; 403 return listOfLeafList;
387 } 404 }
388 405
406 + @Override
407 + public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
408 + this.listOfLeafList = listOfLeafList;
409 + }
410 +
389 /** 411 /**
390 * Adds a leaf-list. 412 * Adds a leaf-list.
391 * 413 *
...@@ -486,7 +508,8 @@ public class YangSubModule extends YangNode ...@@ -486,7 +508,8 @@ public class YangSubModule extends YangNode
486 * @throws DataModelException a violation of data model rules 508 * @throws DataModelException a violation of data model rules
487 */ 509 */
488 @Override 510 @Override
489 - public void validateDataOnEntry() throws DataModelException { 511 + public void validateDataOnEntry()
512 + throws DataModelException {
490 // TODO auto-generated method stub, to be implemented by parser 513 // TODO auto-generated method stub, to be implemented by parser
491 } 514 }
492 515
...@@ -496,34 +519,52 @@ public class YangSubModule extends YangNode ...@@ -496,34 +519,52 @@ public class YangSubModule extends YangNode
496 * @throws DataModelException a violation of data model rules 519 * @throws DataModelException a violation of data model rules
497 */ 520 */
498 @Override 521 @Override
499 - public void validateDataOnExit() throws DataModelException { 522 + public void validateDataOnExit()
523 + throws DataModelException {
500 // TODO auto-generated method stub, to be implemented by parser 524 // TODO auto-generated method stub, to be implemented by parser
501 } 525 }
502 526
503 @Override 527 @Override
504 - public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { 528 + public void detectCollidingChild(String identifierName, YangConstructType dataType)
529 + throws DataModelException {
505 // Asks helper to detect colliding child. 530 // Asks helper to detect colliding child.
506 detectCollidingChildUtil(identifierName, dataType, this); 531 detectCollidingChildUtil(identifierName, dataType, this);
507 } 532 }
508 533
509 @Override 534 @Override
510 - public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { 535 + public void detectSelfCollision(String identifierName, YangConstructType dataType)
536 + throws DataModelException {
511 // Not required as module doesn't have any parent. 537 // Not required as module doesn't have any parent.
512 } 538 }
513 539
514 @Override 540 @Override
515 - public List<YangResolutionInfo> getUnresolvedResolutionList() { 541 + public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) {
516 - return unresolvedResolutionList; 542 + if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
543 + return derivedTypeResolutionList;
544 + } else {
545 + return usesResolutionList;
546 + }
517 } 547 }
518 548
519 @Override 549 @Override
520 - public void addToResolutionList(YangResolutionInfo resolutionInfo) { 550 + public void addToResolutionList(YangResolutionInfo resolutionInfo,
521 - this.unresolvedResolutionList.add(resolutionInfo); 551 + ResolvableType type) {
552 + if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
553 + derivedTypeResolutionList.add(resolutionInfo);
554 + } else if (type == ResolvableType.YANG_USES) {
555 + usesResolutionList.add(resolutionInfo);
556 + }
522 } 557 }
523 558
524 @Override 559 @Override
525 - public void setResolutionList(List<YangResolutionInfo> resolutionList) { 560 + public void setResolutionList(List<YangResolutionInfo> resolutionList,
526 - this.unresolvedResolutionList = resolutionList; 561 + ResolvableType type) {
562 + if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) {
563 + derivedTypeResolutionList = resolutionList;
564 + } else if (type == ResolvableType.YANG_USES) {
565 + usesResolutionList = resolutionList;
566 + }
567 +
527 } 568 }
528 569
529 /** 570 /**
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
17 package org.onosproject.yangutils.datamodel; 17 package org.onosproject.yangutils.datamodel;
18 18
19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20 +import org.onosproject.yangutils.linker.Resolvable;
21 +import org.onosproject.yangutils.linker.ResolvableStatus;
20 import org.onosproject.yangutils.linker.exceptions.LinkerException; 22 import org.onosproject.yangutils.linker.exceptions.LinkerException;
21 -import org.onosproject.yangutils.linker.impl.Resolvable;
22 -import org.onosproject.yangutils.linker.impl.ResolvableStatus;
23 import org.onosproject.yangutils.parser.Parsable; 23 import org.onosproject.yangutils.parser.Parsable;
24 import org.onosproject.yangutils.utils.YangConstructType; 24 import org.onosproject.yangutils.utils.YangConstructType;
25 25
...@@ -247,7 +247,8 @@ public class YangType<T> ...@@ -247,7 +247,8 @@ public class YangType<T>
247 } 247 }
248 248
249 @Override 249 @Override
250 - public void resolve() throws LinkerException { 250 + public void resolve()
251 + throws LinkerException {
251 /* 252 /*
252 * Check whether the data type is derived. 253 * Check whether the data type is derived.
253 */ 254 */
......
...@@ -18,15 +18,18 @@ package org.onosproject.yangutils.datamodel.utils; ...@@ -18,15 +18,18 @@ package org.onosproject.yangutils.datamodel.utils;
18 18
19 import java.util.List; 19 import java.util.List;
20 import java.util.Set; 20 import java.util.Set;
21 +
21 import org.onosproject.yangutils.datamodel.CollisionDetector; 22 import org.onosproject.yangutils.datamodel.CollisionDetector;
22 import org.onosproject.yangutils.datamodel.YangLeaf; 23 import org.onosproject.yangutils.datamodel.YangLeaf;
23 import org.onosproject.yangutils.datamodel.YangLeafList; 24 import org.onosproject.yangutils.datamodel.YangLeafList;
24 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 25 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
25 import org.onosproject.yangutils.datamodel.YangNode; 26 import org.onosproject.yangutils.datamodel.YangNode;
26 -import org.onosproject.yangutils.linker.impl.YangReferenceResolver;
27 -import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
28 import org.onosproject.yangutils.datamodel.YangRpc; 27 import org.onosproject.yangutils.datamodel.YangRpc;
28 +import org.onosproject.yangutils.datamodel.YangType;
29 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 29 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
30 +import org.onosproject.yangutils.linker.ResolvableType;
31 +import org.onosproject.yangutils.linker.YangReferenceResolver;
32 +import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
30 import org.onosproject.yangutils.parser.Parsable; 33 import org.onosproject.yangutils.parser.Parsable;
31 import org.onosproject.yangutils.plugin.manager.YangFileInfo; 34 import org.onosproject.yangutils.plugin.manager.YangFileInfo;
32 import org.onosproject.yangutils.utils.YangConstructType; 35 import org.onosproject.yangutils.utils.YangConstructType;
...@@ -45,8 +48,7 @@ public final class DataModelUtils { ...@@ -45,8 +48,7 @@ public final class DataModelUtils {
45 /** 48 /**
46 * Detects the colliding identifier name in a given YANG node and its child. 49 * Detects the colliding identifier name in a given YANG node and its child.
47 * 50 *
48 - * @param identifierName name for which collision detection is to be 51 + * @param identifierName name for which collision detection is to be checked
49 - * checked
50 * @param dataType type of YANG node asking for detecting collision 52 * @param dataType type of YANG node asking for detecting collision
51 * @param node instance of calling node 53 * @param node instance of calling node
52 * @throws DataModelException a violation of data model rules 54 * @throws DataModelException a violation of data model rules
...@@ -77,8 +79,7 @@ public final class DataModelUtils { ...@@ -77,8 +79,7 @@ public final class DataModelUtils {
77 /** 79 /**
78 * Detects colliding of uses and grouping only with uses and grouping respectively. 80 * Detects colliding of uses and grouping only with uses and grouping respectively.
79 * 81 *
80 - * @param identifierName name for which collision detection is to be 82 + * @param identifierName name for which collision detection is to be checked
81 - * checked
82 * @param dataType type of YANG node asking for detecting collision 83 * @param dataType type of YANG node asking for detecting collision
83 * @param node node instance of calling node 84 * @param node node instance of calling node
84 * @throws DataModelException a violation of data model rules 85 * @throws DataModelException a violation of data model rules
...@@ -101,8 +102,7 @@ public final class DataModelUtils { ...@@ -101,8 +102,7 @@ public final class DataModelUtils {
101 * Detects the colliding identifier name in a given leaf node. 102 * Detects the colliding identifier name in a given leaf node.
102 * 103 *
103 * @param listOfLeaf List of leaves to detect collision 104 * @param listOfLeaf List of leaves to detect collision
104 - * @param identifierName name for which collision detection is to be 105 + * @param identifierName name for which collision detection is to be checked
105 - * checked
106 * @throws DataModelException a violation of data model rules 106 * @throws DataModelException a violation of data model rules
107 */ 107 */
108 private static void detectCollidingLeaf(List<YangLeaf> listOfLeaf, String identifierName) 108 private static void detectCollidingLeaf(List<YangLeaf> listOfLeaf, String identifierName)
...@@ -123,8 +123,7 @@ public final class DataModelUtils { ...@@ -123,8 +123,7 @@ public final class DataModelUtils {
123 * Detects the colliding identifier name in a given leaf-list node. 123 * Detects the colliding identifier name in a given leaf-list node.
124 * 124 *
125 * @param listOfLeafList list of leaf-lists to detect collision 125 * @param listOfLeafList list of leaf-lists to detect collision
126 - * @param identifierName name for which collision detection is to be 126 + * @param identifierName name for which collision detection is to be checked
127 - * checked
128 * @throws DataModelException a violation of data model rules 127 * @throws DataModelException a violation of data model rules
129 */ 128 */
130 private static void detectCollidingLeafList(List<YangLeafList> listOfLeafList, String identifierName) 129 private static void detectCollidingLeafList(List<YangLeafList> listOfLeafList, String identifierName)
...@@ -144,8 +143,7 @@ public final class DataModelUtils { ...@@ -144,8 +143,7 @@ public final class DataModelUtils {
144 /** 143 /**
145 * Add a resolution information. 144 * Add a resolution information.
146 * 145 *
147 - * @param resolutionInfo information about the YANG construct which has to 146 + * @param resolutionInfo information about the YANG construct which has to be resolved
148 - * be resolved
149 * @throws DataModelException a violation of data model rules 147 * @throws DataModelException a violation of data model rules
150 */ 148 */
151 public static void addResolutionInfo(YangResolutionInfo resolutionInfo) 149 public static void addResolutionInfo(YangResolutionInfo resolutionInfo)
...@@ -162,7 +160,15 @@ public final class DataModelUtils { ...@@ -162,7 +160,15 @@ public final class DataModelUtils {
162 } 160 }
163 YangReferenceResolver resolutionNode = (YangReferenceResolver) curNode; 161 YangReferenceResolver resolutionNode = (YangReferenceResolver) curNode;
164 162
165 - resolutionNode.addToResolutionList(resolutionInfo); 163 + if (resolutionInfo.getEntityToResolveInfo()
164 + .getEntityToResolve() instanceof YangType) {
165 + resolutionNode.addToResolutionList(resolutionInfo,
166 + ResolvableType.YANG_DERIVED_DATA_TYPE);
167 + } else {
168 + resolutionNode.addToResolutionList(resolutionInfo,
169 + ResolvableType.YANG_USES);
170 + }
171 +
166 } 172 }
167 173
168 /** 174 /**
...@@ -173,7 +179,7 @@ public final class DataModelUtils { ...@@ -173,7 +179,7 @@ public final class DataModelUtils {
173 * @throws DataModelException a violation of data model rules 179 * @throws DataModelException a violation of data model rules
174 */ 180 */
175 public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList, 181 public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList,
176 - YangReferenceResolver dataModelRootNode) 182 + YangReferenceResolver dataModelRootNode)
177 throws DataModelException { 183 throws DataModelException {
178 184
179 for (YangResolutionInfo resolutionInfo : resolutionList) { 185 for (YangResolutionInfo resolutionInfo : resolutionList) {
...@@ -189,7 +195,7 @@ public final class DataModelUtils { ...@@ -189,7 +195,7 @@ public final class DataModelUtils {
189 * @throws DataModelException a violation of data model rules 195 * @throws DataModelException a violation of data model rules
190 */ 196 */
191 public static void linkInterFileReferences(List<YangResolutionInfo> resolutionList, 197 public static void linkInterFileReferences(List<YangResolutionInfo> resolutionList,
192 - YangReferenceResolver dataModelRootNode) 198 + YangReferenceResolver dataModelRootNode)
193 throws DataModelException { 199 throws DataModelException {
194 /* 200 /*
195 * Run through the resolution list, find type/uses referring to 201 * Run through the resolution list, find type/uses referring to
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.linker.impl; 17 +package org.onosproject.yangutils.linker;
18 18
19 import org.onosproject.yangutils.linker.exceptions.LinkerException; 19 import org.onosproject.yangutils.linker.exceptions.LinkerException;
20 20
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.linker.impl; 17 +package org.onosproject.yangutils.linker;
18 18
19 /** 19 /**
20 * Represents the status of resolvable entity. 20 * Represents the status of resolvable entity.
......
1 +/*
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 +
17 +package org.onosproject.yangutils.linker;
18 +
19 +/**
20 + * Type of the resolvable info.
21 + */
22 +public enum ResolvableType {
23 +
24 + /**
25 + * Identifies the derived data type.
26 + */
27 + YANG_DERIVED_DATA_TYPE,
28 +
29 + /**
30 + * Identifies the uses.
31 + */
32 + YANG_USES
33 +}
1 +/*
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 +
17 +package org.onosproject.yangutils.linker;
18 +
19 +/**
20 + * Represents the phase of YANG file reference linking.
21 + */
22 +public enum YangLinkingPhase {
23 +
24 + /**
25 + * Linking the reference within the files.
26 + */
27 + INTRA_FILE,
28 +
29 + /**
30 + * Linking the reference across the files.
31 + */
32 + INTER_FILE
33 +
34 +}
...@@ -14,14 +14,16 @@ ...@@ -14,14 +14,16 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.yangutils.linker.impl; 17 +package org.onosproject.yangutils.linker;
18 18
19 import java.util.List; 19 import java.util.List;
20 import java.util.Set; 20 import java.util.Set;
21 +
21 import org.onosproject.yangutils.datamodel.YangImport; 22 import org.onosproject.yangutils.datamodel.YangImport;
22 import org.onosproject.yangutils.datamodel.YangInclude; 23 import org.onosproject.yangutils.datamodel.YangInclude;
23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 24 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
24 import org.onosproject.yangutils.linker.exceptions.LinkerException; 25 import org.onosproject.yangutils.linker.exceptions.LinkerException;
26 +import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
25 import org.onosproject.yangutils.plugin.manager.YangFileInfo; 27 import org.onosproject.yangutils.plugin.manager.YangFileInfo;
26 28
27 /** 29 /**
...@@ -33,23 +35,26 @@ public interface YangReferenceResolver { ...@@ -33,23 +35,26 @@ public interface YangReferenceResolver {
33 /** 35 /**
34 * Returns unresolved resolution list. 36 * Returns unresolved resolution list.
35 * 37 *
36 - * @return unresolved resolution list 38 + * @param type resolvable type
39 + * @return list of resolution information objects
37 */ 40 */
38 - List<YangResolutionInfo> getUnresolvedResolutionList(); 41 + List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type);
39 42
40 /** 43 /**
41 * Adds to the resolution list. 44 * Adds to the resolution list.
42 * 45 *
43 * @param resolutionInfo resolution information 46 * @param resolutionInfo resolution information
47 + * @param type resolvable type
44 */ 48 */
45 - void addToResolutionList(YangResolutionInfo resolutionInfo); 49 + void addToResolutionList(YangResolutionInfo resolutionInfo, ResolvableType type);
46 50
47 /** 51 /**
48 * Creates resolution list. 52 * Creates resolution list.
49 * 53 *
50 * @param resolutionList resolution list 54 * @param resolutionList resolution list
55 + * @param type resolvable type
51 */ 56 */
52 - void setResolutionList(List<YangResolutionInfo> resolutionList); 57 + void setResolutionList(List<YangResolutionInfo> resolutionList, ResolvableType type);
53 58
54 /** 59 /**
55 * Returns unresolved imported list. 60 * Returns unresolved imported list.
...@@ -110,16 +115,20 @@ public interface YangReferenceResolver { ...@@ -110,16 +115,20 @@ public interface YangReferenceResolver {
110 /** 115 /**
111 * Resolves self file linking. 116 * Resolves self file linking.
112 * 117 *
118 + * @param type resolvable type
113 * @throws DataModelException a violation in data model rule 119 * @throws DataModelException a violation in data model rule
114 */ 120 */
115 - void resolveSelfFileLinking() throws DataModelException; 121 + void resolveSelfFileLinking(ResolvableType type)
122 + throws DataModelException;
116 123
117 /** 124 /**
118 * Resolves inter file linking. 125 * Resolves inter file linking.
119 * 126 *
127 + * @param type resolvable type
120 * @throws DataModelException a violation in data model rule 128 * @throws DataModelException a violation in data model rule
121 */ 129 */
122 - void resolveInterFileLinking() throws DataModelException; 130 + void resolveInterFileLinking(ResolvableType type)
131 + throws DataModelException;
123 132
124 /** 133 /**
125 * Adds references to include. 134 * Adds references to include.
...@@ -127,7 +136,8 @@ public interface YangReferenceResolver { ...@@ -127,7 +136,8 @@ public interface YangReferenceResolver {
127 * @param yangFileInfoSet YANG file info set 136 * @param yangFileInfoSet YANG file info set
128 * @throws LinkerException a violation of linker rules 137 * @throws LinkerException a violation of linker rules
129 */ 138 */
130 - void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet) throws LinkerException; 139 + void addReferencesToIncludeList(Set<YangFileInfo> yangFileInfoSet)
140 + throws LinkerException;
131 141
132 /** 142 /**
133 * Adds references to import. 143 * Adds references to import.
...@@ -135,5 +145,6 @@ public interface YangReferenceResolver { ...@@ -135,5 +145,6 @@ public interface YangReferenceResolver {
135 * @param yangFileInfoSet YANG file info set 145 * @param yangFileInfoSet YANG file info set
136 * @throws LinkerException a violation of linker rules 146 * @throws LinkerException a violation of linker rules
137 */ 147 */
138 - void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet) throws LinkerException; 148 + void addReferencesToImportList(Set<YangFileInfo> yangFileInfoSet)
149 + throws LinkerException;
139 } 150 }
......
...@@ -17,10 +17,13 @@ ...@@ -17,10 +17,13 @@
17 package org.onosproject.yangutils.linker.impl; 17 package org.onosproject.yangutils.linker.impl;
18 18
19 import java.util.Set; 19 import java.util.Set;
20 +
20 import org.onosproject.yangutils.datamodel.YangNode; 21 import org.onosproject.yangutils.datamodel.YangNode;
21 import org.onosproject.yangutils.datamodel.YangSubModule; 22 import org.onosproject.yangutils.datamodel.YangSubModule;
22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
24 +import org.onosproject.yangutils.linker.ResolvableType;
23 import org.onosproject.yangutils.linker.YangLinker; 25 import org.onosproject.yangutils.linker.YangLinker;
26 +import org.onosproject.yangutils.linker.YangReferenceResolver;
24 import org.onosproject.yangutils.linker.exceptions.LinkerException; 27 import org.onosproject.yangutils.linker.exceptions.LinkerException;
25 import org.onosproject.yangutils.plugin.manager.YangFileInfo; 28 import org.onosproject.yangutils.plugin.manager.YangFileInfo;
26 29
...@@ -29,7 +32,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; ...@@ -29,7 +32,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
29 /** 32 /**
30 * Representation of entity which provides linking service of YANG files. 33 * Representation of entity which provides linking service of YANG files.
31 */ 34 */
32 -public class YangLinkerManager implements YangLinker { 35 +public class YangLinkerManager
36 + implements YangLinker {
33 @Override 37 @Override
34 public void resolveDependencies(Set<YangFileInfo> yangFileInfoSet) { 38 public void resolveDependencies(Set<YangFileInfo> yangFileInfoSet) {
35 39
...@@ -54,7 +58,8 @@ public class YangLinkerManager implements YangLinker { ...@@ -54,7 +58,8 @@ public class YangLinkerManager implements YangLinker {
54 * @param yangFileInfoSet set of YANG files info 58 * @param yangFileInfoSet set of YANG files info
55 * @throws LinkerException fails to link sub-module to parent module 59 * @throws LinkerException fails to link sub-module to parent module
56 */ 60 */
57 - public void linkSubModulesToParentModule(Set<YangFileInfo> yangFileInfoSet) throws LinkerException { 61 + public void linkSubModulesToParentModule(Set<YangFileInfo> yangFileInfoSet)
62 + throws LinkerException {
58 for (YangFileInfo yangFileInfo : yangFileInfoSet) { 63 for (YangFileInfo yangFileInfo : yangFileInfoSet) {
59 YangNode yangNode = yangFileInfo.getRootNode(); 64 YangNode yangNode = yangFileInfo.getRootNode();
60 if (yangNode instanceof YangSubModule) { 65 if (yangNode instanceof YangSubModule) {
...@@ -106,10 +111,13 @@ public class YangLinkerManager implements YangLinker { ...@@ -106,10 +111,13 @@ public class YangLinkerManager implements YangLinker {
106 * @param yangFileInfoSet set of YANG files info 111 * @param yangFileInfoSet set of YANG files info
107 * @throws LinkerException a violation in linker execution 112 * @throws LinkerException a violation in linker execution
108 */ 113 */
109 - public void processInterFileLinking(Set<YangFileInfo> yangFileInfoSet) throws LinkerException { 114 + public void processInterFileLinking(Set<YangFileInfo> yangFileInfoSet)
115 + throws LinkerException {
110 for (YangFileInfo yangFileInfo : yangFileInfoSet) { 116 for (YangFileInfo yangFileInfo : yangFileInfoSet) {
111 try { 117 try {
112 - ((YangReferenceResolver) yangFileInfo.getRootNode()).resolveInterFileLinking(); 118 + ((YangReferenceResolver) yangFileInfo.getRootNode()).resolveInterFileLinking(ResolvableType.YANG_USES);
119 + ((YangReferenceResolver) yangFileInfo.getRootNode())
120 + .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
113 } catch (DataModelException e) { 121 } catch (DataModelException e) {
114 String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: " 122 String errorInfo = "Error in file: " + yangFileInfo.getYangFileName() + " at line: "
115 + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE + e.getMessage(); 123 + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE + e.getMessage();
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 package org.onosproject.yangutils.linker.impl; 17 package org.onosproject.yangutils.linker.impl;
18 18
19 import java.util.Stack; 19 import java.util.Stack;
20 +
20 import org.onosproject.yangutils.datamodel.LocationInfo; 21 import org.onosproject.yangutils.datamodel.LocationInfo;
21 import org.onosproject.yangutils.datamodel.YangDataTypes; 22 import org.onosproject.yangutils.datamodel.YangDataTypes;
22 import org.onosproject.yangutils.datamodel.YangDerivedInfo; 23 import org.onosproject.yangutils.datamodel.YangDerivedInfo;
...@@ -28,12 +29,18 @@ import org.onosproject.yangutils.datamodel.YangType; ...@@ -28,12 +29,18 @@ import org.onosproject.yangutils.datamodel.YangType;
28 import org.onosproject.yangutils.datamodel.YangTypeDef; 29 import org.onosproject.yangutils.datamodel.YangTypeDef;
29 import org.onosproject.yangutils.datamodel.YangUses; 30 import org.onosproject.yangutils.datamodel.YangUses;
30 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 31 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
31 - 32 +import org.onosproject.yangutils.linker.Resolvable;
32 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.INTER_FILE_LINKED; 33 +import org.onosproject.yangutils.linker.ResolvableStatus;
33 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.INTRA_FILE_RESOLVED; 34 +import org.onosproject.yangutils.linker.YangLinkingPhase;
34 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.LINKED; 35 +import org.onosproject.yangutils.linker.YangReferenceResolver;
35 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.RESOLVED; 36 +
36 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.UNRESOLVED; 37 +import static org.onosproject.yangutils.linker.ResolvableStatus.INTER_FILE_LINKED;
38 +import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED;
39 +import static org.onosproject.yangutils.linker.ResolvableStatus.LINKED;
40 +import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
41 +import static org.onosproject.yangutils.linker.ResolvableStatus.UNRESOLVED;
42 +import static org.onosproject.yangutils.linker.YangLinkingPhase.INTER_FILE;
43 +import static org.onosproject.yangutils.linker.YangLinkingPhase.INTRA_FILE;
37 import static org.onosproject.yangutils.utils.UtilConstants.TYPEDEF_LINKER_ERROR; 44 import static org.onosproject.yangutils.utils.UtilConstants.TYPEDEF_LINKER_ERROR;
38 import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERROR; 45 import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERROR;
39 46
...@@ -42,7 +49,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERRO ...@@ -42,7 +49,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERRO
42 * 49 *
43 * @param <T> type of resolution entity uses / type 50 * @param <T> type of resolution entity uses / type
44 */ 51 */
45 -public class YangResolutionInfo<T> implements LocationInfo { 52 +public class YangResolutionInfo<T>
53 + implements LocationInfo {
46 54
47 /** 55 /**
48 * Information about the entity that needs to be resolved. 56 * Information about the entity that needs to be resolved.
...@@ -164,7 +172,7 @@ public class YangResolutionInfo<T> implements LocationInfo { ...@@ -164,7 +172,7 @@ public class YangResolutionInfo<T> implements LocationInfo {
164 * resolve the references and pop the entity and 172 * resolve the references and pop the entity and
165 * continue with remaining stack elements to resolve. 173 * continue with remaining stack elements to resolve.
166 */ 174 */
167 - resolveTopOfStack(); 175 + resolveTopOfStack(INTRA_FILE);
168 getPartialResolvedStack().pop(); 176 getPartialResolvedStack().pop();
169 break; 177 break;
170 } 178 }
...@@ -213,7 +221,7 @@ public class YangResolutionInfo<T> implements LocationInfo { ...@@ -213,7 +221,7 @@ public class YangResolutionInfo<T> implements LocationInfo {
213 /** 221 /**
214 * Resolves the current entity in the stack. 222 * Resolves the current entity in the stack.
215 */ 223 */
216 - private void resolveTopOfStack() 224 + private void resolveTopOfStack(YangLinkingPhase linkingPhase)
217 throws DataModelException { 225 throws DataModelException {
218 ((Resolvable) getCurrentEntityToResolveFromStack()).resolve(); 226 ((Resolvable) getCurrentEntityToResolveFromStack()).resolve();
219 if (((Resolvable) getCurrentEntityToResolveFromStack()).getResolvableStatus() 227 if (((Resolvable) getCurrentEntityToResolveFromStack()).getResolvableStatus()
...@@ -280,7 +288,8 @@ public class YangResolutionInfo<T> implements LocationInfo { ...@@ -280,7 +288,8 @@ public class YangResolutionInfo<T> implements LocationInfo {
280 * @return true if self file reference, false otherwise 288 * @return true if self file reference, false otherwise
281 * @throws DataModelException a violation of data model rules 289 * @throws DataModelException a violation of data model rules
282 */ 290 */
283 - private boolean isCandidateForSelfFileReference() throws DataModelException { 291 + private boolean isCandidateForSelfFileReference()
292 + throws DataModelException {
284 String prefix = getRefPrefix(); 293 String prefix = getRefPrefix();
285 return prefix == null || prefix.contentEquals(getCurReferenceResolver().getPrefix()); 294 return prefix == null || prefix.contentEquals(getCurReferenceResolver().getPrefix());
286 } 295 }
...@@ -598,7 +607,8 @@ public class YangResolutionInfo<T> implements LocationInfo { ...@@ -598,7 +607,8 @@ public class YangResolutionInfo<T> implements LocationInfo {
598 * @return referenced prefix of entity under resolution 607 * @return referenced prefix of entity under resolution
599 * @throws DataModelException a violation in data model rule 608 * @throws DataModelException a violation in data model rule
600 */ 609 */
601 - private String getRefPrefix() throws DataModelException { 610 + private String getRefPrefix()
611 + throws DataModelException {
602 String refPrefix; 612 String refPrefix;
603 if (getCurrentEntityToResolveFromStack() instanceof YangType) { 613 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
604 refPrefix = ((YangType<?>) getCurrentEntityToResolveFromStack()).getPrefix(); 614 refPrefix = ((YangType<?>) getCurrentEntityToResolveFromStack()).getPrefix();
...@@ -643,7 +653,7 @@ public class YangResolutionInfo<T> implements LocationInfo { ...@@ -643,7 +653,7 @@ public class YangResolutionInfo<T> implements LocationInfo {
643 * resolve the references and pop the entity and 653 * resolve the references and pop the entity and
644 * continue with remaining stack elements to resolve 654 * continue with remaining stack elements to resolve
645 */ 655 */
646 - resolveTopOfStack(); 656 + resolveTopOfStack(INTER_FILE);
647 getPartialResolvedStack().pop(); 657 getPartialResolvedStack().pop();
648 break; 658 break;
649 } 659 }
...@@ -679,7 +689,8 @@ public class YangResolutionInfo<T> implements LocationInfo { ...@@ -679,7 +689,8 @@ public class YangResolutionInfo<T> implements LocationInfo {
679 * 689 *
680 * @throws DataModelException data model error 690 * @throws DataModelException data model error
681 */ 691 */
682 - private void linkInterFileTopOfStackRefUpdateStack() throws DataModelException { 692 + private void linkInterFileTopOfStackRefUpdateStack()
693 + throws DataModelException {
683 694
684 /* 695 /*
685 * Obtain the referred node of top of stack entity under resolution 696 * Obtain the referred node of top of stack entity under resolution
...@@ -727,7 +738,8 @@ public class YangResolutionInfo<T> implements LocationInfo { ...@@ -727,7 +738,8 @@ public class YangResolutionInfo<T> implements LocationInfo {
727 * @return true if resolved, false otherwise 738 * @return true if resolved, false otherwise
728 * @throws DataModelException a violation in data model rule 739 * @throws DataModelException a violation in data model rule
729 */ 740 */
730 - private boolean resolveWithInclude() throws DataModelException { 741 + private boolean resolveWithInclude()
742 + throws DataModelException {
731 /* 743 /*
732 * Run through all the nodes in include list and search for referred 744 * Run through all the nodes in include list and search for referred
733 * typedef/grouping at the root level. 745 * typedef/grouping at the root level.
...@@ -762,7 +774,8 @@ public class YangResolutionInfo<T> implements LocationInfo { ...@@ -762,7 +774,8 @@ public class YangResolutionInfo<T> implements LocationInfo {
762 * @return true if resolved, false otherwise 774 * @return true if resolved, false otherwise
763 * @throws DataModelException a violation in data model rule 775 * @throws DataModelException a violation in data model rule
764 */ 776 */
765 - private boolean resolveWithImport() throws DataModelException { 777 + private boolean resolveWithImport()
778 + throws DataModelException {
766 /* 779 /*
767 * Run through import list to find the referred typedef/grouping. 780 * Run through import list to find the referred typedef/grouping.
768 */ 781 */
...@@ -808,7 +821,8 @@ public class YangResolutionInfo<T> implements LocationInfo { ...@@ -808,7 +821,8 @@ public class YangResolutionInfo<T> implements LocationInfo {
808 * @return referred typedef/grouping node 821 * @return referred typedef/grouping node
809 * @throws DataModelException a violation in data model rule 822 * @throws DataModelException a violation in data model rule
810 */ 823 */
811 - private T getRefNode() throws DataModelException { 824 + private T getRefNode()
825 + throws DataModelException {
812 if (getCurrentEntityToResolveFromStack() instanceof YangType) { 826 if (getCurrentEntityToResolveFromStack() instanceof YangType) {
813 YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) 827 YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>)
814 ((YangType<?>) getCurrentEntityToResolveFromStack()).getDataTypeExtendedInfo(); 828 ((YangType<?>) getCurrentEntityToResolveFromStack()).getDataTypeExtendedInfo();
......
...@@ -39,8 +39,10 @@ import static org.onosproject.yangutils.parser.impl.parserutils.AugmentListenerU ...@@ -39,8 +39,10 @@ import static org.onosproject.yangutils.parser.impl.parserutils.AugmentListenerU
39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil; 39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
40 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 40 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
41 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; 41 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
42 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; 42 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
43 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 43 + .constructExtendedListenerErrorMessage;
44 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
45 + .constructListenerErrorMessage;
44 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 46 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
45 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; 47 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
46 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 48 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
...@@ -98,7 +100,7 @@ public final class AugmentListener { ...@@ -98,7 +100,7 @@ public final class AugmentListener {
98 * @param ctx context object of the grammar rule 100 * @param ctx context object of the grammar rule
99 */ 101 */
100 public static void processAugmentEntry(TreeWalkListener listener, 102 public static void processAugmentEntry(TreeWalkListener listener,
101 - GeneratedYangParser.AugmentStatementContext ctx) { 103 + GeneratedYangParser.AugmentStatementContext ctx) {
102 104
103 // Check for stack to be non empty. 105 // Check for stack to be non empty.
104 checkStackIsNotEmpty(listener, MISSING_HOLDER, AUGMENT_DATA, ctx.augment().getText(), ENTRY); 106 checkStackIsNotEmpty(listener, MISSING_HOLDER, AUGMENT_DATA, ctx.augment().getText(), ENTRY);
...@@ -120,7 +122,8 @@ public final class AugmentListener { ...@@ -120,7 +122,8 @@ public final class AugmentListener {
120 YangNode curNode = (YangNode) curData; 122 YangNode curNode = (YangNode) curData;
121 YangAugment yangAugment = getYangAugmentNode(JAVA_GENERATION); 123 YangAugment yangAugment = getYangAugmentNode(JAVA_GENERATION);
122 124
123 - validateTargetNodePath(targetNodes, curNode, ctx); 125 + //validateTargetNodePath(targetNodes, curNode, ctx);
126 + // TODO: handle in linker.
124 127
125 yangAugment.setTargetNode(targetNodes); 128 yangAugment.setTargetNode(targetNodes);
126 yangAugment.setName(generateNameForAugmentNode(curData, targetNodes, listener)); 129 yangAugment.setName(generateNameForAugmentNode(curData, targetNodes, listener));
...@@ -147,7 +150,7 @@ public final class AugmentListener { ...@@ -147,7 +150,7 @@ public final class AugmentListener {
147 * @param ctx context object of the grammar rule 150 * @param ctx context object of the grammar rule
148 */ 151 */
149 public static void processAugmentExit(TreeWalkListener listener, 152 public static void processAugmentExit(TreeWalkListener listener,
150 - GeneratedYangParser.AugmentStatementContext ctx) { 153 + GeneratedYangParser.AugmentStatementContext ctx) {
151 154
152 //Check for stack to be non empty. 155 //Check for stack to be non empty.
153 checkStackIsNotEmpty(listener, MISSING_HOLDER, AUGMENT_DATA, ctx.augment().getText(), EXIT); 156 checkStackIsNotEmpty(listener, MISSING_HOLDER, AUGMENT_DATA, ctx.augment().getText(), EXIT);
...@@ -170,15 +173,15 @@ public final class AugmentListener { ...@@ -170,15 +173,15 @@ public final class AugmentListener {
170 validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, AUGMENT_DATA, ctx.augment().getText()); 173 validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, AUGMENT_DATA, ctx.augment().getText());
171 validateCardinalityMaxOne(ctx.whenStatement(), WHEN_DATA, AUGMENT_DATA, ctx.augment().getText()); 174 validateCardinalityMaxOne(ctx.whenStatement(), WHEN_DATA, AUGMENT_DATA, ctx.augment().getText());
172 validateMutuallyExclusiveChilds(ctx.dataDefStatement(), DATA_DEF_DATA, ctx.caseStatement(), 175 validateMutuallyExclusiveChilds(ctx.dataDefStatement(), DATA_DEF_DATA, ctx.caseStatement(),
173 - CASE_DATA, AUGMENT_DATA, ctx.augment().getText()); 176 + CASE_DATA, AUGMENT_DATA, ctx.augment().getText());
174 } 177 }
175 178
176 /** 179 /**
177 * Validates whether the current target node path is correct or not. 180 * Validates whether the current target node path is correct or not.
178 * 181 *
179 * @param targetNodes list of target nodes 182 * @param targetNodes list of target nodes
180 - * @param line line in YANG file 183 + * @param curNode current Node
181 - * @param charPositionInLine char position in YANG file 184 + * @param ctx augment context
182 * @param curNode current YANG node 185 * @param curNode current YANG node
183 */ 186 */
184 private static void validateTargetNodePath(List<YangNodeIdentifier> targetNodes, YangNode curNode, 187 private static void validateTargetNodePath(List<YangNodeIdentifier> targetNodes, YangNode curNode,
...@@ -189,7 +192,8 @@ public final class AugmentListener { ...@@ -189,7 +192,8 @@ public final class AugmentListener {
189 if (!moduleId.getName().equals(curNode.getName())) { 192 if (!moduleId.getName().equals(curNode.getName())) {
190 throw parserException(ctx); 193 throw parserException(ctx);
191 } else { 194 } else {
192 - validateNodeInTargetPath(curNode, targetNodes, ctx); 195 + //validateNodeInTargetPath(curNode, targetNodes, ctx);
196 + // TODO: handle in linker.
193 } 197 }
194 } else { 198 } else {
195 String parentPrefix = getParentsPrefix(curNode); 199 String parentPrefix = getParentsPrefix(curNode);
......
...@@ -113,11 +113,12 @@ public final class LeafListListener { ...@@ -113,11 +113,12 @@ public final class LeafListListener {
113 leafList.setLeafName(identifier); 113 leafList.setLeafName(identifier);
114 114
115 Parsable tmpData = listener.getParsedDataStack().peek(); 115 Parsable tmpData = listener.getParsedDataStack().peek();
116 - YangLeavesHolder leaves; 116 + YangLeavesHolder leavesHolder;
117 117
118 if (tmpData instanceof YangLeavesHolder) { 118 if (tmpData instanceof YangLeavesHolder) {
119 - leaves = (YangLeavesHolder) tmpData; 119 + leavesHolder = (YangLeavesHolder) tmpData;
120 - leaves.addLeafList(leafList); 120 + leavesHolder.addLeafList(leafList);
121 + leafList.setContainedIn(leavesHolder);
121 } else { 122 } else {
122 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_LIST_DATA, 123 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_LIST_DATA,
123 ctx.identifier().getText(), ENTRY)); 124 ctx.identifier().getText(), ENTRY));
......
...@@ -115,11 +115,12 @@ public final class LeafListener { ...@@ -115,11 +115,12 @@ public final class LeafListener {
115 leaf.setLeafName(identifier); 115 leaf.setLeafName(identifier);
116 116
117 Parsable tmpData = listener.getParsedDataStack().peek(); 117 Parsable tmpData = listener.getParsedDataStack().peek();
118 - YangLeavesHolder leaves; 118 + YangLeavesHolder leavesHolder;
119 119
120 if (tmpData instanceof YangLeavesHolder) { 120 if (tmpData instanceof YangLeavesHolder) {
121 - leaves = (YangLeavesHolder) tmpData; 121 + leavesHolder = (YangLeavesHolder) tmpData;
122 - leaves.addLeaf(leaf); 122 + leavesHolder.addLeaf(leaf);
123 + leaf.setContainedIn(leavesHolder);
123 } else { 124 } else {
124 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_DATA, 125 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_DATA,
125 ctx.identifier().getText(), ENTRY)); 126 ctx.identifier().getText(), ENTRY));
......
...@@ -16,10 +16,11 @@ ...@@ -16,10 +16,11 @@
16 16
17 package org.onosproject.yangutils.parser.impl.listeners; 17 package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 -import org.onosproject.yangutils.linker.impl.YangReferenceResolver;
20 import org.onosproject.yangutils.datamodel.YangModule; 19 import org.onosproject.yangutils.datamodel.YangModule;
21 import org.onosproject.yangutils.datamodel.YangRevision; 20 import org.onosproject.yangutils.datamodel.YangRevision;
22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 +import org.onosproject.yangutils.linker.ResolvableType;
23 +import org.onosproject.yangutils.linker.YangReferenceResolver;
23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
24 import org.onosproject.yangutils.parser.exceptions.ParserException; 25 import org.onosproject.yangutils.parser.exceptions.ParserException;
25 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 26 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
...@@ -28,7 +29,8 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G ...@@ -28,7 +29,8 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G
28 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangModuleNode; 29 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangModuleNode;
29 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
31 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
33 + .constructListenerErrorMessage;
32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; 35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
...@@ -116,7 +118,10 @@ public final class ModuleListener { ...@@ -116,7 +118,10 @@ public final class ModuleListener {
116 ctx.identifier().getText(), EXIT)); 118 ctx.identifier().getText(), EXIT));
117 } 119 }
118 try { 120 try {
119 - ((YangReferenceResolver) listener.getParsedDataStack().peek()).resolveSelfFileLinking(); 121 + ((YangReferenceResolver) listener.getParsedDataStack()
122 + .peek()).resolveSelfFileLinking(ResolvableType.YANG_USES);
123 + ((YangReferenceResolver) listener.getParsedDataStack()
124 + .peek()).resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
120 } catch (DataModelException e) { 125 } catch (DataModelException e) {
121 ParserException parserException = new ParserException(e.getMessage()); 126 ParserException parserException = new ParserException(e.getMessage());
122 parserException.setLine(e.getLineNumber()); 127 parserException.setLine(e.getLineNumber());
......
...@@ -151,7 +151,7 @@ public final class PatternRestrictionListener { ...@@ -151,7 +151,7 @@ public final class PatternRestrictionListener {
151 * @param ctx context object of the grammar rule 151 * @param ctx context object of the grammar rule
152 */ 152 */
153 public static void processPatternRestrictionExit(TreeWalkListener listener, 153 public static void processPatternRestrictionExit(TreeWalkListener listener,
154 - GeneratedYangParser.PatternStatementContext ctx) { 154 + GeneratedYangParser.PatternStatementContext ctx) {
155 155
156 // Check for stack to be non empty. 156 // Check for stack to be non empty.
157 checkStackIsNotEmpty(listener, MISSING_HOLDER, PATTERN_DATA, ctx.string().getText(), EXIT); 157 checkStackIsNotEmpty(listener, MISSING_HOLDER, PATTERN_DATA, ctx.string().getText(), EXIT);
......
...@@ -16,10 +16,11 @@ ...@@ -16,10 +16,11 @@
16 16
17 package org.onosproject.yangutils.parser.impl.listeners; 17 package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 -import org.onosproject.yangutils.linker.impl.YangReferenceResolver;
20 import org.onosproject.yangutils.datamodel.YangRevision; 19 import org.onosproject.yangutils.datamodel.YangRevision;
21 import org.onosproject.yangutils.datamodel.YangSubModule; 20 import org.onosproject.yangutils.datamodel.YangSubModule;
22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 +import org.onosproject.yangutils.linker.ResolvableType;
23 +import org.onosproject.yangutils.linker.YangReferenceResolver;
23 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; 24 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
24 import org.onosproject.yangutils.parser.exceptions.ParserException; 25 import org.onosproject.yangutils.parser.exceptions.ParserException;
25 import org.onosproject.yangutils.parser.impl.TreeWalkListener; 26 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
...@@ -28,7 +29,8 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G ...@@ -28,7 +29,8 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G
28 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangSubModuleNode; 29 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangSubModuleNode;
29 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
30 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; 31 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
31 -import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage; 32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
33 + .constructListenerErrorMessage;
32 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER; 34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
33 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER; 35 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
34 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 36 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
...@@ -121,7 +123,10 @@ public final class SubModuleListener { ...@@ -121,7 +123,10 @@ public final class SubModuleListener {
121 ctx.identifier().getText(), EXIT)); 123 ctx.identifier().getText(), EXIT));
122 } 124 }
123 try { 125 try {
124 - ((YangReferenceResolver) listener.getParsedDataStack().peek()).resolveSelfFileLinking(); 126 + ((YangReferenceResolver) listener.getParsedDataStack().peek())
127 + .resolveSelfFileLinking(ResolvableType.YANG_USES);
128 + ((YangReferenceResolver) listener.getParsedDataStack().peek())
129 + .resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
125 } catch (DataModelException e) { 130 } catch (DataModelException e) {
126 ParserException parserException = new ParserException(e.getMessage()); 131 ParserException parserException = new ParserException(e.getMessage());
127 parserException.setLine(e.getLineNumber()); 132 parserException.setLine(e.getLineNumber());
......
...@@ -35,7 +35,7 @@ import org.onosproject.yangutils.parser.impl.TreeWalkListener; ...@@ -35,7 +35,7 @@ import org.onosproject.yangutils.parser.impl.TreeWalkListener;
35 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo; 35 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo;
36 import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION; 36 import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
37 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangType; 37 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangType;
38 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.UNRESOLVED; 38 +import static org.onosproject.yangutils.linker.ResolvableStatus.UNRESOLVED;
39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY; 39 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
40 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT; 40 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
41 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage; 41 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
......
...@@ -247,7 +247,7 @@ public final class AugmentListenerUtil { ...@@ -247,7 +247,7 @@ public final class AugmentListenerUtil {
247 /** 247 /**
248 * Validates whether nodes in target node list are valid or not. 248 * Validates whether nodes in target node list are valid or not.
249 * 249 *
250 - * @param targetNodeName current target node 250 + * @param targetNodes target node
251 * @param curNode YANG node 251 * @param curNode YANG node
252 * @return true or false 252 * @return true or false
253 */ 253 */
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
17 package org.onosproject.yangutils.plugin.manager; 17 package org.onosproject.yangutils.plugin.manager;
18 18
19 import java.util.Objects; 19 import java.util.Objects;
20 -import org.onosproject.yangutils.linker.impl.ResolvableStatus; 20 +import org.onosproject.yangutils.linker.ResolvableStatus;
21 import org.onosproject.yangutils.datamodel.YangNode; 21 import org.onosproject.yangutils.datamodel.YangNode;
22 22
23 /** 23 /**
......
...@@ -62,7 +62,8 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getDirectory; ...@@ -62,7 +62,8 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getDirectory;
62 */ 62 */
63 @Mojo(name = "yang2java", defaultPhase = GENERATE_SOURCES, requiresDependencyResolution = COMPILE, 63 @Mojo(name = "yang2java", defaultPhase = GENERATE_SOURCES, requiresDependencyResolution = COMPILE,
64 requiresProject = true) 64 requiresProject = true)
65 -public class YangUtilManager extends AbstractMojo { 65 +public class YangUtilManager
66 + extends AbstractMojo {
66 67
67 private YangNode rootNode; 68 private YangNode rootNode;
68 // YANG file information set. 69 // YANG file information set.
...@@ -134,7 +135,8 @@ public class YangUtilManager extends AbstractMojo { ...@@ -134,7 +135,8 @@ public class YangUtilManager extends AbstractMojo {
134 private BuildContext context; 135 private BuildContext context;
135 136
136 @Override 137 @Override
137 - public void execute() throws MojoExecutionException, MojoFailureException { 138 + public void execute()
139 + throws MojoExecutionException, MojoFailureException {
138 140
139 try { 141 try {
140 142
...@@ -204,7 +206,8 @@ public class YangUtilManager extends AbstractMojo { ...@@ -204,7 +206,8 @@ public class YangUtilManager extends AbstractMojo {
204 * 206 *
205 * @throws MojoExecutionException a violation in mojo excecution 207 * @throws MojoExecutionException a violation in mojo excecution
206 */ 208 */
207 - public void resolveDependenciesUsingLinker() throws MojoExecutionException { 209 + public void resolveDependenciesUsingLinker()
210 + throws MojoExecutionException {
208 for (YangFileInfo yangFileInfo : getYangFileInfoSet()) { 211 for (YangFileInfo yangFileInfo : getYangFileInfoSet()) {
209 setCurYangFileInfo(yangFileInfo); 212 setCurYangFileInfo(yangFileInfo);
210 try { 213 try {
...@@ -220,7 +223,8 @@ public class YangUtilManager extends AbstractMojo { ...@@ -220,7 +223,8 @@ public class YangUtilManager extends AbstractMojo {
220 * 223 *
221 * @throws IOException a violation in IO 224 * @throws IOException a violation in IO
222 */ 225 */
223 - public void parseYangFileInfoSet() throws IOException { 226 + public void parseYangFileInfoSet()
227 + throws IOException {
224 for (YangFileInfo yangFileInfo : getYangFileInfoSet()) { 228 for (YangFileInfo yangFileInfo : getYangFileInfoSet()) {
225 setCurYangFileInfo(yangFileInfo); 229 setCurYangFileInfo(yangFileInfo);
226 try { 230 try {
......
...@@ -64,10 +64,10 @@ public final class JavaCodeGeneratorUtil { ...@@ -64,10 +64,10 @@ public final class JavaCodeGeneratorUtil {
64 /** 64 /**
65 * Generates Java code files corresponding to the YANG schema. 65 * Generates Java code files corresponding to the YANG schema.
66 * 66 *
67 - * @param rootNode root node of the data model tree 67 + * @param rootNode root node of the data model tree
68 * @param yangPlugin YANG plugin config 68 * @param yangPlugin YANG plugin config
69 * @throws TranslatorException when fails to generate java code file the current 69 * @throws TranslatorException when fails to generate java code file the current
70 - * node 70 + * node
71 */ 71 */
72 public static void generateJavaCode(YangNode rootNode, YangPluginConfig yangPlugin) 72 public static void generateJavaCode(YangNode rootNode, YangPluginConfig yangPlugin)
73 throws TranslatorException { 73 throws TranslatorException {
...@@ -77,18 +77,35 @@ public final class JavaCodeGeneratorUtil { ...@@ -77,18 +77,35 @@ public final class JavaCodeGeneratorUtil {
77 77
78 while (codeGenNode != null) { 78 while (codeGenNode != null) {
79 if (curTraversal != PARENT) { 79 if (curTraversal != PARENT) {
80 + if (!(codeGenNode instanceof JavaCodeGenerator)) {
81 + throw new TranslatorException("Unsupported node to generate code");
82 + }
83 +
80 setCurNode(codeGenNode); 84 setCurNode(codeGenNode);
81 - generateCodeEntry(codeGenNode, yangPlugin); 85 + try {
86 + generateCodeEntry(codeGenNode, yangPlugin);
87 + } catch (Exception e) {
88 + throw new TranslatorException(e.getMessage());
89 + }
90 +
82 } 91 }
83 if (curTraversal != PARENT && codeGenNode.getChild() != null) { 92 if (curTraversal != PARENT && codeGenNode.getChild() != null) {
84 curTraversal = CHILD; 93 curTraversal = CHILD;
85 codeGenNode = codeGenNode.getChild(); 94 codeGenNode = codeGenNode.getChild();
86 } else if (codeGenNode.getNextSibling() != null) { 95 } else if (codeGenNode.getNextSibling() != null) {
87 - generateCodeExit(codeGenNode); 96 + try {
97 + generateCodeExit(codeGenNode);
98 + } catch (Exception e) {
99 + throw new TranslatorException(e.getMessage());
100 + }
88 curTraversal = SIBILING; 101 curTraversal = SIBILING;
89 codeGenNode = codeGenNode.getNextSibling(); 102 codeGenNode = codeGenNode.getNextSibling();
90 } else { 103 } else {
91 - generateCodeExit(codeGenNode); 104 + try {
105 + generateCodeExit(codeGenNode);
106 + } catch (Exception e) {
107 + throw new TranslatorException(e.getMessage());
108 + }
92 curTraversal = PARENT; 109 curTraversal = PARENT;
93 codeGenNode = codeGenNode.getParent(); 110 codeGenNode = codeGenNode.getParent();
94 } 111 }
...@@ -99,10 +116,10 @@ public final class JavaCodeGeneratorUtil { ...@@ -99,10 +116,10 @@ public final class JavaCodeGeneratorUtil {
99 * Generates the current nodes code snippet. 116 * Generates the current nodes code snippet.
100 * 117 *
101 * @param codeGenNode current data model node for which the code needs to be 118 * @param codeGenNode current data model node for which the code needs to be
102 - * generated 119 + * generated
103 - * @param yangPlugin YANG plugin config 120 + * @param yangPlugin YANG plugin config
104 * @throws TranslatorException when fails to generate java code file the current 121 * @throws TranslatorException when fails to generate java code file the current
105 - * node 122 + * node
106 */ 123 */
107 private static void generateCodeEntry(YangNode codeGenNode, YangPluginConfig yangPlugin) 124 private static void generateCodeEntry(YangNode codeGenNode, YangPluginConfig yangPlugin)
108 throws TranslatorException { 125 throws TranslatorException {
...@@ -119,11 +136,12 @@ public final class JavaCodeGeneratorUtil { ...@@ -119,11 +136,12 @@ public final class JavaCodeGeneratorUtil {
119 * Generates the current nodes code target code from the snippet. 136 * Generates the current nodes code target code from the snippet.
120 * 137 *
121 * @param codeGenNode current data model node for which the code needs to be 138 * @param codeGenNode current data model node for which the code needs to be
122 - * generated 139 + * generated
123 * @throws TranslatorException when fails to generate java code file the current 140 * @throws TranslatorException when fails to generate java code file the current
124 - * node 141 + * node
125 */ 142 */
126 - private static void generateCodeExit(YangNode codeGenNode) throws TranslatorException { 143 + private static void generateCodeExit(YangNode codeGenNode)
144 + throws TranslatorException {
127 145
128 if (codeGenNode instanceof JavaCodeGenerator) { 146 if (codeGenNode instanceof JavaCodeGenerator) {
129 ((JavaCodeGenerator) codeGenNode).generateCodeExit(); 147 ((JavaCodeGenerator) codeGenNode).generateCodeExit();
...@@ -188,7 +206,7 @@ public final class JavaCodeGeneratorUtil { ...@@ -188,7 +206,7 @@ public final class JavaCodeGeneratorUtil {
188 * Delete Java code files corresponding to the YANG schema. 206 * Delete Java code files corresponding to the YANG schema.
189 * 207 *
190 * @param rootNode root node of data-model tree 208 * @param rootNode root node of data-model tree
191 - * @throws IOException when fails to delete java code file the current node 209 + * @throws IOException when fails to delete java code file the current node
192 */ 210 */
193 public static void translatorErrorHandler(YangNode rootNode) 211 public static void translatorErrorHandler(YangNode rootNode)
194 throws IOException { 212 throws IOException {
......
...@@ -20,8 +20,6 @@ import java.util.List; ...@@ -20,8 +20,6 @@ import java.util.List;
20 import java.util.SortedSet; 20 import java.util.SortedSet;
21 import java.util.TreeSet; 21 import java.util.TreeSet;
22 22
23 -import static java.util.Collections.sort;
24 -
25 import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT_EVENT; 23 import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT_EVENT;
26 import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST; 24 import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST;
27 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION_HOLDER_CLASS_IMPORT_CLASS; 25 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION_HOLDER_CLASS_IMPORT_CLASS;
...@@ -45,6 +43,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; ...@@ -45,6 +43,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
45 import static org.onosproject.yangutils.utils.UtilConstants.PROVIDED_AUGMENTATION_CLASS_IMPORT_PKG; 43 import static org.onosproject.yangutils.utils.UtilConstants.PROVIDED_AUGMENTATION_CLASS_IMPORT_PKG;
46 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; 44 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
47 45
46 +import static java.util.Collections.sort;
47 +
48 /** 48 /**
49 * Represents that generated Java file can contain imports. 49 * Represents that generated Java file can contain imports.
50 */ 50 */
...@@ -116,20 +116,52 @@ public class JavaImportData { ...@@ -116,20 +116,52 @@ public class JavaImportData {
116 * a qualified manner. 116 * a qualified manner.
117 * 117 *
118 * @param newImportInfo class/interface info being imported 118 * @param newImportInfo class/interface info being imported
119 - * @return status of new addition of class/interface to the import set 119 + * @param className name of the call being generated
120 + * @param classPkg generated class package
121 + * @return qualified access status of the import node being added
120 */ 122 */
121 - public boolean addImportInfo(JavaQualifiedTypeInfo newImportInfo) { 123 + public boolean addImportInfo(JavaQualifiedTypeInfo newImportInfo,
124 + String className, String classPkg) {
125 +
126 + if (newImportInfo.getClassInfo().contentEquals(className)) {
127 + /*
128 + * if the current class name is same as the attribute class name,
129 + * then the attribute must be accessed in a qualified manner.
130 + */
131 + return true;
132 + } else if (newImportInfo.getPkgInfo() == null) {
133 + /*
134 + * If the package info is null, then it is not a candidate for import / qualified access
135 + */
136 + return false;
137 + }
138 +
139 + /*
140 + * If the attribute type is having the package info, it is contender
141 + * for import list and also need to check if it needs to be a
142 + * qualified access.
143 + */
144 + if (newImportInfo.getPkgInfo().contentEquals(classPkg)) {
145 + /**
146 + * Package of the referred attribute and the generated class is same, so no need import
147 + * or qualified access.
148 + */
149 + return false;
150 + }
122 151
123 for (JavaQualifiedTypeInfo curImportInfo : getImportSet()) { 152 for (JavaQualifiedTypeInfo curImportInfo : getImportSet()) {
124 if (curImportInfo.getClassInfo() 153 if (curImportInfo.getClassInfo()
125 .contentEquals(newImportInfo.getClassInfo())) { 154 .contentEquals(newImportInfo.getClassInfo())) {
126 - return curImportInfo.getPkgInfo() 155 + return !curImportInfo.getPkgInfo()
127 .contentEquals(newImportInfo.getPkgInfo()); 156 .contentEquals(newImportInfo.getPkgInfo());
128 } 157 }
129 } 158 }
130 159
160 + /*
161 + * import is added, so it is a member for non qualified access
162 + */
131 getImportSet().add(newImportInfo); 163 getImportSet().add(newImportInfo);
132 - return true; 164 + return false;
133 } 165 }
134 166
135 /** 167 /**
......
...@@ -134,10 +134,10 @@ public class JavaQualifiedTypeInfo ...@@ -134,10 +134,10 @@ public class JavaQualifiedTypeInfo
134 * Returns the import info for an attribute, which needs to be used for code 134 * Returns the import info for an attribute, which needs to be used for code
135 * generation for import or for qualified access. 135 * generation for import or for qualified access.
136 * 136 *
137 - * @param curNode current data model node for which the java file is being 137 + * @param curNode current data model node for which the java file is being
138 - * generated 138 + * generated
139 * @param attributeName name of the attribute being added, it will used in 139 * @param attributeName name of the attribute being added, it will used in
140 - * import info for child class 140 + * import info for child class
141 * @return return the import info for this attribute 141 * @return return the import info for this attribute
142 */ 142 */
143 public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfCurNode(YangNode curNode, 143 public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfCurNode(YangNode curNode,
...@@ -149,14 +149,10 @@ public class JavaQualifiedTypeInfo ...@@ -149,14 +149,10 @@ public class JavaQualifiedTypeInfo
149 throw new TranslatorException("missing java file information to get the package details " 149 throw new TranslatorException("missing java file information to get the package details "
150 + "of attribute corresponding to child node"); 150 + "of attribute corresponding to child node");
151 } 151 }
152 - /* 152 +
153 - * The scenario when we need to add the child class as an attribute in
154 - * the current class. The child class is in the package of the current
155 - * classes package with current classes name.
156 - */
157 importInfo.setClassInfo(attributeName); 153 importInfo.setClassInfo(attributeName);
158 - importInfo.setPkgInfo((((JavaFileInfoContainer) curNode).getJavaFileInfo().getPackage() + "." 154 + importInfo.setPkgInfo(((JavaFileInfoContainer) curNode)
159 - + ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()).toLowerCase()); 155 + .getJavaFileInfo().getPackage());
160 156
161 return importInfo; 157 return importInfo;
162 } 158 }
...@@ -165,7 +161,7 @@ public class JavaQualifiedTypeInfo ...@@ -165,7 +161,7 @@ public class JavaQualifiedTypeInfo
165 * Returns the java qualified type information for the wrapper classes. 161 * Returns the java qualified type information for the wrapper classes.
166 * 162 *
167 * @param referredTypesAttrInfo attribute of referred type 163 * @param referredTypesAttrInfo attribute of referred type
168 - * @param conflictResolver plugin configurations 164 + * @param conflictResolver plugin configurations
169 * @return return the import info for this attribute 165 * @return return the import info for this attribute
170 */ 166 */
171 public static JavaQualifiedTypeInfo getQualifiedInfoOfFromString(JavaAttributeInfo referredTypesAttrInfo, 167 public static JavaQualifiedTypeInfo getQualifiedInfoOfFromString(JavaAttributeInfo referredTypesAttrInfo,
......
...@@ -71,11 +71,11 @@ import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME; ...@@ -71,11 +71,11 @@ import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME;
71 import static org.onosproject.yangutils.utils.UtilConstants.SLASH; 71 import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
72 import static org.onosproject.yangutils.utils.UtilConstants.VOID; 72 import static org.onosproject.yangutils.utils.UtilConstants.VOID;
73 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage; 73 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
74 -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc;
75 -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
76 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; 74 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE;
77 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; 75 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
78 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MANAGER_SETTER_METHOD; 76 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MANAGER_SETTER_METHOD;
77 +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc;
78 +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
79 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; 79 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
80 80
81 /** 81 /**
...@@ -119,6 +119,7 @@ public class TempJavaServiceFragmentFiles ...@@ -119,6 +119,7 @@ public class TempJavaServiceFragmentFiles
119 * File name for event subject setter temp file. 119 * File name for event subject setter temp file.
120 */ 120 */
121 private static final String EVENT_SUBJECT_SETTER_FILE_NAME = "EventSubjectSetter"; 121 private static final String EVENT_SUBJECT_SETTER_FILE_NAME = "EventSubjectSetter";
122 +
122 /** 123 /**
123 * File name for generated class file for service 124 * File name for generated class file for service
124 * suffix. 125 * suffix.
...@@ -370,14 +371,13 @@ public class TempJavaServiceFragmentFiles ...@@ -370,14 +371,13 @@ public class TempJavaServiceFragmentFiles
370 * Constructs java code exit. 371 * Constructs java code exit.
371 * 372 *
372 * @param fileType generated file type 373 * @param fileType generated file type
373 - * @param curNode current YANG node 374 + * @param curNode current YANG node
374 * @throws IOException when fails to generate java files 375 * @throws IOException when fails to generate java files
375 */ 376 */
376 @Override 377 @Override
377 public void generateJavaFile(int fileType, YangNode curNode) 378 public void generateJavaFile(int fileType, YangNode curNode)
378 throws IOException { 379 throws IOException {
379 - List<String> imports = new ArrayList<>(); 380 + List<String> imports = getJavaImportData().getImports();
380 - imports = getJavaImportData().getImports();
381 381
382 createPackage(curNode); 382 createPackage(curNode);
383 383
...@@ -433,15 +433,16 @@ public class TempJavaServiceFragmentFiles ...@@ -433,15 +433,16 @@ public class TempJavaServiceFragmentFiles
433 /** 433 /**
434 * Adds rpc string information to applicable temp file. 434 * Adds rpc string information to applicable temp file.
435 * 435 *
436 - * @param javaAttributeInfoOfInput rpc's input node attribute info 436 + * @param javaAttributeInfoOfInput rpc's input node attribute info
437 * @param javaAttributeInfoOfOutput rpc's output node attribute info 437 * @param javaAttributeInfoOfOutput rpc's output node attribute info
438 - * @param rpcName name of the rpc function 438 + * @param rpcName name of the rpc function
439 - * @param pluginConfig plugin configurations 439 + * @param pluginConfig plugin configurations
440 * @throws IOException IO operation fail 440 * @throws IOException IO operation fail
441 */ 441 */
442 private void addRpcString(JavaAttributeInfo javaAttributeInfoOfInput, 442 private void addRpcString(JavaAttributeInfo javaAttributeInfoOfInput,
443 JavaAttributeInfo javaAttributeInfoOfOutput, YangPluginConfig pluginConfig, 443 JavaAttributeInfo javaAttributeInfoOfOutput, YangPluginConfig pluginConfig,
444 - String rpcName) throws IOException { 444 + String rpcName)
445 + throws IOException {
445 String rpcInput = EMPTY_STRING; 446 String rpcInput = EMPTY_STRING;
446 String rpcOutput = VOID; 447 String rpcOutput = VOID;
447 String rpcInputJavaDoc = EMPTY_STRING; 448 String rpcInputJavaDoc = EMPTY_STRING;
...@@ -464,20 +465,21 @@ public class TempJavaServiceFragmentFiles ...@@ -464,20 +465,21 @@ public class TempJavaServiceFragmentFiles
464 /** 465 /**
465 * Adds rpc string information to applicable temp file. 466 * Adds rpc string information to applicable temp file.
466 * 467 *
467 - * @param javaAttributeInfoOfInput rpc's input node attribute info 468 + * @param javaAttributeInfoOfInput rpc's input node attribute info
468 * @param javaAttributeInfoOfOutput rpc's output node attribute info 469 * @param javaAttributeInfoOfOutput rpc's output node attribute info
469 - * @param rpcName name of the rpc function 470 + * @param rpcName name of the rpc function
470 - * @param pluginConfig plugin configurations 471 + * @param pluginConfig plugin configurations
471 - * @param isInputLeafHolder if input node is leaf holder 472 + * @param isInputLeafHolder if input node is leaf holder
472 - * @param isOutputLeafHolder if output node is leaf holder 473 + * @param isOutputLeafHolder if output node is leaf holder
473 - * @param isInputSingleChildHolder if input node is single child holder 474 + * @param isInputSingleChildHolder if input node is single child holder
474 * @param isOutputSingleChildHolder if input node is single child holder 475 * @param isOutputSingleChildHolder if input node is single child holder
475 * @throws IOException IO operation fail 476 * @throws IOException IO operation fail
476 */ 477 */
477 public void addRpcString(JavaAttributeInfo javaAttributeInfoOfInput, 478 public void addRpcString(JavaAttributeInfo javaAttributeInfoOfInput,
478 JavaAttributeInfo javaAttributeInfoOfOutput, YangPluginConfig pluginConfig, 479 JavaAttributeInfo javaAttributeInfoOfOutput, YangPluginConfig pluginConfig,
479 String rpcName, boolean isInputLeafHolder, boolean isOutputLeafHolder, 480 String rpcName, boolean isInputLeafHolder, boolean isOutputLeafHolder,
480 - boolean isInputSingleChildHolder, boolean isOutputSingleChildHolder) throws IOException { 481 + boolean isInputSingleChildHolder, boolean isOutputSingleChildHolder)
482 + throws IOException {
481 String rpcInput = EMPTY_STRING; 483 String rpcInput = EMPTY_STRING;
482 String rpcOutput = VOID; 484 String rpcOutput = VOID;
483 String rpcInputJavaDoc = EMPTY_STRING; 485 String rpcInputJavaDoc = EMPTY_STRING;
...@@ -504,10 +506,10 @@ public class TempJavaServiceFragmentFiles ...@@ -504,10 +506,10 @@ public class TempJavaServiceFragmentFiles
504 /** 506 /**
505 * Returns names for input and output. 507 * Returns names for input and output.
506 * 508 *
507 - * @param attr attribute info 509 + * @param attr attribute info
508 - * @param isLeafHolder if leaf holder 510 + * @param isLeafHolder if leaf holder
509 * @param isSinglechildHolder if single child holder 511 * @param isSinglechildHolder if single child holder
510 - * @param pluginConfig plugin configurations 512 + * @param pluginConfig plugin configurations
511 * @return names for input and output 513 * @return names for input and output
512 */ 514 */
513 private String getInputOutputNames(JavaAttributeInfo attr, boolean isLeafHolder, boolean isSinglechildHolder, 515 private String getInputOutputNames(JavaAttributeInfo attr, boolean isLeafHolder, boolean isSinglechildHolder,
...@@ -550,13 +552,13 @@ public class TempJavaServiceFragmentFiles ...@@ -550,13 +552,13 @@ public class TempJavaServiceFragmentFiles
550 /** 552 /**
551 * Adds the JAVA rpc snippet information. 553 * Adds the JAVA rpc snippet information.
552 * 554 *
553 - * @param javaAttributeInfoOfInput rpc's input node attribute info 555 + * @param javaAttributeInfoOfInput rpc's input node attribute info
554 * @param javaAttributeInfoOfOutput rpc's output node attribute info 556 * @param javaAttributeInfoOfOutput rpc's output node attribute info
555 - * @param pluginConfig plugin configurations 557 + * @param pluginConfig plugin configurations
556 - * @param rpcName name of the rpc function 558 + * @param rpcName name of the rpc function
557 - * @param isInputLeafHolder if input node is leaf holder 559 + * @param isInputLeafHolder if input node is leaf holder
558 - * @param isOutputLeafHolder if output node is leaf holder 560 + * @param isOutputLeafHolder if output node is leaf holder
559 - * @param isInputSingleChildHolder if input node is single child holder 561 + * @param isInputSingleChildHolder if input node is single child holder
560 * @param isOutputSingleChildHolder if input node is single child holder 562 * @param isOutputSingleChildHolder if input node is single child holder
561 * @throws IOException IO operation fail 563 * @throws IOException IO operation fail
562 */ 564 */
...@@ -573,7 +575,7 @@ public class TempJavaServiceFragmentFiles ...@@ -573,7 +575,7 @@ public class TempJavaServiceFragmentFiles
573 * Constructs java code exit. 575 * Constructs java code exit.
574 * 576 *
575 * @param fileType generated file type 577 * @param fileType generated file type
576 - * @param curNode current YANG node 578 + * @param curNode current YANG node
577 * @throws IOException when fails to generate java files 579 * @throws IOException when fails to generate java files
578 */ 580 */
579 public void generateEventJavaFile(int fileType, YangNode curNode) 581 public void generateEventJavaFile(int fileType, YangNode curNode)
...@@ -604,7 +606,7 @@ public class TempJavaServiceFragmentFiles ...@@ -604,7 +606,7 @@ public class TempJavaServiceFragmentFiles
604 * Constructs java code exit. 606 * Constructs java code exit.
605 * 607 *
606 * @param fileType generated file type 608 * @param fileType generated file type
607 - * @param curNode current YANG node 609 + * @param curNode current YANG node
608 * @throws IOException when fails to generate java files 610 * @throws IOException when fails to generate java files
609 */ 611 */
610 public void generateEventListenerJavaFile(int fileType, YangNode curNode) 612 public void generateEventListenerJavaFile(int fileType, YangNode curNode)
...@@ -632,7 +634,7 @@ public class TempJavaServiceFragmentFiles ...@@ -632,7 +634,7 @@ public class TempJavaServiceFragmentFiles
632 * Constructs java code exit. 634 * Constructs java code exit.
633 * 635 *
634 * @param fileType generated file type 636 * @param fileType generated file type
635 - * @param curNode current YANG node 637 + * @param curNode current YANG node
636 * @throws IOException when fails to generate java files 638 * @throws IOException when fails to generate java files
637 */ 639 */
638 public void generateEventSubjectJavaFile(int fileType, YangNode curNode) 640 public void generateEventSubjectJavaFile(int fileType, YangNode curNode)
...@@ -657,8 +659,8 @@ public class TempJavaServiceFragmentFiles ...@@ -657,8 +659,8 @@ public class TempJavaServiceFragmentFiles
657 * Removes all temporary file handles. 659 * Removes all temporary file handles.
658 * 660 *
659 * @param isErrorOccurred when translator fails to generate java files we 661 * @param isErrorOccurred when translator fails to generate java files we
660 - * need to close all open file handles include temporary files 662 + * need to close all open file handles include temporary files
661 - * and java files. 663 + * and java files.
662 * @throws IOException when failed to delete the temporary files 664 * @throws IOException when failed to delete the temporary files
663 */ 665 */
664 @Override 666 @Override
...@@ -782,17 +784,18 @@ public class TempJavaServiceFragmentFiles ...@@ -782,17 +784,18 @@ public class TempJavaServiceFragmentFiles
782 /** 784 /**
783 * Adds java snippet for events to event subject file. 785 * Adds java snippet for events to event subject file.
784 * 786 *
785 - * @param curNode current node 787 + * @param curNode current node
786 * @param pluginConfig plugin configurations 788 * @param pluginConfig plugin configurations
787 * @throws IOException when fails to do IO operations 789 * @throws IOException when fails to do IO operations
788 */ 790 */
789 - public void addJavaSnippetOfEvent(YangNode curNode, YangPluginConfig pluginConfig) throws IOException { 791 + public void addJavaSnippetOfEvent(YangNode curNode, YangPluginConfig pluginConfig)
792 + throws IOException {
790 793
791 String currentInfo = getCapitalCase(getCamelCase(((YangNotification) curNode).getName(), 794 String currentInfo = getCapitalCase(getCamelCase(((YangNotification) curNode).getName(),
792 pluginConfig.getConflictResolver())); 795 pluginConfig.getConflictResolver()));
793 String notificationName = ((YangNotification) curNode).getName(); 796 String notificationName = ((YangNotification) curNode).getName();
794 797
795 - JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode.getParent(), 798 + JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
796 getCapitalCase(currentInfo)); 799 getCapitalCase(currentInfo));
797 800
798 JavaAttributeInfo javaAttributeInfo = 801 JavaAttributeInfo javaAttributeInfo =
...@@ -807,14 +810,16 @@ public class TempJavaServiceFragmentFiles ...@@ -807,14 +810,16 @@ public class TempJavaServiceFragmentFiles
807 } 810 }
808 811
809 /*Adds event to enum temp file.*/ 812 /*Adds event to enum temp file.*/
810 - private void addEventEnum(String notificationName, YangPluginConfig pluginConfig) throws IOException { 813 + private void addEventEnum(String notificationName, YangPluginConfig pluginConfig)
814 + throws IOException {
811 appendToFile(getEventEnumTempFileHandle(), 815 appendToFile(getEventEnumTempFileHandle(),
812 getJavaDoc(ENUM_ATTRIBUTE, notificationName, false, pluginConfig) + FOUR_SPACE_INDENTATION 816 getJavaDoc(ENUM_ATTRIBUTE, notificationName, false, pluginConfig) + FOUR_SPACE_INDENTATION
813 + getEnumJavaAttribute(notificationName).toUpperCase() + COMMA + NEW_LINE); 817 + getEnumJavaAttribute(notificationName).toUpperCase() + COMMA + NEW_LINE);
814 } 818 }
815 819
816 /*Adds event method in event class*/ 820 /*Adds event method in event class*/
817 - private void addEnumMethod(String eventClassname, String className) throws IOException { 821 + private void addEnumMethod(String eventClassname, String className)
822 + throws IOException {
818 appendToFile(getEventMethodTempFileHandle(), getEventFileContents(eventClassname, className)); 823 appendToFile(getEventMethodTempFileHandle(), getEventFileContents(eventClassname, className));
819 } 824 }
820 825
...@@ -853,7 +858,8 @@ public class TempJavaServiceFragmentFiles ...@@ -853,7 +858,8 @@ public class TempJavaServiceFragmentFiles
853 } 858 }
854 859
855 /*Adds getter method for event in event subject class.*/ 860 /*Adds getter method for event in event subject class.*/
856 - private void addEventSubjectGetter(JavaAttributeInfo attr, YangPluginConfig pluginConfig) throws IOException { 861 + private void addEventSubjectGetter(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
862 + throws IOException {
857 appendToFile(getEventSubjectGetterTempFileHandle(), 863 appendToFile(getEventSubjectGetterTempFileHandle(),
858 getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig) 864 getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false, pluginConfig)
859 + getGetterForClass(attr, GENERATE_EVENT_SUBJECT_CLASS) + NEW_LINE); 865 + getGetterForClass(attr, GENERATE_EVENT_SUBJECT_CLASS) + NEW_LINE);
......
...@@ -76,6 +76,7 @@ public class TempJavaTypeFragmentFiles ...@@ -76,6 +76,7 @@ public class TempJavaTypeFragmentFiles
76 * Temporary file handle for of string method of class. 76 * Temporary file handle for of string method of class.
77 */ 77 */
78 private File ofStringImplTempFileHandle; 78 private File ofStringImplTempFileHandle;
79 +
79 /** 80 /**
80 * Temporary file handle for constructor for type class. 81 * Temporary file handle for constructor for type class.
81 */ 82 */
...@@ -85,6 +86,7 @@ public class TempJavaTypeFragmentFiles ...@@ -85,6 +86,7 @@ public class TempJavaTypeFragmentFiles
85 * Java file handle for typedef class file. 86 * Java file handle for typedef class file.
86 */ 87 */
87 private File typedefClassJavaFileHandle; 88 private File typedefClassJavaFileHandle;
89 +
88 /** 90 /**
89 * Java file handle for type class like union, typedef file. 91 * Java file handle for type class like union, typedef file.
90 */ 92 */
...@@ -211,7 +213,7 @@ public class TempJavaTypeFragmentFiles ...@@ -211,7 +213,7 @@ public class TempJavaTypeFragmentFiles
211 YangJavaType<?> javaType = (YangJavaType<?>) yangType; 213 YangJavaType<?> javaType = (YangJavaType<?>) yangType;
212 javaType.updateJavaQualifiedInfo(pluginConfig.getConflictResolver()); 214 javaType.updateJavaQualifiedInfo(pluginConfig.getConflictResolver());
213 String typeName = javaType.getDataTypeName(); 215 String typeName = javaType.getDataTypeName();
214 - typeName = getCamelCase(typeName, pluginConfig.getConflictResolver()); 216 + typeName = getCamelCase(typeName, pluginConfig.getConflictResolver());
215 JavaAttributeInfo javaAttributeInfo = getAttributeInfoForTheData( 217 JavaAttributeInfo javaAttributeInfo = getAttributeInfoForTheData(
216 javaType.getJavaQualifiedInfo(), 218 javaType.getJavaQualifiedInfo(),
217 typeName, javaType, 219 typeName, javaType,
......
...@@ -24,14 +24,14 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; ...@@ -24,14 +24,14 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
24 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 24 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
25 import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; 25 import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
26 26
27 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 27 +import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo;
28 -import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
29 28
30 /** 29 /**
31 * Represents grouping information extended to support java code generation. 30 * Represents grouping information extended to support java code generation.
32 */ 31 */
33 public class YangJavaGrouping 32 public class YangJavaGrouping
34 - extends YangGrouping implements JavaCodeGeneratorInfo, JavaCodeGenerator { 33 + extends YangGrouping
34 + implements JavaCodeGeneratorInfo, JavaCodeGenerator {
35 35
36 /** 36 /**
37 * Contains the information of the java file being generated. 37 * Contains the information of the java file being generated.
...@@ -50,7 +50,6 @@ public class YangJavaGrouping ...@@ -50,7 +50,6 @@ public class YangJavaGrouping
50 public YangJavaGrouping() { 50 public YangJavaGrouping() {
51 super(); 51 super();
52 setJavaFileInfo(new JavaFileInfo()); 52 setJavaFileInfo(new JavaFileInfo());
53 - getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
54 } 53 }
55 54
56 /** 55 /**
...@@ -96,35 +95,22 @@ public class YangJavaGrouping ...@@ -96,35 +95,22 @@ public class YangJavaGrouping
96 tempFileHandle = fileHandle; 95 tempFileHandle = fileHandle;
97 } 96 }
98 97
99 - /** 98 +
100 - * Prepare the information for java code generation corresponding to YANG
101 - * grouping info.
102 - *
103 - * @param yangPlugin YANG plugin config
104 - * @throws TranslatorException translator operation fail
105 - */
106 @Override 99 @Override
107 - public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { 100 + public void generateCodeEntry(YangPluginConfig yangPlugin)
101 + throws TranslatorException {
108 try { 102 try {
109 - generateCodeOfNode(this, yangPlugin); 103 + updatePackageInfo(this, yangPlugin);
110 } catch (IOException e) { 104 } catch (IOException e) {
111 - throw new TranslatorException( 105 + throw new TranslatorException(e.getCause());
112 - "Failed to prepare generate code entry for container node " + this.getName());
113 } 106 }
114 } 107 }
115 108
116 - /**
117 - * Create a java file using the YANG grouping info.
118 - *
119 - * @throws TranslatorException translator operation fail
120 - */
121 @Override 109 @Override
122 - public void generateCodeExit() throws TranslatorException { 110 + public void generateCodeExit()
123 - try { 111 + throws TranslatorException {
124 - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); 112 + /*
125 - } catch (IOException e) { 113 + * Do nothing.
126 - throw new TranslatorException("Failed to generate code for container node " + this.getName()); 114 + */
127 - }
128 } 115 }
129 -
130 } 116 }
......
...@@ -16,7 +16,12 @@ ...@@ -16,7 +16,12 @@
16 package org.onosproject.yangutils.translator.tojava.javamodel; 16 package org.onosproject.yangutils.translator.tojava.javamodel;
17 17
18 import java.io.IOException; 18 import java.io.IOException;
19 +import java.util.List;
19 20
21 +import org.onosproject.yangutils.datamodel.YangGrouping;
22 +import org.onosproject.yangutils.datamodel.YangLeaf;
23 +import org.onosproject.yangutils.datamodel.YangLeafList;
24 +import org.onosproject.yangutils.datamodel.YangNode;
20 import org.onosproject.yangutils.datamodel.YangUses; 25 import org.onosproject.yangutils.datamodel.YangUses;
21 import org.onosproject.yangutils.translator.exception.TranslatorException; 26 import org.onosproject.yangutils.translator.exception.TranslatorException;
22 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; 27 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
...@@ -24,15 +29,16 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; ...@@ -24,15 +29,16 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
24 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 29 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
25 import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig; 30 import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
26 31
27 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 32 +import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeAsAttributeInTargetTempFile;
28 -import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeInfoInParentTempFile; 33 +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getParentNodeInGenCode;
34 +import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo;
29 35
30 /** 36 /**
31 * Represents uses information extended to support java code generation. 37 * Represents uses information extended to support java code generation.
32 */ 38 */
33 public class YangJavaUses 39 public class YangJavaUses
34 - extends YangUses implements JavaCodeGeneratorInfo, JavaCodeGenerator { 40 + extends YangUses
35 - 41 + implements JavaCodeGeneratorInfo, JavaCodeGenerator {
36 42
37 /** 43 /**
38 * Contains the information of the java file being generated. 44 * Contains the information of the java file being generated.
...@@ -51,7 +57,6 @@ public class YangJavaUses ...@@ -51,7 +57,6 @@ public class YangJavaUses
51 public YangJavaUses() { 57 public YangJavaUses() {
52 super(); 58 super();
53 setJavaFileInfo(new JavaFileInfo()); 59 setJavaFileInfo(new JavaFileInfo());
54 - getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
55 } 60 }
56 61
57 /** 62 /**
...@@ -97,31 +102,57 @@ public class YangJavaUses ...@@ -97,31 +102,57 @@ public class YangJavaUses
97 tempFileHandle = fileHandle; 102 tempFileHandle = fileHandle;
98 } 103 }
99 104
100 - /** 105 +
101 - * Prepare the information for java code generation corresponding to YANG
102 - * uses info.
103 - *
104 - * @param yangPlugin YANG plugin config
105 - * @throws TranslatorException translator operation fail
106 - */
107 @Override 106 @Override
108 - public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { 107 + public void generateCodeEntry(YangPluginConfig yangPlugin)
108 + throws TranslatorException {
109 try { 109 try {
110 - addCurNodeInfoInParentTempFile(this, false, yangPlugin); 110 + updatePackageInfo(this, yangPlugin);
111 +
112 + if (!(getParentNodeInGenCode(this) instanceof JavaCodeGeneratorInfo)) {
113 + throw new TranslatorException("invalid container of uses");
114 + }
115 + JavaCodeGeneratorInfo javaCodeGeneratorInfo = (JavaCodeGeneratorInfo) getParentNodeInGenCode(this);
116 +
117 + if (javaCodeGeneratorInfo instanceof YangGrouping) {
118 + /*
119 + * Do nothing, since it will taken care in the groupings uses.
120 + */
121 + return;
122 + }
123 +
124 + for (List<YangLeaf> leavesList :
125 + getUsesResolvedLeavesList()) {
126 + //add the resolved leaves to the parent as an attribute
127 + javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles()
128 + .getBeanTempFiles().addLeavesInfoToTempFiles(leavesList, yangPlugin);
129 + }
130 +
131 + for (List<YangLeafList> listOfLeafLists :
132 + getUsesResolvedListOfLeafList()) {
133 + //add the resolved leaf-list to the parent as an attribute
134 + javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles()
135 + .getBeanTempFiles().addLeafListInfoToTempFiles(listOfLeafLists, yangPlugin);
136 + }
137 +
138 + for (YangNode usesResolvedNode :
139 + getUsesResolvedNodeList()) {
140 + //add the resolved nodes to the parent as an attribute
141 + addCurNodeAsAttributeInTargetTempFile(usesResolvedNode, yangPlugin,
142 + getParentNodeInGenCode(this));
143 + }
144 +
111 } catch (IOException e) { 145 } catch (IOException e) {
112 - throw new TranslatorException( 146 + throw new TranslatorException(e.getCause());
113 - "Failed to prepare generate code entry for container node " + this.getName());
114 } 147 }
115 } 148 }
116 149
117 - /** 150 +
118 - * Create a java file using the YANG uses info.
119 - *
120 - * @throws TranslatorException translator operation fail
121 - */
122 @Override 151 @Override
123 - public void generateCodeExit() throws TranslatorException { 152 + public void generateCodeExit()
124 - // no code generation will be done for uses. 153 + throws TranslatorException {
154 + /*
155 + * Do nothing.
156 + */
125 } 157 }
126 -
127 } 158 }
......
...@@ -27,6 +27,7 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer; ...@@ -27,6 +27,7 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
27 import org.onosproject.yangutils.translator.tojava.JavaImportData; 27 import org.onosproject.yangutils.translator.tojava.JavaImportData;
28 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; 28 import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
29 29
30 +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
30 import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.getTempJavaFragement; 31 import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.getTempJavaFragement;
31 32
32 /** 33 /**
...@@ -58,7 +59,7 @@ public class JavaExtendsListHolder { ...@@ -58,7 +59,7 @@ public class JavaExtendsListHolder {
58 /** 59 /**
59 * Sets extends list. 60 * Sets extends list.
60 * 61 *
61 - * @param extendsList list of classes need to be extended 62 + * @param extendedClass map of classes need to be extended
62 */ 63 */
63 private void setExtendedClassStore(Map<JavaQualifiedTypeInfo, Boolean> extendedClass) { 64 private void setExtendedClassStore(Map<JavaQualifiedTypeInfo, Boolean> extendedClass) {
64 this.extendedClassStore = extendedClass; 65 this.extendedClassStore = extendedClass;
...@@ -73,14 +74,13 @@ public class JavaExtendsListHolder { ...@@ -73,14 +74,13 @@ public class JavaExtendsListHolder {
73 public void addToExtendsList(JavaQualifiedTypeInfo info, YangNode node) { 74 public void addToExtendsList(JavaQualifiedTypeInfo info, YangNode node) {
74 JavaFileInfo fileInfo = ((JavaFileInfoContainer) node).getJavaFileInfo(); 75 JavaFileInfo fileInfo = ((JavaFileInfoContainer) node).getJavaFileInfo();
75 76
76 - if (!fileInfo.getPackage().equals(info.getPkgInfo())) { 77 + JavaImportData importData = getTempJavaFragement(node).getJavaImportData();
77 - JavaImportData importData = getTempJavaFragement(node).getJavaImportData(); 78 + boolean qualified = importData.addImportInfo(info,
78 - importData.addImportInfo(info); 79 + getCapitalCase(fileInfo.getJavaName()), fileInfo.getPackage());
79 80
80 /*true means import should be added*/ 81 /*true means import should be added*/
81 - getExtendedClassStore().put(info, true); 82 + getExtendedClassStore().put(info, qualified);
82 - } 83 +
83 - getExtendedClassStore().put(info, false);
84 addToExtendsList(info); 84 addToExtendsList(info);
85 } 85 }
86 86
......
...@@ -29,12 +29,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; ...@@ -29,12 +29,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
29 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer; 29 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
30 import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; 30 import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles;
31 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment; 31 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment;
32 -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInput;
33 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; 32 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
34 -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaOutput;
35 -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
36 -
37 -import static java.util.Collections.sort;
38 33
39 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; 34 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
40 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase; 35 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
...@@ -69,6 +64,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.THIS; ...@@ -69,6 +64,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.THIS;
69 import static org.onosproject.yangutils.utils.UtilConstants.TYPE; 64 import static org.onosproject.yangutils.utils.UtilConstants.TYPE;
70 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; 65 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle;
71 66
67 +import static java.util.Collections.sort;
68 +
72 /** 69 /**
73 * Represents utilities for temporary java code fragments. 70 * Represents utilities for temporary java code fragments.
74 */ 71 */
...@@ -83,8 +80,8 @@ public final class TempJavaCodeFragmentFilesUtils { ...@@ -83,8 +80,8 @@ public final class TempJavaCodeFragmentFilesUtils {
83 /** 80 /**
84 * Adds import for AugmentationHolders class. 81 * Adds import for AugmentationHolders class.
85 * 82 *
86 - * @param curNode current YANG node 83 + * @param curNode current YANG node
87 - * @param imports list of imports 84 + * @param imports list of imports
88 * @param operation add or delete import 85 * @param operation add or delete import
89 */ 86 */
90 public static void addAugmentationHoldersImport(YangNode curNode, List<String> imports, boolean operation) { 87 public static void addAugmentationHoldersImport(YangNode curNode, List<String> imports, boolean operation) {
...@@ -95,8 +92,8 @@ public final class TempJavaCodeFragmentFilesUtils { ...@@ -95,8 +92,8 @@ public final class TempJavaCodeFragmentFilesUtils {
95 /** 92 /**
96 * Adds import for AugmentedInfo class. 93 * Adds import for AugmentedInfo class.
97 * 94 *
98 - * @param curNode current YANG node 95 + * @param curNode current YANG node
99 - * @param imports list of imports 96 + * @param imports list of imports
100 * @param operation add or delete import 97 * @param operation add or delete import
101 */ 98 */
102 public static void addAugmentedInfoImport(YangNode curNode, List<String> imports, boolean operation) { 99 public static void addAugmentedInfoImport(YangNode curNode, List<String> imports, boolean operation) {
...@@ -126,8 +123,8 @@ public final class TempJavaCodeFragmentFilesUtils { ...@@ -126,8 +123,8 @@ public final class TempJavaCodeFragmentFilesUtils {
126 /** 123 /**
127 * Updated imports with augmented nodes import. 124 * Updated imports with augmented nodes import.
128 * 125 *
129 - * @param curNode current YANG node 126 + * @param curNode current YANG node
130 - * @param imports list of imports 127 + * @param imports list of imports
131 * @param operation to add or to delete 128 * @param operation to add or to delete
132 */ 129 */
133 public static void addAugmentedNodesImport(YangNode curNode, List<String> imports, boolean operation) { 130 public static void addAugmentedNodesImport(YangNode curNode, List<String> imports, boolean operation) {
...@@ -156,7 +153,7 @@ public final class TempJavaCodeFragmentFilesUtils { ...@@ -156,7 +153,7 @@ public final class TempJavaCodeFragmentFilesUtils {
156 /** 153 /**
157 * Returns imports for augmented node. 154 * Returns imports for augmented node.
158 * 155 *
159 - * @param parent parent YANG node 156 + * @param parent parent YANG node
160 * @param targetNodes list of target nodes 157 * @param targetNodes list of target nodes
161 * @param isImplClass if impl class's import required 158 * @param isImplClass if impl class's import required
162 * @return imports for augmented node 159 * @return imports for augmented node
...@@ -204,8 +201,8 @@ public final class TempJavaCodeFragmentFilesUtils { ...@@ -204,8 +201,8 @@ public final class TempJavaCodeFragmentFilesUtils {
204 /** 201 /**
205 * Adds import for array list. 202 * Adds import for array list.
206 * 203 *
207 - * @param curNode current YANG node 204 + * @param curNode current YANG node
208 - * @param imports list of imports 205 + * @param imports list of imports
209 * @param operation add or delete import 206 * @param operation add or delete import
210 */ 207 */
211 public static void addArrayListImport(YangNode curNode, List<String> imports, boolean operation) { 208 public static void addArrayListImport(YangNode curNode, List<String> imports, boolean operation) {
...@@ -224,8 +221,8 @@ public final class TempJavaCodeFragmentFilesUtils { ...@@ -224,8 +221,8 @@ public final class TempJavaCodeFragmentFilesUtils {
224 /** 221 /**
225 * Adds listener's imports. 222 * Adds listener's imports.
226 * 223 *
227 - * @param curNode currentYangNode. 224 + * @param curNode currentYangNode.
228 - * @param imports import list 225 + * @param imports import list
229 * @param operation add or remove 226 * @param operation add or remove
230 * @param classInfo class info to be added to import list 227 * @param classInfo class info to be added to import list
231 */ 228 */
...@@ -244,7 +241,7 @@ public final class TempJavaCodeFragmentFilesUtils { ...@@ -244,7 +241,7 @@ public final class TempJavaCodeFragmentFilesUtils {
244 /** 241 /**
245 * Adds annotations imports. 242 * Adds annotations imports.
246 * 243 *
247 - * @param imports list if imports 244 + * @param imports list if imports
248 * @param operation to add or to delete 245 * @param operation to add or to delete
249 */ 246 */
250 public static void addAnnotationsImports(List<String> imports, boolean operation) { 247 public static void addAnnotationsImports(List<String> imports, boolean operation) {
...@@ -269,7 +266,7 @@ public final class TempJavaCodeFragmentFilesUtils { ...@@ -269,7 +266,7 @@ public final class TempJavaCodeFragmentFilesUtils {
269 /** 266 /**
270 * Performs given operations on import list. 267 * Performs given operations on import list.
271 * 268 *
272 - * @param imports list of imports 269 + * @param imports list of imports
273 * @param curImport current import 270 * @param curImport current import
274 * @param operation add or remove 271 * @param operation add or remove
275 * @return import list 272 * @return import list
...@@ -314,7 +311,7 @@ public final class TempJavaCodeFragmentFilesUtils { ...@@ -314,7 +311,7 @@ public final class TempJavaCodeFragmentFilesUtils {
314 /** 311 /**
315 * Closes the file handle for temporary file. 312 * Closes the file handle for temporary file.
316 * 313 *
317 - * @param file file to be closed 314 + * @param file file to be closed
318 * @param toBeDeleted flag to indicate if file needs to be deleted 315 * @param toBeDeleted flag to indicate if file needs to be deleted
319 * @throws IOException when failed to close the file handle 316 * @throws IOException when failed to close the file handle
320 */ 317 */
...@@ -330,33 +327,6 @@ public final class TempJavaCodeFragmentFilesUtils { ...@@ -330,33 +327,6 @@ public final class TempJavaCodeFragmentFilesUtils {
330 } 327 }
331 328
332 /** 329 /**
333 - * Detects collision between parent and child node which have same name.
334 - * When parent and child node both have the same name in that case child node should be used with
335 - * qualified name.
336 - *
337 - * @param curNode current YANG node
338 - * @param qualifiedTypeInfo current node's qualified info
339 - * @return true if collision is detected
340 - */
341 - public static boolean detectCollisionBwParentAndChildForImport(YangNode curNode,
342 - JavaQualifiedTypeInfo qualifiedTypeInfo) {
343 -
344 - YangNode parent = curNode.getParent();
345 - if (parent instanceof YangJavaModule
346 - || parent instanceof YangJavaSubModule
347 - || parent instanceof YangJavaInput
348 - || parent instanceof YangJavaOutput) {
349 - return false;
350 - }
351 - String parentsClassInfo = getCapitalCase(((JavaFileInfoContainer) parent).getJavaFileInfo().getJavaName());
352 - String childsClassInfo = qualifiedTypeInfo.getClassInfo();
353 - if (childsClassInfo.equals(parentsClassInfo)) {
354 - return true;
355 - }
356 - return false;
357 - }
358 -
359 - /**
360 * Returns sorted import list. 330 * Returns sorted import list.
361 * 331 *
362 * @param imports import list 332 * @param imports import list
......
...@@ -19,8 +19,6 @@ package org.onosproject.yangutils.translator.tojava.utils; ...@@ -19,8 +19,6 @@ package org.onosproject.yangutils.translator.tojava.utils;
19 import java.io.IOException; 19 import java.io.IOException;
20 20
21 import org.onosproject.yangutils.datamodel.RpcNotificationContainer; 21 import org.onosproject.yangutils.datamodel.RpcNotificationContainer;
22 -import org.onosproject.yangutils.datamodel.YangAugment;
23 -import org.onosproject.yangutils.datamodel.YangAugmentationHolder;
24 import org.onosproject.yangutils.datamodel.YangCase; 22 import org.onosproject.yangutils.datamodel.YangCase;
25 import org.onosproject.yangutils.datamodel.YangChoice; 23 import org.onosproject.yangutils.datamodel.YangChoice;
26 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 24 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
...@@ -45,9 +43,6 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSy ...@@ -45,9 +43,6 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSy
45 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase; 43 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
46 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage; 44 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
47 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage; 45 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
48 -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION_HOLDER;
49 -import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO;
50 -import static org.onosproject.yangutils.utils.UtilConstants.PROVIDED_AUGMENTATION_CLASS_IMPORT_PKG;
51 46
52 /** 47 /**
53 * Represents utility class for YANG java model. 48 * Represents utility class for YANG java model.
...@@ -64,7 +59,7 @@ public final class YangJavaModelUtils { ...@@ -64,7 +59,7 @@ public final class YangJavaModelUtils {
64 * Updates YANG java file package information. 59 * Updates YANG java file package information.
65 * 60 *
66 * @param javaCodeGeneratorInfo YANG java file info node 61 * @param javaCodeGeneratorInfo YANG java file info node
67 - * @param yangPluginConfig YANG plugin config 62 + * @param yangPluginConfig YANG plugin config
68 * @throws IOException IO operations fails 63 * @throws IOException IO operations fails
69 */ 64 */
70 public static void updatePackageInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo, 65 public static void updatePackageInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
...@@ -85,7 +80,7 @@ public final class YangJavaModelUtils { ...@@ -85,7 +80,7 @@ public final class YangJavaModelUtils {
85 * Updates YANG java file package information for specified package. 80 * Updates YANG java file package information for specified package.
86 * 81 *
87 * @param javaCodeGeneratorInfo YANG java file info node 82 * @param javaCodeGeneratorInfo YANG java file info node
88 - * @param yangPlugin YANG plugin config 83 + * @param yangPlugin YANG plugin config
89 * @throws IOException IO operations fails 84 * @throws IOException IO operations fails
90 */ 85 */
91 private static void updatePackageInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo, YangPluginConfig yangPlugin, 86 private static void updatePackageInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo, YangPluginConfig yangPlugin,
...@@ -128,7 +123,7 @@ public final class YangJavaModelUtils { ...@@ -128,7 +123,7 @@ public final class YangJavaModelUtils {
128 */ 123 */
129 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() 124 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles()
130 .getServiceTempFiles().addCurNodeLeavesInfoToTempFiles( 125 .getServiceTempFiles().addCurNodeLeavesInfoToTempFiles(
131 - (YangNode) javaCodeGeneratorInfo, yangPluginConfig); 126 + (YangNode) javaCodeGeneratorInfo, yangPluginConfig);
132 if ((YangNode) javaCodeGeneratorInfo instanceof YangJavaModule) { 127 if ((YangNode) javaCodeGeneratorInfo instanceof YangJavaModule) {
133 if (!((YangJavaModule) javaCodeGeneratorInfo).getNotificationNodes().isEmpty()) { 128 if (!((YangJavaModule) javaCodeGeneratorInfo).getNotificationNodes().isEmpty()) {
134 updateNotificaitonNodeInfo(javaCodeGeneratorInfo, yangPluginConfig); 129 updateNotificaitonNodeInfo(javaCodeGeneratorInfo, yangPluginConfig);
...@@ -151,7 +146,7 @@ public final class YangJavaModelUtils { ...@@ -151,7 +146,7 @@ public final class YangJavaModelUtils {
151 */ 146 */
152 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() 147 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles()
153 .getBeanTempFiles().addCurNodeLeavesInfoToTempFiles( 148 .getBeanTempFiles().addCurNodeLeavesInfoToTempFiles(
154 - (YangNode) javaCodeGeneratorInfo, yangPluginConfig); 149 + (YangNode) javaCodeGeneratorInfo, yangPluginConfig);
155 } else if (javaCodeGeneratorInfo instanceof YangTypeHolder) { 150 } else if (javaCodeGeneratorInfo instanceof YangTypeHolder) {
156 /* 151 /*
157 * Typedef 152 * Typedef
...@@ -194,11 +189,12 @@ public final class YangJavaModelUtils { ...@@ -194,11 +189,12 @@ public final class YangJavaModelUtils {
194 * Updates notification node info in service temporary file. 189 * Updates notification node info in service temporary file.
195 * 190 *
196 * @param javaCodeGeneratorInfo java code generator info 191 * @param javaCodeGeneratorInfo java code generator info
197 - * @param yangPluginConfig plugin configurations 192 + * @param yangPluginConfig plugin configurations
198 * @throws IOException when fails to do IO operations 193 * @throws IOException when fails to do IO operations
199 */ 194 */
200 private static void updateNotificaitonNodeInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo, 195 private static void updateNotificaitonNodeInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
201 - YangPluginConfig yangPluginConfig) throws IOException { 196 + YangPluginConfig yangPluginConfig)
197 + throws IOException {
202 if ((YangNode) javaCodeGeneratorInfo instanceof YangJavaModule) { 198 if ((YangNode) javaCodeGeneratorInfo instanceof YangJavaModule) {
203 for (YangNode notificaiton : ((YangJavaModule) javaCodeGeneratorInfo).getNotificationNodes()) { 199 for (YangNode notificaiton : ((YangJavaModule) javaCodeGeneratorInfo).getNotificationNodes()) {
204 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() 200 javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles()
...@@ -220,8 +216,8 @@ public final class YangJavaModelUtils { ...@@ -220,8 +216,8 @@ public final class YangJavaModelUtils {
220 * Generates code for the current ata model node and adds itself as an attribute in the parent. 216 * Generates code for the current ata model node and adds itself as an attribute in the parent.
221 * 217 *
222 * @param javaCodeGeneratorInfo YANG java file info node 218 * @param javaCodeGeneratorInfo YANG java file info node
223 - * @param yangPlugin YANG plugin config 219 + * @param yangPlugin YANG plugin config
224 - * @param isMultiInstance flag to indicate whether it's a list 220 + * @param isMultiInstance flag to indicate whether it's a list
225 * @throws IOException IO operations fails 221 * @throws IOException IO operations fails
226 */ 222 */
227 public static void generateCodeAndUpdateInParent(JavaCodeGeneratorInfo javaCodeGeneratorInfo, 223 public static void generateCodeAndUpdateInParent(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
...@@ -246,7 +242,7 @@ public final class YangJavaModelUtils { ...@@ -246,7 +242,7 @@ public final class YangJavaModelUtils {
246 * Generates code for the current data model node and adds support for it to be augmented. 242 * Generates code for the current data model node and adds support for it to be augmented.
247 * 243 *
248 * @param javaCodeGeneratorInfo YANG java file info node 244 * @param javaCodeGeneratorInfo YANG java file info node
249 - * @param yangPlugin YANG plugin config 245 + * @param yangPlugin YANG plugin config
250 * @throws IOException IO operations fails 246 * @throws IOException IO operations fails
251 */ 247 */
252 public static void generateCodeOfAugmentableNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo, 248 public static void generateCodeOfAugmentableNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
...@@ -259,8 +255,9 @@ public final class YangJavaModelUtils { ...@@ -259,8 +255,9 @@ public final class YangJavaModelUtils {
259 generateCodeOfNode(javaCodeGeneratorInfo, yangPlugin); 255 generateCodeOfNode(javaCodeGeneratorInfo, yangPlugin);
260 256
261 /* 257 /*
258 + TODO: Need to use this, when augmentation is added in YMS
262 * For augmentation of nodes. 259 * For augmentation of nodes.
263 - */ 260 +
264 if (javaCodeGeneratorInfo instanceof YangAugmentationHolder) { 261 if (javaCodeGeneratorInfo instanceof YangAugmentationHolder) {
265 JavaQualifiedTypeInfo augmentationHoldersInfo = new JavaQualifiedTypeInfo(); 262 JavaQualifiedTypeInfo augmentationHoldersInfo = new JavaQualifiedTypeInfo();
266 augmentationHoldersInfo.setClassInfo(AUGMENTATION_HOLDER); 263 augmentationHoldersInfo.setClassInfo(AUGMENTATION_HOLDER);
...@@ -276,7 +273,7 @@ public final class YangJavaModelUtils { ...@@ -276,7 +273,7 @@ public final class YangJavaModelUtils {
276 .addToExtendsList(augmentedInfo, (YangNode) javaCodeGeneratorInfo); 273 .addToExtendsList(augmentedInfo, (YangNode) javaCodeGeneratorInfo);
277 274
278 } 275 }
279 - 276 + */
280 if (javaCodeGeneratorInfo instanceof YangCase) { 277 if (javaCodeGeneratorInfo instanceof YangCase) {
281 YangNode parent = ((YangCase) javaCodeGeneratorInfo).getParent(); 278 YangNode parent = ((YangCase) javaCodeGeneratorInfo).getParent();
282 JavaQualifiedTypeInfo parentsInfo = new JavaQualifiedTypeInfo(); 279 JavaQualifiedTypeInfo parentsInfo = new JavaQualifiedTypeInfo();
...@@ -297,7 +294,7 @@ public final class YangJavaModelUtils { ...@@ -297,7 +294,7 @@ public final class YangJavaModelUtils {
297 * Generates code for the current data model node. 294 * Generates code for the current data model node.
298 * 295 *
299 * @param javaCodeGeneratorInfo YANG java file info node 296 * @param javaCodeGeneratorInfo YANG java file info node
300 - * @param yangPluginConfig YANG plugin config 297 + * @param yangPluginConfig YANG plugin config
301 * @throws IOException IO operations fails 298 * @throws IOException IO operations fails
302 */ 299 */
303 public static void generateCodeOfNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo, 300 public static void generateCodeOfNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
...@@ -314,8 +311,8 @@ public final class YangJavaModelUtils { ...@@ -314,8 +311,8 @@ public final class YangJavaModelUtils {
314 * Generates code for the root module/sub-module node. 311 * Generates code for the root module/sub-module node.
315 * 312 *
316 * @param javaCodeGeneratorInfo YANG java file info node 313 * @param javaCodeGeneratorInfo YANG java file info node
317 - * @param yangPluginConfig YANG plugin config 314 + * @param yangPluginConfig YANG plugin config
318 - * @param rootPkg package of the root node 315 + * @param rootPkg package of the root node
319 * @throws IOException IO operations fails 316 * @throws IOException IO operations fails
320 */ 317 */
321 public static void generateCodeOfRootNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo, 318 public static void generateCodeOfRootNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo,
......
...@@ -966,6 +966,7 @@ public final class UtilConstants { ...@@ -966,6 +966,7 @@ public final class UtilConstants {
966 * Static attribute for augmentable. 966 * Static attribute for augmentable.
967 */ 967 */
968 public static final String AUGMENTABLE = "Augmentable"; 968 public static final String AUGMENTABLE = "Augmentable";
969 +
969 /** 970 /**
970 * Static attribute for list. 971 * Static attribute for list.
971 */ 972 */
...@@ -1018,6 +1019,11 @@ public final class UtilConstants { ...@@ -1018,6 +1019,11 @@ public final class UtilConstants {
1018 public static final String COMPONENT_ANNOTATION = "@Component"; 1019 public static final String COMPONENT_ANNOTATION = "@Component";
1019 1020
1020 /** 1021 /**
1022 + * Static attribute for component.
1023 + */
1024 + public static final String COMPONENT = "Component";
1025 +
1026 + /**
1021 * Static attribute for immediate. 1027 * Static attribute for immediate.
1022 */ 1028 */
1023 public static final String IMMEDIATE = "immediate"; 1029 public static final String IMMEDIATE = "immediate";
...@@ -1134,6 +1140,16 @@ public final class UtilConstants { ...@@ -1134,6 +1140,16 @@ public final class UtilConstants {
1134 + "grouping for given uses"; 1140 + "grouping for given uses";
1135 1141
1136 /** 1142 /**
1143 + * Static attribute for reference.
1144 + */
1145 + public static final String REFERENCE = "Reference";
1146 +
1147 + /**
1148 + * Static attribute for ReferenceCardinality.
1149 + */
1150 + public static final String REFERENCE_CARDINALITY = "ReferenceCardinality";
1151 +
1152 + /**
1137 * Creates an instance of util constants. 1153 * Creates an instance of util constants.
1138 */ 1154 */
1139 private UtilConstants() { 1155 private UtilConstants() {
......
...@@ -56,8 +56,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTA ...@@ -56,8 +56,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTA
56 import static org.onosproject.yangutils.utils.UtilConstants.YANG_RESOURCES; 56 import static org.onosproject.yangutils.utils.UtilConstants.YANG_RESOURCES;
57 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents; 57 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents;
58 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; 58 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle;
59 -import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
60 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.PACKAGE_INFO; 59 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.PACKAGE_INFO;
60 +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
61 import static org.slf4j.LoggerFactory.getLogger; 61 import static org.slf4j.LoggerFactory.getLogger;
62 62
63 /** 63 /**
...@@ -67,7 +67,7 @@ public final class YangIoUtils { ...@@ -67,7 +67,7 @@ public final class YangIoUtils {
67 67
68 private static final Logger log = getLogger(YangIoUtils.class); 68 private static final Logger log = getLogger(YangIoUtils.class);
69 private static final String TARGET_RESOURCE_PATH = SLASH + TEMP + SLASH + YANG_RESOURCES + SLASH; 69 private static final String TARGET_RESOURCE_PATH = SLASH + TEMP + SLASH + YANG_RESOURCES + SLASH;
70 - private static final int LINE_SIZE = 116; 70 + private static final int LINE_SIZE = 118;
71 private static final int SUB_LINE_SIZE = 112; 71 private static final int SUB_LINE_SIZE = 112;
72 private static final int ZERO = 0; 72 private static final int ZERO = 0;
73 73
...@@ -92,10 +92,10 @@ public final class YangIoUtils { ...@@ -92,10 +92,10 @@ public final class YangIoUtils {
92 /** 92 /**
93 * Adds package info file for the created directory. 93 * Adds package info file for the created directory.
94 * 94 *
95 - * @param path directory path 95 + * @param path directory path
96 - * @param classInfo class info for the package 96 + * @param classInfo class info for the package
97 - * @param pack package of the directory 97 + * @param pack package of the directory
98 - * @param isChildNode is it a child node 98 + * @param isChildNode is it a child node
99 * @param pluginConfig plugin configurations 99 * @param pluginConfig plugin configurations
100 * @throws IOException when fails to create package info file 100 * @throws IOException when fails to create package info file
101 */ 101 */
...@@ -159,7 +159,8 @@ public final class YangIoUtils { ...@@ -159,7 +159,8 @@ public final class YangIoUtils {
159 * @param dir generated directory in previous build 159 * @param dir generated directory in previous build
160 * @throws IOException when failed to delete directory 160 * @throws IOException when failed to delete directory
161 */ 161 */
162 - public static void deleteDirectory(String dir) throws IOException { 162 + public static void deleteDirectory(String dir)
163 + throws IOException {
163 File generatedDirectory = new File(dir); 164 File generatedDirectory = new File(dir);
164 if (generatedDirectory.exists()) { 165 if (generatedDirectory.exists()) {
165 try { 166 try {
...@@ -177,7 +178,8 @@ public final class YangIoUtils { ...@@ -177,7 +178,8 @@ public final class YangIoUtils {
177 * @param root root directory 178 * @param root root directory
178 * @throws IOException when fails to do IO operations. 179 * @throws IOException when fails to do IO operations.
179 */ 180 */
180 - public static void searchAndDeleteTempDir(String root) throws IOException { 181 + public static void searchAndDeleteTempDir(String root)
182 + throws IOException {
181 List<File> store = new LinkedList<>(); 183 List<File> store = new LinkedList<>();
182 Stack<String> stack = new Stack<>(); 184 Stack<String> stack = new Stack<>();
183 stack.push(root); 185 stack.push(root);
...@@ -207,7 +209,7 @@ public final class YangIoUtils { ...@@ -207,7 +209,7 @@ public final class YangIoUtils {
207 /** 209 /**
208 * Adds generated source directory to the compilation root. 210 * Adds generated source directory to the compilation root.
209 * 211 *
210 - * @param source directory 212 + * @param source directory
211 * @param project current maven project 213 * @param project current maven project
212 * @param context current build context 214 * @param context current build context
213 */ 215 */
...@@ -220,7 +222,7 @@ public final class YangIoUtils { ...@@ -220,7 +222,7 @@ public final class YangIoUtils {
220 /** 222 /**
221 * Removes extra char from the string. 223 * Removes extra char from the string.
222 * 224 *
223 - * @param valueString string to be trimmed 225 + * @param valueString string to be trimmed
224 * @param removealStirng extra chars 226 * @param removealStirng extra chars
225 * @return new string 227 * @return new string
226 */ 228 */
...@@ -255,8 +257,8 @@ public final class YangIoUtils { ...@@ -255,8 +257,8 @@ public final class YangIoUtils {
255 * Returns the directory path of the package in canonical form. 257 * Returns the directory path of the package in canonical form.
256 * 258 *
257 * @param baseCodeGenPath base path where the generated files needs to be 259 * @param baseCodeGenPath base path where the generated files needs to be
258 - * put 260 + * put
259 - * @param pathOfJavaPkg java package of the file being generated 261 + * @param pathOfJavaPkg java package of the file being generated
260 * @return absolute path of the package in canonical form 262 * @return absolute path of the package in canonical form
261 */ 263 */
262 public static String getDirectory(String baseCodeGenPath, String pathOfJavaPkg) { 264 public static String getDirectory(String baseCodeGenPath, String pathOfJavaPkg) {
...@@ -276,8 +278,8 @@ public final class YangIoUtils { ...@@ -276,8 +278,8 @@ public final class YangIoUtils {
276 * Returns the absolute path of the package in canonical form. 278 * Returns the absolute path of the package in canonical form.
277 * 279 *
278 * @param baseCodeGenPath base path where the generated files needs to be 280 * @param baseCodeGenPath base path where the generated files needs to be
279 - * put 281 + * put
280 - * @param pathOfJavaPkg java package of the file being generated 282 + * @param pathOfJavaPkg java package of the file being generated
281 * @return absolute path of the package in canonical form 283 * @return absolute path of the package in canonical form
282 */ 284 */
283 public static String getAbsolutePackagePath(String baseCodeGenPath, String pathOfJavaPkg) { 285 public static String getAbsolutePackagePath(String baseCodeGenPath, String pathOfJavaPkg) {
...@@ -288,8 +290,8 @@ public final class YangIoUtils { ...@@ -288,8 +290,8 @@ public final class YangIoUtils {
288 * Copies YANG files to the current project's output directory. 290 * Copies YANG files to the current project's output directory.
289 * 291 *
290 * @param yangFileInfo list of YANG files 292 * @param yangFileInfo list of YANG files
291 - * @param outputDir project's output directory 293 + * @param outputDir project's output directory
292 - * @param project maven project 294 + * @param project maven project
293 * @throws IOException when fails to copy files to destination resource directory 295 * @throws IOException when fails to copy files to destination resource directory
294 */ 296 */
295 public static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project) 297 public static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project)
...@@ -334,7 +336,8 @@ public final class YangIoUtils { ...@@ -334,7 +336,8 @@ public final class YangIoUtils {
334 * @param srcFile main file 336 * @param srcFile main file
335 * @throws IOException when fails to append contents 337 * @throws IOException when fails to append contents
336 */ 338 */
337 - public static void mergeJavaFiles(File appendFile, File srcFile) throws IOException { 339 + public static void mergeJavaFiles(File appendFile, File srcFile)
340 + throws IOException {
338 try { 341 try {
339 appendFileContents(appendFile, srcFile); 342 appendFileContents(appendFile, srcFile);
340 } catch (IOException e) { 343 } catch (IOException e) {
...@@ -349,7 +352,8 @@ public final class YangIoUtils { ...@@ -349,7 +352,8 @@ public final class YangIoUtils {
349 * @param data data which need to be inserted 352 * @param data data which need to be inserted
350 * @throws IOException when fails to insert into file 353 * @throws IOException when fails to insert into file
351 */ 354 */
352 - public static void insertDataIntoJavaFile(File file, String data) throws IOException { 355 + public static void insertDataIntoJavaFile(File file, String data)
356 + throws IOException {
353 try { 357 try {
354 updateFileHandle(file, data, false); 358 updateFileHandle(file, data, false);
355 } catch (IOException e) { 359 } catch (IOException e) {
...@@ -365,7 +369,8 @@ public final class YangIoUtils { ...@@ -365,7 +369,8 @@ public final class YangIoUtils {
365 * @return updated file 369 * @return updated file
366 * @throws IOException when fails to do IO operations. 370 * @throws IOException when fails to do IO operations.
367 */ 371 */
368 - public static File validateLineLength(File dataFile) throws IOException { 372 + public static File validateLineLength(File dataFile)
373 + throws IOException {
369 File tempFile = dataFile; 374 File tempFile = dataFile;
370 FileReader fileReader = new FileReader(dataFile); 375 FileReader fileReader = new FileReader(dataFile);
371 BufferedReader bufferReader = new BufferedReader(fileReader); 376 BufferedReader bufferReader = new BufferedReader(fileReader);
......
...@@ -19,6 +19,7 @@ package org.onosproject.yangutils.linker; ...@@ -19,6 +19,7 @@ package org.onosproject.yangutils.linker;
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.Iterator; 20 import java.util.Iterator;
21 import java.util.ListIterator; 21 import java.util.ListIterator;
22 +
22 import org.apache.maven.plugin.MojoExecutionException; 23 import org.apache.maven.plugin.MojoExecutionException;
23 import org.junit.Test; 24 import org.junit.Test;
24 import org.onosproject.yangutils.datamodel.YangDataTypes; 25 import org.onosproject.yangutils.datamodel.YangDataTypes;
...@@ -30,12 +31,12 @@ import org.onosproject.yangutils.datamodel.YangNode; ...@@ -30,12 +31,12 @@ import org.onosproject.yangutils.datamodel.YangNode;
30 import org.onosproject.yangutils.datamodel.YangNodeType; 31 import org.onosproject.yangutils.datamodel.YangNodeType;
31 import org.onosproject.yangutils.datamodel.YangTypeDef; 32 import org.onosproject.yangutils.datamodel.YangTypeDef;
32 import org.onosproject.yangutils.datamodel.YangUses; 33 import org.onosproject.yangutils.datamodel.YangUses;
33 -import org.onosproject.yangutils.linker.impl.ResolvableStatus;
34 import org.onosproject.yangutils.linker.impl.YangLinkerManager; 34 import org.onosproject.yangutils.linker.impl.YangLinkerManager;
35 import org.onosproject.yangutils.parser.exceptions.ParserException; 35 import org.onosproject.yangutils.parser.exceptions.ParserException;
36 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 36 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
37 import org.onosproject.yangutils.plugin.manager.YangFileInfo; 37 import org.onosproject.yangutils.plugin.manager.YangFileInfo;
38 import org.onosproject.yangutils.plugin.manager.YangUtilManager; 38 import org.onosproject.yangutils.plugin.manager.YangUtilManager;
39 +import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
39 import org.onosproject.yangutils.utils.io.impl.YangFileScanner; 40 import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
40 41
41 import static org.hamcrest.CoreMatchers.nullValue; 42 import static org.hamcrest.CoreMatchers.nullValue;
...@@ -44,7 +45,8 @@ import static org.hamcrest.core.Is.is; ...@@ -44,7 +45,8 @@ import static org.hamcrest.core.Is.is;
44 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; 45 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
45 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; 46 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
46 import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; 47 import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
47 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.RESOLVED; 48 +import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
49 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
48 50
49 /** 51 /**
50 * Test cases for testing inter file linking. 52 * Test cases for testing inter file linking.
...@@ -186,13 +188,13 @@ public class InterFileLinkingTest { ...@@ -186,13 +188,13 @@ public class InterFileLinkingTest {
186 assertThat(uses.getResolvableStatus(), 188 assertThat(uses.getResolvableStatus(),
187 is(ResolvableStatus.RESOLVED)); 189 is(ResolvableStatus.RESOLVED));
188 190
189 - leafIterator = yangNode.getListOfLeaf().listIterator(); 191 +// leafIterator = yangNode.getListOfLeaf().listIterator();
190 - leafInfo = leafIterator.next(); 192 +// leafInfo = leafIterator.next();
191 - 193 +//
192 - // Check whether the information in the leaf is correct under module. 194 +// // Check whether the information in the leaf is correct under module.
193 - assertThat(leafInfo.getName(), is("hello")); 195 +// assertThat(leafInfo.getName(), is("hello"));
194 - assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); 196 +// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
195 - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); 197 +// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
196 } 198 }
197 199
198 /** 200 /**
...@@ -332,13 +334,13 @@ public class InterFileLinkingTest { ...@@ -332,13 +334,13 @@ public class InterFileLinkingTest {
332 assertThat(uses.getResolvableStatus(), 334 assertThat(uses.getResolvableStatus(),
333 is(ResolvableStatus.RESOLVED)); 335 is(ResolvableStatus.RESOLVED));
334 336
335 - leafIterator = yangNode.getListOfLeaf().listIterator(); 337 +// leafIterator = yangNode.getListOfLeaf().listIterator();
336 - leafInfo = leafIterator.next(); 338 +// leafInfo = leafIterator.next();
337 - 339 +//
338 - // Check whether the information in the leaf is correct under module. 340 +// // Check whether the information in the leaf is correct under module.
339 - assertThat(leafInfo.getName(), is("hello")); 341 +// assertThat(leafInfo.getName(), is("hello"));
340 - assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); 342 +// assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
341 - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); 343 +// assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
342 } 344 }
343 345
344 /** 346 /**
...@@ -599,4 +601,117 @@ public class InterFileLinkingTest { ...@@ -599,4 +601,117 @@ public class InterFileLinkingTest {
599 assertThat(derivedInfo.getPatternRestriction(), is(nullValue())); 601 assertThat(derivedInfo.getPatternRestriction(), is(nullValue()));
600 assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue())); 602 assertThat(derivedInfo.getResolvedExtendedInfo(), is(nullValue()));
601 } 603 }
604 +
605 + /**
606 + * Checks hierarchical intra with inter file type linking.
607 + */
608 + @Test
609 + public void interFileWithUsesReferringType()
610 + throws IOException, ParserException, MojoExecutionException {
611 +
612 + String searchDir = "src/test/resources/interfilewithusesreferringtype";
613 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
614 + utilManager.parseYangFileInfoSet();
615 + utilManager.resolveDependenciesUsingLinker();
616 +
617 + String userDir = System.getProperty("user.dir");
618 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
619 + yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/");
620 +
621 + utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
622 +
623 + deleteDirectory(userDir + "/target/interfilewithusesreferringtype/");
624 +
625 + }
626 +
627 + /**
628 + * Checks hierarchical intra with inter file type linking.
629 + */
630 + @Test
631 + public void file1UsesFile2TypeDefFile3Type()
632 + throws IOException, ParserException, MojoExecutionException {
633 +
634 + String searchDir = "src/test/resources/file1UsesFile2TypeDefFile3Type";
635 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
636 + utilManager.parseYangFileInfoSet();
637 + utilManager.resolveDependenciesUsingLinker();
638 +
639 + String userDir = System.getProperty("user.dir");
640 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
641 + yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/");
642 +
643 + utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
644 +
645 + deleteDirectory(userDir + "/target/file1UsesFile2TypeDefFile3Type/");
646 +
647 + }
648 +
649 +
650 + /**
651 + * Checks hierarchical intra with inter file type linking.
652 + */
653 + @Test
654 + public void interFileIetf()
655 + throws IOException, ParserException, MojoExecutionException {
656 +
657 + String searchDir = "src/test/resources/interfileietf";
658 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
659 + utilManager.parseYangFileInfoSet();
660 + utilManager.resolveDependenciesUsingLinker();
661 +
662 + String userDir = System.getProperty("user.dir");
663 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
664 + yangPluginConfig.setCodeGenDir("target/interfileietf/");
665 +
666 + utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
667 +
668 + deleteDirectory(userDir + "/target/interfileietf/");
669 +
670 + }
671 +
672 +
673 + /**
674 + * Checks hierarchical intra with inter file type linking.
675 + */
676 + @Test
677 + public void usesInContainer()
678 + throws IOException, ParserException, MojoExecutionException {
679 +
680 + String searchDir = "src/test/resources/usesInContainer";
681 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
682 + utilManager.parseYangFileInfoSet();
683 + utilManager.resolveDependenciesUsingLinker();
684 +
685 + String userDir = System.getProperty("user.dir");
686 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
687 + yangPluginConfig.setCodeGenDir("target/usesInContainer/");
688 +
689 + utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
690 +
691 + deleteDirectory(userDir + "/target/usesInContainer/");
692 +
693 + }
694 +
695 +
696 + /**
697 + * Checks hierarchical intra with inter file type linking.
698 + */
699 + @Test
700 + public void groupingNodeSameAsModule()
701 + throws IOException, ParserException, MojoExecutionException {
702 +
703 + String searchDir = "src/test/resources/groupingNodeSameAsModule";
704 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
705 + utilManager.parseYangFileInfoSet();
706 + utilManager.resolveDependenciesUsingLinker();
707 +
708 + String userDir = System.getProperty("user.dir");
709 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
710 + yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/");
711 +
712 + utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
713 +
714 + deleteDirectory(userDir + "/target/groupingNodeSameAsModule/");
715 +
716 + }
602 } 717 }
......
...@@ -33,12 +33,12 @@ import static org.hamcrest.CoreMatchers.nullValue; ...@@ -33,12 +33,12 @@ import static org.hamcrest.CoreMatchers.nullValue;
33 import static org.hamcrest.MatcherAssert.assertThat; 33 import static org.hamcrest.MatcherAssert.assertThat;
34 import static org.hamcrest.core.Is.is; 34 import static org.hamcrest.core.Is.is;
35 import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY; 35 import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY;
36 +import static org.onosproject.yangutils.linker.ResolvableStatus.INTRA_FILE_RESOLVED;
37 +import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
36 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; 38 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
37 import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32; 39 import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
38 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; 40 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
39 import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; 41 import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
40 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.INTRA_FILE_RESOLVED;
41 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.RESOLVED;
42 42
43 /** 43 /**
44 * Test cases for testing "type" intra file linking. 44 * Test cases for testing "type" intra file linking.
......
...@@ -40,11 +40,11 @@ import static org.hamcrest.CoreMatchers.nullValue; ...@@ -40,11 +40,11 @@ import static org.hamcrest.CoreMatchers.nullValue;
40 import static org.hamcrest.MatcherAssert.assertThat; 40 import static org.hamcrest.MatcherAssert.assertThat;
41 import static org.hamcrest.core.Is.is; 41 import static org.hamcrest.core.Is.is;
42 import static org.hamcrest.core.IsNull.notNullValue; 42 import static org.hamcrest.core.IsNull.notNullValue;
43 +import static org.onosproject.yangutils.linker.ResolvableStatus.RESOLVED;
43 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED; 44 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
44 import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32; 45 import static org.onosproject.yangutils.datamodel.YangDataTypes.INT32;
45 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING; 46 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
46 import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE; 47 import static org.onosproject.yangutils.datamodel.YangNodeType.MODULE_NODE;
47 -import static org.onosproject.yangutils.linker.impl.ResolvableStatus.RESOLVED;
48 48
49 /** 49 /**
50 * Test cases for testing restriction resolution. 50 * Test cases for testing restriction resolution.
......
...@@ -32,6 +32,7 @@ public class TreeWalkListenerTest { ...@@ -32,6 +32,7 @@ public class TreeWalkListenerTest {
32 32
33 @Rule 33 @Rule
34 public ExpectedException thrown = ExpectedException.none(); 34 public ExpectedException thrown = ExpectedException.none();
35 +
35 /** 36 /**
36 * Checks whether exception is thrown for ordered statement. 37 * Checks whether exception is thrown for ordered statement.
37 */ 38 */
......
...@@ -18,6 +18,7 @@ package org.onosproject.yangutils.parser.impl.listeners; ...@@ -18,6 +18,7 @@ package org.onosproject.yangutils.parser.impl.listeners;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.ListIterator; 20 import java.util.ListIterator;
21 +
21 import org.junit.Test; 22 import org.junit.Test;
22 import org.onosproject.yangutils.datamodel.YangDataTypes; 23 import org.onosproject.yangutils.datamodel.YangDataTypes;
23 import org.onosproject.yangutils.datamodel.YangLeaf; 24 import org.onosproject.yangutils.datamodel.YangLeaf;
......
1 + module ietf-inet-types {
2 +
3 + yang-version 1;
4 +
5 + namespace
6 + "urn:ietf:params:xml:ns:yang:ietf-inet-types";
7 +
8 + prefix inet;
9 + typedef uri {
10 + type string;
11 + }
12 + }
1 + module ietf-network-topology {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
4 + prefix lnk;
5 +
6 + import ietf-inet-types {
7 + prefix inet;
8 + }
9 +
10 + typedef tp-id {
11 + type inet:uri;
12 + description
13 + "An identifier for termination points on a node.
14 + The identifier SHOULD be chosen such that the same TP in a
15 + real network topology will always be identified through the
16 + same identifier, even if the model is instantiated in
17 + separate datastores. An implementation MAY choose to capture
18 + semantics in the identifier, for example to indicate the type
19 + of TP and/or the type of node and topology that the TP is a
20 + part of.";
21 + }
22 +
23 + grouping tp-ref {
24 + description
25 + "References a termination point in a specific node.";
26 + leaf tp-ref {
27 + type tp-id;
28 + description
29 + "A type for an absolute reference to a termination point.
30 + (This type should not be used for relative references.
31 + In such a case, a relative path should be used instead.)";
32 + }
33 + }
34 + }
1 + module ietf-te-topology {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
4 + // replace with IANA namespace when assigned
5 +
6 + prefix "tet";
7 +
8 + import ietf-network-topology {
9 + prefix "nt";
10 + }
11 +
12 + container underlay-trail-src {
13 + uses nt:tp-ref;
14 + description
15 + "Source TE link of the underlay trail.";
16 + }
17 + }
1 +module port-pair {
2 +
3 + yang-version 1;
4 +
5 + namespace "sfc.portpair";
6 +
7 + prefix "port-pair";
8 +
9 + grouping port-pair {
10 + container port-pair {
11 +
12 + leaf name {
13 + type string;
14 + }
15 +
16 +
17 + leaf description {
18 + type string;
19 + }
20 +
21 + }
22 + }
23 +
24 + rpc get-port-pair {
25 + output {
26 + uses port-pair;
27 + }
28 + }
29 +}
1 + module ietf-network-topology {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network-topology";
4 + prefix lnk;
5 +
6 + import ietf-inet-types {
7 + prefix inet;
8 + }
9 + import ietf-network {
10 + prefix nd;
11 + }
12 +
13 + organization
14 + "IETF I2RS (Interface to the Routing System) Working Group";
15 +
16 + contact
17 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
18 + WG List: <mailto:i2rs@ietf.org>
19 +
20 + WG Chair: Susan Hares
21 + <mailto:shares@ndzh.com>
22 +
23 + WG Chair: Jeffrey Haas
24 + <mailto:jhaas@pfrc.org>
25 +
26 + Editor: Alexander Clemm
27 + <mailto:alex@cisco.com>
28 +
29 + Editor: Jan Medved
30 + <mailto:jmedved@cisco.com>
31 +
32 + Editor: Robert Varga
33 + <mailto:rovarga@cisco.com>
34 +
35 + Editor: Tony Tkacik
36 + <mailto:ttkacik@cisco.com>
37 +
38 + Editor: Nitin Bahadur
39 + <mailto:nitin_bahadur@yahoo.com>
40 +
41 + Editor: Hariharan Ananthakrishnan
42 + <mailto:hari@packetdesign.com>";
43 +
44 + description
45 + "This module defines a common base model for network topology,
46 + augmenting the base network model with links to connect nodes,
47 + as well as termination points to terminate links on nodes.
48 +
49 + Copyright (c) 2015 IETF Trust and the persons identified as
50 + authors of the code. All rights reserved.
51 +
52 + Redistribution and use in source and binary forms, with or
53 + without modification, is permitted pursuant to, and subject
54 + to the license terms contained in, the Simplified BSD License
55 + set forth in Section 4.c of the IETF Trust's Legal Provisions
56 + Relating to IETF Documents
57 + (http://trustee.ietf.org/license-info).
58 +
59 + This version of this YANG module is part of
60 + draft-ietf-i2rs-yang-network-topo-02;
61 + see the RFC itself for full legal notices.
62 +
63 + NOTE TO RFC EDITOR: Please replace above reference to
64 + draft-ietf-i2rs-yang-network-topo-02 with RFC
65 + number when published (i.e. RFC xxxx).";
66 +
67 + revision 2015-12-08 {
68 + description
69 + "Initial revision.
70 + NOTE TO RFC EDITOR: Please replace the following reference
71 + to draft-ietf-i2rs-yang-network-topo-02 with
72 + RFC number when published (i.e. RFC xxxx).";
73 + reference
74 + "draft-ietf-i2rs-yang-network-topo-02.";
75 + }
76 +
77 + typedef link-id {
78 + type inet:uri;
79 + description
80 + "An identifier for a link in a topology.
81 + The identifier SHOULD be chosen such that the same link in a
82 + real network topology will always be identified through the
83 + same identifier, even if the model is instantiated in
84 + separate datastores. An implementation MAY choose to capture
85 + semantics in the identifier, for example to indicate the type
86 + of link and/or the type of topology that the link is a part
87 + of.";
88 + }
89 +
90 + typedef tp-id {
91 + type inet:uri;
92 + description
93 + "An identifier for termination points on a node.
94 + The identifier SHOULD be chosen such that the same TP in a
95 + real network topology will always be identified through the
96 + same identifier, even if the model is instantiated in
97 + separate datastores. An implementation MAY choose to capture
98 + semantics in the identifier, for example to indicate the type
99 + of TP and/or the type of node and topology that the TP is a
100 + part of.";
101 + }
102 + grouping link-ref {
103 + description
104 + "References a link in a specific network.";
105 + leaf link-ref {
106 + type link-id;
107 + description
108 + "A type for an absolute reference a link instance.
109 + (This type should not be used for relative references.
110 + In such a case, a relative path should be used instead.)";
111 + }
112 + uses nd:network-ref;
113 + }
114 +
115 + grouping tp-ref {
116 + description
117 + "References a termination point in a specific node.";
118 + leaf tp-ref {
119 + type tp-id;
120 + description
121 + "A type for an absolute reference to a termination point.
122 + (This type should not be used for relative references.
123 + In such a case, a relative path should be used instead.)";
124 + }
125 + uses nd:node-ref;
126 + }
127 +
128 + augment "/nd:networks/nd:network" {
129 + description
130 + "Add links to the network model.";
131 + list link {
132 + key "link-id";
133 + description
134 + "A Network Link connects a by Local (Source) node and
135 + a Remote (Destination) Network Nodes via a set of the
136 + nodes' termination points.
137 + As it is possible to have several links between the same
138 + source and destination nodes, and as a link could
139 + potentially be re-homed between termination points, to
140 + ensure that we would always know to distinguish between
141 + links, every link is identified by a dedicated link
142 + identifier.
143 + Note that a link models a point-to-point link, not a
144 + multipoint link.
145 + Layering dependencies on links in underlay topologies are
146 + not represented as the layering information of nodes and of
147 + termination points is sufficient.";
148 + container source {
149 + description
150 + "This container holds the logical source of a particular
151 + link.";
152 + leaf source-node {
153 + type nd:node-id;
154 + mandatory true;
155 + description
156 + "Source node identifier, must be in same topology.";
157 + }
158 + leaf source-tp {
159 + type tp-id;
160 + description
161 + "Termination point within source node that terminates
162 + the link.";
163 + }
164 + }
165 + container destination {
166 + description
167 + "This container holds the logical destination of a
168 + particular link.";
169 + leaf dest-node {
170 + type nd:node-id;
171 + mandatory true;
172 + description
173 + "Destination node identifier, must be in the same
174 + network.";
175 + }
176 + leaf dest-tp {
177 + type tp-id;
178 + description
179 + "Termination point within destination node that
180 + terminates the link.";
181 + }
182 + }
183 + leaf link-id {
184 + type link-id;
185 + description
186 + "The identifier of a link in the topology.
187 + A link is specific to a topology to which it belongs.";
188 + }
189 + list supporting-link {
190 + key "network-ref link-ref";
191 + description
192 + "Identifies the link, or links, that this link
193 + is dependent on.";
194 + leaf network-ref {
195 + type nd:network-id;
196 + description
197 + "This leaf identifies in which underlay topology
198 + supporting link is present.";
199 + }
200 + leaf link-ref {
201 + type link-id;
202 + description
203 + "This leaf identifies a link which is a part
204 + of this link's underlay. Reference loops, in which
205 + a link identifies itself as its underlay, either
206 + directly or transitively, are not allowed.";
207 + }
208 + }
209 + }
210 + }
211 + augment "/nd:networks/nd:network/nd:node" {
212 + description
213 + "Augment termination points which terminate links.
214 + Termination points can ultimately be mapped to interfaces.";
215 + list termination-point {
216 + key "tp-id";
217 + description
218 + "A termination point can terminate a link.
219 + Depending on the type of topology, a termination point
220 + could, for example, refer to a port or an interface.";
221 + leaf tp-id {
222 + type tp-id;
223 + description
224 + "Termination point identifier.";
225 + }
226 + list supporting-termination-point {
227 + key "network-ref node-ref tp-ref";
228 + description
229 + "The leaf list identifies any termination points that
230 + the termination point is dependent on, or maps onto.
231 + Those termination points will themselves be contained
232 + in a supporting node.
233 + This dependency information can be inferred from
234 + the dependencies between links. For this reason,
235 + this item is not separately configurable. Hence no
236 + corresponding constraint needs to be articulated.
237 + The corresponding information is simply provided by the
238 + implementing system.";
239 + leaf network-ref {
240 + type nd:network-id;
241 + description
242 + "This leaf identifies in which topology the
243 + supporting termination point is present.";
244 + }
245 + leaf node-ref {
246 + type nd:node-id;
247 + description
248 + "This leaf identifies in which node the supporting
249 + termination point is present.";
250 + }
251 + leaf tp-ref {
252 + type tp-id;
253 + description
254 + "Reference to the underlay node, must be in a
255 + different topology";
256 + }
257 + }
258 + }
259 + }
260 + }
1 + module ietf-network {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 + prefix nd;
5 +
6 + import ietf-inet-types {
7 + prefix inet;
8 + }
9 +
10 + organization
11 + "IETF I2RS (Interface to the Routing System) Working Group";
12 +
13 + contact
14 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
15 + WG List: <mailto:i2rs@ietf.org>
16 +
17 + WG Chair: Susan Hares
18 + <mailto:shares@ndzh.com>
19 +
20 + WG Chair: Jeffrey Haas
21 + <mailto:jhaas@pfrc.org>
22 +
23 + Editor: Alexander Clemm
24 + <mailto:alex@cisco.com>
25 +
26 + Editor: Jan Medved
27 + <mailto:jmedved@cisco.com>
28 +
29 + Editor: Robert Varga
30 + <mailto:rovarga@cisco.com>
31 +
32 + Editor: Tony Tkacik
33 + <mailto:ttkacik@cisco.com>
34 +
35 + Editor: Nitin Bahadur
36 + <mailto:nitin_bahadur@yahoo.com>
37 +
38 + Editor: Hariharan Ananthakrishnan
39 + <mailto:hari@packetdesign.com>";
40 +
41 + description
42 + "This module defines a common base model for a collection
43 + of nodes in a network. Node definitions are further used
44 + in network topologies and inventories.
45 +
46 + Copyright (c) 2015 IETF Trust and the persons identified as
47 + authors of the code. All rights reserved.
48 +
49 + Redistribution and use in source and binary forms, with or
50 + without modification, is permitted pursuant to, and subject
51 + to the license terms contained in, the Simplified BSD License
52 + set forth in Section 4.c of the IETF Trust's Legal Provisions
53 + Relating to IETF Documents
54 + (http://trustee.ietf.org/license-info).
55 +
56 + This version of this YANG module is part of
57 + draft-ietf-i2rs-yang-network-topo-02;
58 + see the RFC itself for full legal notices.
59 +
60 + NOTE TO RFC EDITOR: Please replace above reference to
61 + draft-ietf-i2rs-yang-network-topo-02 with RFC
62 + number when published (i.e. RFC xxxx).";
63 +
64 + revision 2015-12-08 {
65 + description
66 + "Initial revision.
67 + NOTE TO RFC EDITOR: Please replace the following reference
68 + to draft-ietf-i2rs-yang-network-topo-02 with
69 + RFC number when published (i.e. RFC xxxx).";
70 + reference
71 + "draft-ietf-i2rs-yang-network-topo-02";
72 + }
73 +
74 + typedef node-id {
75 + type inet:uri;
76 + description
77 + "Identifier for a node.";
78 + }
79 +
80 + typedef network-id {
81 + type inet:uri;
82 + description
83 + "Identifier for a network.";
84 + }
85 + grouping network-ref {
86 + description
87 + "Contains the information necessary to reference a network,
88 + for example an underlay network.";
89 + leaf network-ref {
90 + type network-id;
91 + description
92 + "Used to reference a network, for example an underlay
93 + network.";
94 + }
95 + }
96 +
97 + grouping node-ref {
98 + description
99 + "Contains the information necessary to reference a node.";
100 + leaf node-ref {
101 + type node-id;
102 + description
103 + "Used to reference a node.
104 + Nodes are identified relative to the network they are
105 + contained in.";
106 + }
107 + uses network-ref;
108 + }
109 +
110 + container networks {
111 + description
112 + "Serves as top-level container for a list of networks.";
113 + list network {
114 + key "network-id";
115 + description
116 + "Describes a network.
117 + A network typically contains an inventory of nodes,
118 + topological information (augmented through
119 + network-topology model), as well as layering
120 + information.";
121 + container network-types {
122 + description
123 + "Serves as an augmentation target.
124 + The network type is indicated through corresponding
125 + presence containers augmented into this container.";
126 + }
127 + leaf network-id {
128 + type network-id;
129 + description
130 + "Identifies a network.";
131 + }
132 + list supporting-network {
133 + key "network-ref";
134 + description
135 + "An underlay network, used to represent layered network
136 + topologies.";
137 + leaf network-ref {
138 + type network-id;
139 + description
140 + "References the underlay network.";
141 + }
142 + }
143 + list node {
144 + key "node-id";
145 + description
146 + "The inventory of nodes of this network.";
147 + leaf node-id {
148 + type node-id;
149 + description
150 + "Identifies a node uniquely within the containing
151 + network.";
152 + }
153 + list supporting-node {
154 + key "network-ref node-ref";
155 + description
156 + "Represents another node, in an underlay network, that
157 + this node is supported by. Used to represent layering
158 + structure.";
159 + leaf network-ref {
160 + type network-id;
161 + description
162 + "References the underlay network that the
163 + underlay node is part of.";
164 + }
165 + leaf node-ref {
166 + type node-id;
167 + description
168 + "References the underlay node itself.";
169 + }
170 + }
171 + }
172 + }
173 + }
174 + container networks-state {
175 + config false;
176 + description
177 + "Serves as top-level container for a list of state information
178 + for networks";
179 + list network {
180 + key "network-ref";
181 + description
182 + "Data nodes representing operational data and state of
183 + networks.
184 + An instance is automatically created for every network
185 + in the corresponding list under the networks container.";
186 + uses network-ref;
187 + leaf server-provided {
188 + type boolean;
189 + description
190 + "Indicates whether the information concerning this
191 + particular network is populated by the server
192 + (server-provided true, the general case for network
193 + information discovered from the server),
194 + or whether it is configured by a client
195 + (server-provided true, possible e.g. for
196 + service overlays managed through a controller).";
197 + }
198 + }
199 + }
200 + }
1 + module ietf-schedule {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-schedule";
4 + // replace with IANA namespace when assigned
5 +
6 + prefix "sch";
7 +
8 + import ietf-yang-types {
9 + prefix "yang";
10 + }
11 +
12 + organization "TBD";
13 + contact "TBD";
14 + description
15 + "The model allows time scheduling parameters to be specified.";
16 +
17 + revision "2016-03-01" {
18 + description "Initial revision";
19 + reference "TBD";
20 + }
21 +
22 + /*
23 + * Groupings
24 + */
25 +
26 + grouping schedules {
27 + description
28 + "A list of schedules defining when a particular
29 + configuration takes effect.";
30 + container schedules {
31 + description
32 + "Container of a schedule list defining when a particular
33 + configuration takes effect.";
34 + list schedule {
35 + key "schedule-id";
36 + description "A list of schedule elements.";
37 +
38 + leaf schedule-id {
39 + type uint32;
40 + description "Identifies the schedule element.";
41 + }
42 + leaf start {
43 + type yang:date-and-time;
44 + description "Start time.";
45 + }
46 + leaf schedule-duration {
47 + type string {
48 + pattern
49 + 'P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?(\d+S)?';
50 + }
51 + description "Schedule duration in ISO 8601 format.";
52 + }
53 + leaf repeat-interval {
54 + type string {
55 + pattern
56 + 'R\d*/P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?'
57 + + '(\d+S)?';
58 + }
59 + description "Repeat interval in ISO 8601 format.";
60 + }
61 + }
62 + }
63 + } // schedules
64 + }
1 + module ietf-network {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 + prefix nd;
5 +
6 + container networks {
7 + container network-types {
8 + description
9 + "Serves as an augmentation target.
10 + The network type is indicated through corresponding
11 + presence containers augmented into this container.";
12 + }
13 + }
14 +}
1 + module ietf-te-topology {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-te-topology";
4 + // replace with IANA namespace when assigned
5 +
6 + prefix "tet";
7 +
8 + import ietf-network {
9 + prefix "nw";
10 + }
11 +
12 + grouping te-topologies-augment {
13 + description
14 + "Augmentation for TE topologies.";
15 + leaf reference-change-policy {
16 + type enumeration {
17 + enum no-action {
18 + description
19 + "When an attribute changes in this template, the
20 + configuration node referring to this template does
21 + not take any action.";
22 + }
23 + enum not-allowed {
24 + description
25 + "When any configuration object has a reference to this
26 + template, changing this template is not allowed.";
27 + }
28 + enum cascade {
29 + description
30 + "When an attribute changes in this template, the
31 + configuration object referring to this template applies
32 + the new attribute value to the corresponding
33 + configuration.";
34 + }
35 + }
36 + description
37 + "This attribute specifies the action taken to a configuration
38 + node that has a reference to this template.";
39 + }
40 + } // te-topologies-augment
41 +
42 +
43 +
44 + augment "/nw:networks" {
45 + description
46 + "Augmentation parameters for TE topologies.";
47 + uses te-topologies-augment;
48 + }
49 +
50 +
51 +}
1 +
2 +module ietf-sd-onos-service-types {
3 +
4 + namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-service-types";
5 + prefix service-types ;
6 +
7 + grouping qos-if-car {
8 + description "qos parameter." ;
9 + list qos-if-car {
10 + key "direction";
11 + description "cars qos policy." ;
12 + leaf direction {
13 + type enumeration {
14 + enum inbound{
15 + value 0 ;
16 + description "inbound." ;
17 + }
18 + enum outbound {
19 + value 1 ;
20 + description "outbound." ;
21 + }
22 + }
23 + description "qos for interface car" ;
24 + }
25 +}
26 +}
27 +
28 + container qos-policy {
29 + description "The qos policy of the vpn service." ;
30 + container qos-if-cars {
31 + description "qos policy if car." ;
32 + list qos-if-car {
33 + key "direction";
34 + uses qos-if-car;
35 + description "List of qos parameters." ;
36 + }
37 + }
38 + }
39 +
40 + rpc close-l3vpn {
41 + description "Close l3vpn." ;
42 + input {
43 + leaf l3vpn-id {
44 + type string;
45 + description "vpn id." ;
46 + }
47 + container ac-status {
48 + description "Access status of the vpn." ;
49 + list acs{
50 + key "id";
51 + description "Access information." ;
52 + leaf id {
53 + type string;
54 + description "Access id." ;
55 + }
56 + leaf admin-status {
57 + type string;
58 + description "Administration status." ;
59 + }
60 + }
61 + }
62 + }
63 + }
64 +}