Bharat saraswal
Committed by Patrick Liu

[ONOS-4839] update file priority for translator and OP param file impl defect fix

Change-Id: Ieaef43f915996ed0a34dfa17c338ab612716b2bc
Showing 44 changed files with 539 additions and 302 deletions
...@@ -32,6 +32,11 @@ public class YangAtomicPath implements Serializable { ...@@ -32,6 +32,11 @@ public class YangAtomicPath implements Serializable {
32 private List<YangPathPredicate> pathPredicatesList; 32 private List<YangPathPredicate> pathPredicatesList;
33 33
34 /** 34 /**
35 + * Resolved node for the absolute path.
36 + */
37 + private YangNode resolvedNode;
38 +
39 + /**
35 * Returns the node identifier. 40 * Returns the node identifier.
36 * 41 *
37 * @return the node identifier 42 * @return the node identifier
...@@ -75,4 +80,23 @@ public class YangAtomicPath implements Serializable { ...@@ -75,4 +80,23 @@ public class YangAtomicPath implements Serializable {
75 public void addLeavesPredicate(YangPathPredicate predicatesExp) { 80 public void addLeavesPredicate(YangPathPredicate predicatesExp) {
76 getPathPredicatesList().add(predicatesExp); 81 getPathPredicatesList().add(predicatesExp);
77 } 82 }
83 +
84 +
85 + /**
86 + * Returns resolved node.
87 + *
88 + * @return resolved node
89 + */
90 + public YangNode getResolvedNode() {
91 + return resolvedNode;
92 + }
93 +
94 + /**
95 + * Sets resolved node.
96 + *
97 + * @param resolvedNode resolved node
98 + */
99 + public void setResolvedNode(YangNode resolvedNode) {
100 + this.resolvedNode = resolvedNode;
101 + }
78 } 102 }
......
...@@ -15,10 +15,8 @@ ...@@ -15,10 +15,8 @@
15 */ 15 */
16 package org.onosproject.yangutils.datamodel; 16 package org.onosproject.yangutils.datamodel;
17 17
18 -import java.util.HashMap;
19 import java.util.LinkedList; 18 import java.util.LinkedList;
20 import java.util.List; 19 import java.util.List;
21 -import java.util.Map;
22 20
23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
24 import org.onosproject.yangutils.datamodel.utils.Parsable; 22 import org.onosproject.yangutils.datamodel.utils.Parsable;
...@@ -130,11 +128,6 @@ public class YangAugment ...@@ -130,11 +128,6 @@ public class YangAugment
130 private YangNode augmentedNode; 128 private YangNode augmentedNode;
131 129
132 /** 130 /**
133 - * All resolved nodes in given xPath.
134 - */
135 - private Map<YangAtomicPath, YangNode> resolveNodeInPath;
136 -
137 - /**
138 * Status of resolution. If completely resolved enum value is "RESOLVED", if not enum value is "UNRESOLVED", in case 131 * Status of resolution. If completely resolved enum value is "RESOLVED", if not enum value is "UNRESOLVED", in case
139 * reference of grouping/typedef is added to uses/type but it's not resolved value of enum should be 132 * reference of grouping/typedef is added to uses/type but it's not resolved value of enum should be
140 * "INTRA_FILE_RESOLVED". 133 * "INTRA_FILE_RESOLVED".
...@@ -156,7 +149,6 @@ public class YangAugment ...@@ -156,7 +149,6 @@ public class YangAugment
156 */ 149 */
157 public YangAugment() { 150 public YangAugment() {
158 super(YangNodeType.AUGMENT_NODE); 151 super(YangNodeType.AUGMENT_NODE);
159 - resolveNodeInPath = new HashMap<>();
160 resolvableStatus = ResolvableStatus.UNRESOLVED; 152 resolvableStatus = ResolvableStatus.UNRESOLVED;
161 } 153 }
162 154
...@@ -447,21 +439,4 @@ public class YangAugment ...@@ -447,21 +439,4 @@ public class YangAugment
447 return null; 439 return null;
448 } 440 }
449 441
450 - /**
451 - * Returns all resolved node in path.
452 - *
453 - * @return all resolved node in path
454 - */
455 - public Map<YangAtomicPath, YangNode> getResolveNodeInPath() {
456 - return resolveNodeInPath;
457 - }
458 -
459 - /**
460 - * Sets all resolved node in path.
461 - *
462 - * @param resolveNodeInPath all resolved node in path
463 - */
464 - public void setResolveNodeInPath(Map<YangAtomicPath, YangNode> resolveNodeInPath) {
465 - this.resolveNodeInPath = resolveNodeInPath;
466 - }
467 } 442 }
......
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 +package org.onosproject.yangutils.datamodel;
17 +
18 +/**
19 + * Abstraction of an entity which represent operation parameter info for augmentable node.
20 + */
21 +public interface YangAugmentedOpParamInfo extends YangAugmentedInfo {
22 +
23 + /**
24 + * Returns class object of base class.
25 + *
26 + * @return class object of base class
27 + */
28 + Class<?> getBaseClass();
29 +
30 + /**
31 + * Returns if augmented info's contents matches.
32 + *
33 + * @param augmentedInfo augmented info
34 + * @return true or false
35 + */
36 + boolean isFilterContentMatch(Object augmentedInfo);
37 +}
...@@ -79,7 +79,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -79,7 +79,7 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
79 */ 79 */
80 public class YangGrouping 80 public class YangGrouping
81 extends YangNode 81 extends YangNode
82 - implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector { 82 + implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangTranslatorOperatorNode {
83 83
84 private static final long serialVersionUID = 806201607L; 84 private static final long serialVersionUID = 806201607L;
85 85
......
...@@ -64,6 +64,11 @@ public abstract class YangNode ...@@ -64,6 +64,11 @@ public abstract class YangNode
64 private int priority; 64 private int priority;
65 65
66 /** 66 /**
67 + * Flag if the node is for translation.
68 + */
69 + private boolean isToTranslate = true;
70 +
71 + /**
67 * Returns the priority of the node. 72 * Returns the priority of the node.
68 * 73 *
69 * @return priority of the node 74 * @return priority of the node
...@@ -268,6 +273,7 @@ public abstract class YangNode ...@@ -268,6 +273,7 @@ public abstract class YangNode
268 /** 273 /**
269 * Clones the current node contents and create a new node. 274 * Clones the current node contents and create a new node.
270 * 275 *
276 + * @param yangUses YANG uses
271 * @return cloned node 277 * @return cloned node
272 * @throws CloneNotSupportedException clone is not supported by the referred 278 * @throws CloneNotSupportedException clone is not supported by the referred
273 * node 279 * node
...@@ -297,6 +303,7 @@ public abstract class YangNode ...@@ -297,6 +303,7 @@ public abstract class YangNode
297 * 303 *
298 * @param srcRootNode source node for sub tree cloning 304 * @param srcRootNode source node for sub tree cloning
299 * @param dstRootNode destination node where the sub tree needs to be cloned 305 * @param dstRootNode destination node where the sub tree needs to be cloned
306 + * @param yangUses YANG uses
300 * @throws DataModelException data model error 307 * @throws DataModelException data model error
301 */ 308 */
302 public static void cloneSubTree(YangNode srcRootNode, YangNode dstRootNode, YangUses yangUses) 309 public static void cloneSubTree(YangNode srcRootNode, YangNode dstRootNode, YangUses yangUses)
...@@ -411,6 +418,24 @@ public abstract class YangNode ...@@ -411,6 +418,24 @@ public abstract class YangNode
411 } 418 }
412 419
413 /** 420 /**
421 + * /** Returns true if translation required.
422 + *
423 + * @return true if translation required
424 + */
425 + public boolean isToTranslate() {
426 + return isToTranslate;
427 + }
428 +
429 + /**
430 + * Sest true if translation required.
431 + *
432 + * @param toTranslate true if translation required.
433 + */
434 + public void setToTranslate(boolean toTranslate) {
435 + isToTranslate = toTranslate;
436 + }
437 +
438 + /**
414 * Adds a new next sibling. 439 * Adds a new next sibling.
415 * 440 *
416 * @param newSibling new sibling to be added 441 * @param newSibling new sibling to be added
......
1 +
2 +/*
3 + * Copyright 2016-present Open Networking Laboratory
4 + *
5 + * Licensed under the Apache License, Version 2.0 (the "License");
6 + * you may not use this file except in compliance with the License.
7 + * You may obtain a copy of the License at
8 + *
9 + * http://www.apache.org/licenses/LICENSE-2.0
10 + *
11 + * Unless required by applicable law or agreed to in writing, software
12 + * distributed under the License is distributed on an "AS IS" BASIS,
13 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + * See the License for the specific language governing permissions and
15 + * limitations under the License.
16 + */
17 +
18 +package org.onosproject.yangutils.datamodel;
19 +
20 +/**
21 + * Abstraction of an entity which provides info about whether to translate module/submodule in manager and service
22 + * classes.
23 + */
24 +public interface YangTranslatorOperatorNode {
25 +}
...@@ -57,7 +57,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol ...@@ -57,7 +57,8 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCol
57 /** 57 /**
58 * Represents data model node to maintain information defined in YANG typedef. 58 * Represents data model node to maintain information defined in YANG typedef.
59 */ 59 */
60 -public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable, YangTypeHolder, CollisionDetector { 60 +public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable, YangTypeHolder, CollisionDetector,
61 + YangTranslatorOperatorNode {
61 62
62 private static final long serialVersionUID = 806201615L; 63 private static final long serialVersionUID = 806201615L;
63 64
......
...@@ -370,6 +370,7 @@ public final class DataModelUtils { ...@@ -370,6 +370,7 @@ public final class DataModelUtils {
370 * 370 *
371 * @param clonedLeaf cloned leaf in uses from grouping 371 * @param clonedLeaf cloned leaf in uses from grouping
372 * @param leafParentHolder holder of the leaf from uses 372 * @param leafParentHolder holder of the leaf from uses
373 + * @param yangUses YANG uses
373 * @return entity of leafref which has to be resolved 374 * @return entity of leafref which has to be resolved
374 * @throws DataModelException data model error 375 * @throws DataModelException data model error
375 */ 376 */
......
...@@ -19,7 +19,7 @@ package org.onosproject.yangutils.linker.impl; ...@@ -19,7 +19,7 @@ package org.onosproject.yangutils.linker.impl;
19 /** 19 /**
20 * Enum for prefix resolver type when augment has come in path. 20 * Enum for prefix resolver type when augment has come in path.
21 */ 21 */
22 -public enum PrefixResolverType { 22 +enum PrefixResolverType {
23 23
24 /** 24 /**
25 * When prefix changes from inter file to intra file. 25 * When prefix changes from inter file to intra file.
...@@ -37,12 +37,12 @@ public enum PrefixResolverType { ...@@ -37,12 +37,12 @@ public enum PrefixResolverType {
37 INTER_TO_INTER, 37 INTER_TO_INTER,
38 38
39 /** 39 /**
40 - * When no prefix change occurres. 40 + * When no prefix change occurs.
41 */ 41 */
42 NO_PREFIX_CHANGE_FOR_INTRA, 42 NO_PREFIX_CHANGE_FOR_INTRA,
43 43
44 /** 44 /**
45 - * When no prefix change occurres. 45 + * When no prefix change occurs.
46 */ 46 */
47 NO_PREFIX_CHANGE_FOR_INTER 47 NO_PREFIX_CHANGE_FOR_INTER
48 } 48 }
......
...@@ -18,13 +18,11 @@ package org.onosproject.yangutils.linker.impl; ...@@ -18,13 +18,11 @@ package org.onosproject.yangutils.linker.impl;
18 18
19 import java.util.Collections; 19 import java.util.Collections;
20 import java.util.HashSet; 20 import java.util.HashSet;
21 -import java.util.Iterator;
22 import java.util.LinkedList; 21 import java.util.LinkedList;
23 import java.util.List; 22 import java.util.List;
24 import java.util.Set; 23 import java.util.Set;
24 +
25 import org.onosproject.yangutils.datamodel.ResolvableType; 25 import org.onosproject.yangutils.datamodel.ResolvableType;
26 -import org.onosproject.yangutils.datamodel.YangImport;
27 -import org.onosproject.yangutils.datamodel.YangInclude;
28 import org.onosproject.yangutils.datamodel.YangNode; 26 import org.onosproject.yangutils.datamodel.YangNode;
29 import org.onosproject.yangutils.datamodel.YangReferenceResolver; 27 import org.onosproject.yangutils.datamodel.YangReferenceResolver;
30 import org.onosproject.yangutils.datamodel.YangSubModule; 28 import org.onosproject.yangutils.datamodel.YangSubModule;
...@@ -32,6 +30,7 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException; ...@@ -32,6 +30,7 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
32 import org.onosproject.yangutils.linker.YangLinker; 30 import org.onosproject.yangutils.linker.YangLinker;
33 import org.onosproject.yangutils.linker.exceptions.LinkerException; 31 import org.onosproject.yangutils.linker.exceptions.LinkerException;
34 32
33 +import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority;
35 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 34 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
36 35
37 /** 36 /**
...@@ -191,52 +190,4 @@ public class YangLinkerManager ...@@ -191,52 +190,4 @@ public class YangLinkerManager
191 } 190 }
192 } 191 }
193 192
194 - /**
195 - * Updates the priority for all the input files.
196 - *
197 - * @param yangNodeSet set of YANG files info
198 - */
199 - public void updateFilePriority(Set<YangNode> yangNodeSet) {
200 - for (YangNode yangNode : yangNodeSet) {
201 - updateFilePriorityOfNode(yangNode);
202 - }
203 - }
204 -
205 - /**
206 - * Updates priority of the node.
207 - *
208 - * @param yangNode YANG node information
209 - */
210 - public void updateFilePriorityOfNode(YangNode yangNode) {
211 - int curNodePriority = yangNode.getPriority();
212 - if (yangNode instanceof YangReferenceResolver) {
213 - List<YangImport> yangImportList = ((YangReferenceResolver) yangNode).getImportList();
214 - if (yangImportList != null && !yangImportList.isEmpty()) {
215 - Iterator<YangImport> importInfoIterator = yangImportList.iterator();
216 - // Run through the imported list to update priority.
217 - while (importInfoIterator.hasNext()) {
218 - YangImport yangImport = importInfoIterator.next();
219 - YangNode importedNode = yangImport.getImportedNode();
220 - if (curNodePriority >= importedNode.getPriority()) {
221 - importedNode.setPriority(curNodePriority + 1);
222 - updateFilePriorityOfNode(importedNode);
223 - }
224 - }
225 - }
226 -
227 - List<YangInclude> yangIncludeList = ((YangReferenceResolver) yangNode).getIncludeList();
228 - if (yangIncludeList != null && !yangIncludeList.isEmpty()) {
229 - Iterator<YangInclude> includeInfoIterator = yangIncludeList.iterator();
230 - // Run through the imported list to update priority.
231 - while (includeInfoIterator.hasNext()) {
232 - YangInclude yangInclude = includeInfoIterator.next();
233 - YangNode includedNode = yangInclude.getIncludedNode();
234 - if (curNodePriority >= includedNode.getPriority()) {
235 - includedNode.setPriority(curNodePriority + 1);
236 - updateFilePriorityOfNode(includedNode);
237 - }
238 - }
239 - }
240 - }
241 - }
242 } 193 }
......
...@@ -16,24 +16,29 @@ ...@@ -16,24 +16,29 @@
16 16
17 package org.onosproject.yangutils.linker.impl; 17 package org.onosproject.yangutils.linker.impl;
18 18
19 +import java.util.ArrayList;
20 +import java.util.Iterator;
21 +import java.util.List;
22 +import java.util.Set;
23 +import java.util.regex.Pattern;
24 +
19 import org.onosproject.yangutils.datamodel.YangAugment; 25 import org.onosproject.yangutils.datamodel.YangAugment;
20 import org.onosproject.yangutils.datamodel.YangAugmentableNode; 26 import org.onosproject.yangutils.datamodel.YangAugmentableNode;
21 import org.onosproject.yangutils.datamodel.YangAugmentedInfo; 27 import org.onosproject.yangutils.datamodel.YangAugmentedInfo;
22 import org.onosproject.yangutils.datamodel.YangCase; 28 import org.onosproject.yangutils.datamodel.YangCase;
23 import org.onosproject.yangutils.datamodel.YangChoice; 29 import org.onosproject.yangutils.datamodel.YangChoice;
30 +import org.onosproject.yangutils.datamodel.YangImport;
31 +import org.onosproject.yangutils.datamodel.YangInclude;
24 import org.onosproject.yangutils.datamodel.YangLeaf; 32 import org.onosproject.yangutils.datamodel.YangLeaf;
25 import org.onosproject.yangutils.datamodel.YangLeafList; 33 import org.onosproject.yangutils.datamodel.YangLeafList;
26 import org.onosproject.yangutils.datamodel.YangLeafRef; 34 import org.onosproject.yangutils.datamodel.YangLeafRef;
27 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 35 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
28 import org.onosproject.yangutils.datamodel.YangNode; 36 import org.onosproject.yangutils.datamodel.YangNode;
29 import org.onosproject.yangutils.datamodel.YangNodeIdentifier; 37 import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
38 +import org.onosproject.yangutils.datamodel.YangReferenceResolver;
30 import org.onosproject.yangutils.datamodel.utils.YangConstructType; 39 import org.onosproject.yangutils.datamodel.utils.YangConstructType;
31 import org.onosproject.yangutils.linker.exceptions.LinkerException; 40 import org.onosproject.yangutils.linker.exceptions.LinkerException;
32 41
33 -import java.util.ArrayList;
34 -import java.util.List;
35 -import java.util.regex.Pattern;
36 -
37 import static org.onosproject.yangutils.utils.UtilConstants.COLON; 42 import static org.onosproject.yangutils.utils.UtilConstants.COLON;
38 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 43 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
39 import static org.onosproject.yangutils.utils.UtilConstants.SLASH_FOR_STRING; 44 import static org.onosproject.yangutils.utils.UtilConstants.SLASH_FOR_STRING;
...@@ -43,13 +48,13 @@ import static org.onosproject.yangutils.utils.UtilConstants.SLASH_FOR_STRING; ...@@ -43,13 +48,13 @@ import static org.onosproject.yangutils.utils.UtilConstants.SLASH_FOR_STRING;
43 */ 48 */
44 public final class YangLinkerUtils { 49 public final class YangLinkerUtils {
45 50
46 - private YangLinkerUtils() {
47 - }
48 -
49 private static final int IDENTIFIER_LENGTH = 64; 51 private static final int IDENTIFIER_LENGTH = 64;
50 private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_.-]*"); 52 private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_.-]*");
51 private static final String XML = "xml"; 53 private static final String XML = "xml";
52 54
55 + private YangLinkerUtils() {
56 + }
57 +
53 /** 58 /**
54 * Detects collision between target nodes leaf/leaf-list or child node with augmented leaf/leaf-list or child node. 59 * Detects collision between target nodes leaf/leaf-list or child node with augmented leaf/leaf-list or child node.
55 * 60 *
...@@ -59,17 +64,28 @@ public final class YangLinkerUtils { ...@@ -59,17 +64,28 @@ public final class YangLinkerUtils {
59 private static void detectCollision(YangNode targetNode, YangAugment augment) { 64 private static void detectCollision(YangNode targetNode, YangAugment augment) {
60 YangNode targetNodesChild = targetNode.getChild(); 65 YangNode targetNodesChild = targetNode.getChild();
61 YangNode augmentsChild = augment.getChild(); 66 YangNode augmentsChild = augment.getChild();
62 - YangLeavesHolder augmentsLeavesHolder = augment; 67 + YangNode parent = targetNode;
63 - if (targetNode instanceof YangChoice) { 68 + if (targetNode instanceof YangAugment) {
64 - if (augmentsLeavesHolder.getListOfLeaf() != null 69 + parent = targetNode.getParent();
65 - || augmentsLeavesHolder.getListOfLeafList() != null) { 70 + } else {
66 - throw new LinkerException("target node " + targetNode.getName() 71 + while (parent.getParent() != null) {
67 - + "is a instance of choice. it can " + 72 + parent = parent.getParent();
68 - "only be augmented with leaf using a case node."); 73 + }
69 } 74 }
75 + if (targetNode instanceof YangChoice) {
76 + // no need to check here.
70 } else { 77 } else {
71 - YangLeavesHolder targetNodesLeavesHolder = (YangLeavesHolder) targetNode; 78 + detectCollisionInLeaveHolders(targetNode, augment);
79 + while (augmentsChild != null) {
80 + detectCollisionInChildNodes(targetNodesChild, augmentsChild, targetNode.getName(), parent.getName());
81 + augmentsChild = augmentsChild.getNextSibling();
82 + }
83 + }
84 + }
72 85
86 + /*Detects collision between leaves/leaflists*/
87 + private static void detectCollisionInLeaveHolders(YangNode targetNode, YangAugment augment) {
88 + YangLeavesHolder targetNodesLeavesHolder = (YangLeavesHolder) targetNode;
73 YangNode parent = targetNode; 89 YangNode parent = targetNode;
74 if (targetNode instanceof YangAugment) { 90 if (targetNode instanceof YangAugment) {
75 parent = targetNode.getParent(); 91 parent = targetNode.getParent();
...@@ -78,9 +94,9 @@ public final class YangLinkerUtils { ...@@ -78,9 +94,9 @@ public final class YangLinkerUtils {
78 parent = parent.getParent(); 94 parent = parent.getParent();
79 } 95 }
80 } 96 }
81 - if (augmentsLeavesHolder.getListOfLeaf() != null && augmentsLeavesHolder.getListOfLeaf().size() != 0 97 + if (augment.getListOfLeaf() != null && augment.getListOfLeaf().size() != 0
82 && targetNodesLeavesHolder.getListOfLeaf() != null) { 98 && targetNodesLeavesHolder.getListOfLeaf() != null) {
83 - for (YangLeaf leaf : augmentsLeavesHolder.getListOfLeaf()) { 99 + for (YangLeaf leaf : augment.getListOfLeaf()) {
84 for (YangLeaf targetLeaf : targetNodesLeavesHolder.getListOfLeaf()) { 100 for (YangLeaf targetLeaf : targetNodesLeavesHolder.getListOfLeaf()) {
85 if (targetLeaf.getName().equals(leaf.getName())) { 101 if (targetLeaf.getName().equals(leaf.getName())) {
86 throw new LinkerException("target node " + targetNode.getName() 102 throw new LinkerException("target node " + targetNode.getName()
...@@ -89,10 +105,10 @@ public final class YangLinkerUtils { ...@@ -89,10 +105,10 @@ public final class YangLinkerUtils {
89 } 105 }
90 } 106 }
91 } 107 }
92 - } else if (augmentsLeavesHolder.getListOfLeafList() != null 108 + } else if (augment.getListOfLeafList() != null
93 - && augmentsLeavesHolder.getListOfLeafList().size() != 0 109 + && augment.getListOfLeafList().size() != 0
94 - && targetNodesLeavesHolder.getListOfLeafList() != null) { 110 + && augment.getListOfLeafList() != null) {
95 - for (YangLeafList leafList : augmentsLeavesHolder.getListOfLeafList()) { 111 + for (YangLeafList leafList : augment.getListOfLeafList()) {
96 for (YangLeafList targetLeafList : targetNodesLeavesHolder.getListOfLeafList()) { 112 for (YangLeafList targetLeafList : targetNodesLeavesHolder.getListOfLeafList()) {
97 if (targetLeafList.getName().equals(leafList.getName())) { 113 if (targetLeafList.getName().equals(leafList.getName())) {
98 throw new LinkerException("target node " + targetNode.getName() 114 throw new LinkerException("target node " + targetNode.getName()
...@@ -101,21 +117,24 @@ public final class YangLinkerUtils { ...@@ -101,21 +117,24 @@ public final class YangLinkerUtils {
101 } 117 }
102 } 118 }
103 } 119 }
104 - } else { 120 + }
121 + }
122 +
123 + /*Detects collision for child nodes.*/
124 + private static void detectCollisionInChildNodes(YangNode targetNodesChild, YangNode augmentsChild, String
125 + targetName, String parentName) {
105 while (augmentsChild != null) { 126 while (augmentsChild != null) {
106 while (targetNodesChild != null) { 127 while (targetNodesChild != null) {
107 if (targetNodesChild.getName().equals(augmentsChild.getName())) { 128 if (targetNodesChild.getName().equals(augmentsChild.getName())) {
108 - throw new LinkerException("target node " + targetNode.getName() 129 + throw new LinkerException("target node " + targetName
109 + " contains augmented child node" + augmentsChild.getName() + " in module " 130 + " contains augmented child node" + augmentsChild.getName() + " in module "
110 - + parent.getName()); 131 + + parentName);
111 } 132 }
112 targetNodesChild = targetNodesChild.getNextSibling(); 133 targetNodesChild = targetNodesChild.getNextSibling();
113 } 134 }
114 augmentsChild = augmentsChild.getNextSibling(); 135 augmentsChild = augmentsChild.getNextSibling();
115 } 136 }
116 } 137 }
117 - }
118 - }
119 138
120 /** 139 /**
121 * Detects collision between target nodes and its all leaf/leaf-list or child node with augmented leaf/leaf-list or 140 * Detects collision between target nodes and its all leaf/leaf-list or child node with augmented leaf/leaf-list or
...@@ -124,7 +143,7 @@ public final class YangLinkerUtils { ...@@ -124,7 +143,7 @@ public final class YangLinkerUtils {
124 * @param targetNode target node 143 * @param targetNode target node
125 * @param augment augment node 144 * @param augment augment node
126 */ 145 */
127 - public static void detectCollisionForAugmentedNode(YangNode targetNode, YangAugment augment) { 146 + static void detectCollisionForAugmentedNode(YangNode targetNode, YangAugment augment) {
128 // Detect collision for target node and augment node. 147 // Detect collision for target node and augment node.
129 detectCollision(targetNode, augment); 148 detectCollision(targetNode, augment);
130 List<YangAugmentedInfo> yangAugmentedInfo = ((YangAugmentableNode) targetNode).getAugmentedInfoList(); 149 List<YangAugmentedInfo> yangAugmentedInfo = ((YangAugmentableNode) targetNode).getAugmentedInfoList();
...@@ -228,4 +247,49 @@ public final class YangLinkerUtils { ...@@ -228,4 +247,49 @@ public final class YangLinkerUtils {
228 return identifier; 247 return identifier;
229 } 248 }
230 } 249 }
250 +
251 + /**
252 + * Updates the priority for all the input files.
253 + *
254 + * @param yangNodeSet set of YANG files info
255 + */
256 + public static void updateFilePriority(Set<YangNode> yangNodeSet) {
257 + for (YangNode yangNode : yangNodeSet) {
258 + updateFilePriorityOfNode(yangNode);
259 + }
260 + }
261 +
262 + /**
263 + * Updates priority of the node.
264 + *
265 + * @param yangNode YANG node information
266 + */
267 + public static void updateFilePriorityOfNode(YangNode yangNode) {
268 + int curNodePriority = yangNode.getPriority();
269 + if (yangNode instanceof YangReferenceResolver) {
270 + List<YangImport> yangImportList = ((YangReferenceResolver) yangNode).getImportList();
271 + Iterator<YangImport> importInfoIterator = yangImportList.iterator();
272 + // Run through the imported list to update priority.
273 + while (importInfoIterator.hasNext()) {
274 + YangImport yangImport = importInfoIterator.next();
275 + YangNode importedNode = yangImport.getImportedNode();
276 + if (curNodePriority >= importedNode.getPriority()) {
277 + importedNode.setPriority(curNodePriority + 1);
278 + updateFilePriorityOfNode(importedNode);
279 + }
280 + }
281 +
282 + List<YangInclude> yangIncludeList = ((YangReferenceResolver) yangNode).getIncludeList();
283 + Iterator<YangInclude> includeInfoIterator = yangIncludeList.iterator();
284 + // Run through the imported list to update priority.
285 + while (includeInfoIterator.hasNext()) {
286 + YangInclude yangInclude = includeInfoIterator.next();
287 + YangNode includedNode = yangInclude.getIncludedNode();
288 + if (curNodePriority >= includedNode.getPriority()) {
289 + includedNode.setPriority(curNodePriority + 1);
290 + updateFilePriorityOfNode(includedNode);
291 + }
292 + }
293 + }
294 + }
231 } 295 }
......
...@@ -1209,7 +1209,6 @@ public class YangResolutionInfoImpl<T> ...@@ -1209,7 +1209,6 @@ public class YangResolutionInfoImpl<T>
1209 detectCollisionForAugmentedNode(targetNode, augment); 1209 detectCollisionForAugmentedNode(targetNode, augment);
1210 ((YangAugmentableNode) targetNode).addAugmentation(augment); 1210 ((YangAugmentableNode) targetNode).addAugmentation(augment);
1211 augment.setAugmentedNode(targetNode); 1211 augment.setAugmentedNode(targetNode);
1212 - augment.setResolveNodeInPath(xPathLinker.getResolvedNodes());
1213 Resolvable resolvable = (Resolvable) entityToResolve; 1212 Resolvable resolvable = (Resolvable) entityToResolve;
1214 resolvable.setResolvableStatus(RESOLVED); 1213 resolvable.setResolvableStatus(RESOLVED);
1215 } else { 1214 } else {
......
...@@ -16,6 +16,12 @@ ...@@ -16,6 +16,12 @@
16 16
17 package org.onosproject.yangutils.linker.impl; 17 package org.onosproject.yangutils.linker.impl;
18 18
19 +import java.util.ArrayList;
20 +import java.util.HashMap;
21 +import java.util.Iterator;
22 +import java.util.List;
23 +import java.util.Map;
24 +import java.util.Stack;
19 import org.onosproject.yangutils.datamodel.YangAtomicPath; 25 import org.onosproject.yangutils.datamodel.YangAtomicPath;
20 import org.onosproject.yangutils.datamodel.YangAugment; 26 import org.onosproject.yangutils.datamodel.YangAugment;
21 import org.onosproject.yangutils.datamodel.YangCase; 27 import org.onosproject.yangutils.datamodel.YangCase;
...@@ -37,13 +43,6 @@ import org.onosproject.yangutils.datamodel.YangTypeDef; ...@@ -37,13 +43,6 @@ import org.onosproject.yangutils.datamodel.YangTypeDef;
37 import org.onosproject.yangutils.datamodel.YangUses; 43 import org.onosproject.yangutils.datamodel.YangUses;
38 import org.onosproject.yangutils.linker.exceptions.LinkerException; 44 import org.onosproject.yangutils.linker.exceptions.LinkerException;
39 45
40 -import java.util.ArrayList;
41 -import java.util.HashMap;
42 -import java.util.Iterator;
43 -import java.util.List;
44 -import java.util.Map;
45 -import java.util.Stack;
46 -
47 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTER; 46 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTER;
48 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTRA; 47 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTRA;
49 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTRA_TO_INTER; 48 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTRA_TO_INTER;
...@@ -63,14 +62,12 @@ public class YangXpathLinker<T> { ...@@ -63,14 +62,12 @@ public class YangXpathLinker<T> {
63 private YangNode rootNode; 62 private YangNode rootNode;
64 private Map<YangAtomicPath, PrefixResolverType> prefixResolverTypes; 63 private Map<YangAtomicPath, PrefixResolverType> prefixResolverTypes;
65 private String curPrefix; 64 private String curPrefix;
66 - private Map<YangAtomicPath, YangNode> resolvedNodes;
67 65
68 /** 66 /**
69 * Creates an instance of x-path linker. 67 * Creates an instance of x-path linker.
70 */ 68 */
71 public YangXpathLinker() { 69 public YangXpathLinker() {
72 absPaths = new ArrayList<>(); 70 absPaths = new ArrayList<>();
73 - setResolvedNodes(new HashMap<>());
74 } 71 }
75 72
76 /** 73 /**
...@@ -156,31 +153,13 @@ public class YangXpathLinker<T> { ...@@ -156,31 +153,13 @@ public class YangXpathLinker<T> {
156 } 153 }
157 154
158 /** 155 /**
159 - * Returns resolved nodes.
160 - *
161 - * @return resolved nodes
162 - */
163 - public Map<YangAtomicPath, YangNode> getResolvedNodes() {
164 - return resolvedNodes;
165 - }
166 -
167 - /**
168 - * Sets resolved nodes.
169 - *
170 - * @param resolvedNodes resolved nodes
171 - */
172 - private void setResolvedNodes(Map<YangAtomicPath, YangNode> resolvedNodes) {
173 - this.resolvedNodes = resolvedNodes;
174 - }
175 -
176 - /**
177 * Adds node to resolved nodes. 156 * Adds node to resolved nodes.
178 * 157 *
179 * @param path absolute path 158 * @param path absolute path
180 * @param node resolved node 159 * @param node resolved node
181 */ 160 */
182 private void addToResolvedNodes(YangAtomicPath path, YangNode node) { 161 private void addToResolvedNodes(YangAtomicPath path, YangNode node) {
183 - getResolvedNodes().put(path, node); 162 + path.setResolvedNode(node);
184 } 163 }
185 164
186 /** 165 /**
...@@ -211,7 +190,7 @@ public class YangXpathLinker<T> { ...@@ -211,7 +190,7 @@ public class YangXpathLinker<T> {
211 */ 190 */
212 public T processLeafRefXpathLinking(List<YangAtomicPath> atomicPaths, YangNode root, YangLeafRef leafref) { 191 public T processLeafRefXpathLinking(List<YangAtomicPath> atomicPaths, YangNode root, YangLeafRef leafref) {
213 192
214 - YangNode targetNode = null; 193 + YangNode targetNode;
215 setRootNode(root); 194 setRootNode(root);
216 setPrefixResolverTypes(new HashMap<>()); 195 setPrefixResolverTypes(new HashMap<>());
217 parsePrefixResolverList(atomicPaths); 196 parsePrefixResolverList(atomicPaths);
...@@ -260,11 +239,8 @@ public class YangXpathLinker<T> { ...@@ -260,11 +239,8 @@ public class YangXpathLinker<T> {
260 * @param leafref instance of YANG leafref 239 * @param leafref instance of YANG leafref
261 */ 240 */
262 private void validateInvalidNodesInThePath(YangLeafRef leafref) { 241 private void validateInvalidNodesInThePath(YangLeafRef leafref) {
263 - Map<YangAtomicPath, YangNode> nodes = getResolvedNodes(); 242 + for (YangAtomicPath absolutePath : (Iterable<YangAtomicPath>) leafref.getAtomicPath()) {
264 - Iterator<Map.Entry<YangAtomicPath, YangNode>> nodesIterator = nodes.entrySet().iterator(); 243 + YangNode nodeInPath = absolutePath.getResolvedNode();
265 - while (nodesIterator.hasNext()) {
266 - Map.Entry<YangAtomicPath, YangNode> nodeInList = nodesIterator.next();
267 - YangNode nodeInPath = nodeInList.getValue();
268 244
269 if (nodeInPath instanceof YangGrouping || nodeInPath instanceof YangUses 245 if (nodeInPath instanceof YangGrouping || nodeInPath instanceof YangUses
270 || nodeInPath instanceof YangTypeDef || nodeInPath instanceof YangCase 246 || nodeInPath instanceof YangTypeDef || nodeInPath instanceof YangCase
...@@ -331,9 +307,7 @@ public class YangXpathLinker<T> { ...@@ -331,9 +307,7 @@ public class YangXpathLinker<T> {
331 YangLeavesHolder holder = (YangLeavesHolder) targetNode; 307 YangLeavesHolder holder = (YangLeavesHolder) targetNode;
332 List<YangLeaf> leaves = holder.getListOfLeaf(); 308 List<YangLeaf> leaves = holder.getListOfLeaf();
333 if (leaves != null && !leaves.isEmpty()) { 309 if (leaves != null && !leaves.isEmpty()) {
334 - Iterator<YangLeaf> leafIterator = leaves.listIterator(); 310 + for (YangLeaf leaf : leaves) {
335 - while (leafIterator.hasNext()) {
336 - YangLeaf leaf = leafIterator.next();
337 if (leaf.getName().equals(leafName)) { 311 if (leaf.getName().equals(leafName)) {
338 return leaf; 312 return leaf;
339 } 313 }
...@@ -357,9 +331,7 @@ public class YangXpathLinker<T> { ...@@ -357,9 +331,7 @@ public class YangXpathLinker<T> {
357 YangLeavesHolder holder = (YangLeavesHolder) targetNode; 331 YangLeavesHolder holder = (YangLeavesHolder) targetNode;
358 List<YangLeafList> leavesList = holder.getListOfLeafList(); 332 List<YangLeafList> leavesList = holder.getListOfLeafList();
359 if (leavesList != null && !leavesList.isEmpty()) { 333 if (leavesList != null && !leavesList.isEmpty()) {
360 - Iterator<YangLeafList> leafListIterator = leavesList.listIterator(); 334 + for (YangLeafList leafList : leavesList) {
361 - while (leafListIterator.hasNext()) {
362 - YangLeafList leafList = leafListIterator.next();
363 if (leafList.getName().equals(leafListName)) { 335 if (leafList.getName().equals(leafListName)) {
364 return leafList; 336 return leafList;
365 } 337 }
......
...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.plugin.manager; ...@@ -18,7 +18,6 @@ package org.onosproject.yangutils.plugin.manager;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.HashSet; 20 import java.util.HashSet;
21 -import java.util.Iterator;
22 import java.util.List; 21 import java.util.List;
23 import java.util.Set; 22 import java.util.Set;
24 import org.apache.maven.artifact.repository.ArtifactRepository; 23 import org.apache.maven.artifact.repository.ArtifactRepository;
...@@ -43,6 +42,7 @@ import org.sonatype.plexus.build.incremental.BuildContext; ...@@ -43,6 +42,7 @@ import org.sonatype.plexus.build.incremental.BuildContext;
43 42
44 import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES; 43 import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES;
45 import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE; 44 import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE;
45 +import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority;
46 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot; 46 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot;
47 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.copyYangFilesToTarget; 47 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.copyYangFilesToTarget;
48 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.resolveInterJarDependencies; 48 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.resolveInterJarDependencies;
...@@ -67,17 +67,14 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirP ...@@ -67,17 +67,14 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirP
67 public class YangUtilManager 67 public class YangUtilManager
68 extends AbstractMojo { 68 extends AbstractMojo {
69 69
70 + private static final String DEFAULT_PKG = SLASH + getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG);
70 private YangNode rootNode; 71 private YangNode rootNode;
71 // YANG file information set. 72 // YANG file information set.
72 private Set<YangFileInfo> yangFileInfoSet = new HashSet<>(); 73 private Set<YangFileInfo> yangFileInfoSet = new HashSet<>();
73 private YangUtilsParser yangUtilsParser = new YangUtilsParserManager(); 74 private YangUtilsParser yangUtilsParser = new YangUtilsParserManager();
74 private YangLinker yangLinker = new YangLinkerManager(); 75 private YangLinker yangLinker = new YangLinkerManager();
75 private YangFileInfo curYangFileInfo = new YangFileInfo(); 76 private YangFileInfo curYangFileInfo = new YangFileInfo();
76 -
77 private Set<YangNode> yangNodeSet = new HashSet<>(); 77 private Set<YangNode> yangNodeSet = new HashSet<>();
78 -
79 - private static final String DEFAULT_PKG = SLASH + getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG);
80 -
81 /** 78 /**
82 * Source directory for YANG files. 79 * Source directory for YANG files.
83 */ 80 */
...@@ -144,9 +141,15 @@ public class YangUtilManager ...@@ -144,9 +141,15 @@ public class YangUtilManager
144 @Component 141 @Component
145 private BuildContext context; 142 private BuildContext context;
146 143
144 + /**
145 + * Local maven repository.
146 + */
147 @Parameter(readonly = true, defaultValue = "${localRepository}") 147 @Parameter(readonly = true, defaultValue = "${localRepository}")
148 private ArtifactRepository localRepository; 148 private ArtifactRepository localRepository;
149 149
150 + /**
151 + * Remote maven repositories.
152 + */
150 @Parameter(readonly = true, defaultValue = "${project.remoteArtifactRepositories}") 153 @Parameter(readonly = true, defaultValue = "${project.remoteArtifactRepositories}")
151 private List<ArtifactRepository> remoteRepository; 154 private List<ArtifactRepository> remoteRepository;
152 155
...@@ -196,7 +199,7 @@ public class YangUtilManager ...@@ -196,7 +199,7 @@ public class YangUtilManager
196 return; 199 return;
197 } 200 }
198 // Resolve inter jar dependency. 201 // Resolve inter jar dependency.
199 - resolveInterJardependency(); 202 + resolveInterJarDependency();
200 203
201 // Carry out the parsing for all the YANG files. 204 // Carry out the parsing for all the YANG files.
202 parseYangFileInfoSet(); 205 parseYangFileInfoSet();
...@@ -205,7 +208,7 @@ public class YangUtilManager ...@@ -205,7 +208,7 @@ public class YangUtilManager
205 resolveDependenciesUsingLinker(); 208 resolveDependenciesUsingLinker();
206 209
207 // Perform translation to JAVA. 210 // Perform translation to JAVA.
208 - translateToJava(getYangFileInfoSet(), yangPlugin); 211 + translateToJava(yangPlugin);
209 212
210 // Serialize data model. 213 // Serialize data model.
211 serializeDataModel(getDirectory(baseDir, outputDirectory), getYangFileInfoSet(), project, true); 214 serializeDataModel(getDirectory(baseDir, outputDirectory), getYangFileInfoSet(), project, true);
...@@ -237,7 +240,7 @@ public class YangUtilManager ...@@ -237,7 +240,7 @@ public class YangUtilManager
237 * 240 *
238 * @return YANG node set 241 * @return YANG node set
239 */ 242 */
240 - public Set<YangNode> getYangNodeSet() { 243 + Set<YangNode> getYangNodeSet() {
241 return yangNodeSet; 244 return yangNodeSet;
242 } 245 }
243 246
...@@ -246,12 +249,13 @@ public class YangUtilManager ...@@ -246,12 +249,13 @@ public class YangUtilManager
246 * 249 *
247 * @throws IOException when fails to do IO operations 250 * @throws IOException when fails to do IO operations
248 */ 251 */
249 - public void resolveInterJardependency() throws IOException { 252 + private void resolveInterJarDependency() throws IOException {
250 try { 253 try {
251 List<YangNode> interJarResolvedNodes = resolveInterJarDependencies(project, localRepository, 254 List<YangNode> interJarResolvedNodes = resolveInterJarDependencies(project, localRepository,
252 remoteRepository, getDirectory(baseDir, outputDirectory)); 255 remoteRepository, getDirectory(baseDir, outputDirectory));
253 for (YangNode node : interJarResolvedNodes) { 256 for (YangNode node : interJarResolvedNodes) {
254 YangFileInfo dependentFileInfo = new YangFileInfo(); 257 YangFileInfo dependentFileInfo = new YangFileInfo();
258 + node.setToTranslate(false);
255 dependentFileInfo.setRootNode(node); 259 dependentFileInfo.setRootNode(node);
256 dependentFileInfo.setForTranslator(false); 260 dependentFileInfo.setForTranslator(false);
257 dependentFileInfo.setYangFileName(node.getName()); 261 dependentFileInfo.setYangFileName(node.getName());
...@@ -281,7 +285,7 @@ public class YangUtilManager ...@@ -281,7 +285,7 @@ public class YangUtilManager
281 /** 285 /**
282 * Creates YANG nodes set. 286 * Creates YANG nodes set.
283 */ 287 */
284 - public void createYangNodeSet() { 288 + void createYangNodeSet() {
285 for (YangFileInfo yangFileInfo : getYangFileInfoSet()) { 289 for (YangFileInfo yangFileInfo : getYangFileInfoSet()) {
286 getYangNodeSet().add(yangFileInfo.getRootNode()); 290 getYangNodeSet().add(yangFileInfo.getRootNode());
287 } 291 }
...@@ -339,19 +343,15 @@ public class YangUtilManager ...@@ -339,19 +343,15 @@ public class YangUtilManager
339 /** 343 /**
340 * Translates to java code corresponding to the YANG schema. 344 * Translates to java code corresponding to the YANG schema.
341 * 345 *
342 - * @param yangFileInfoSet YANG file information
343 * @param yangPlugin YANG plugin config 346 * @param yangPlugin YANG plugin config
344 - * @throws IOException when fails to generate java code file the current 347 + * @throws IOException when fails to generate java code file the current node
345 - * node
346 */ 348 */
347 - public void translateToJava(Set<YangFileInfo> yangFileInfoSet, YangPluginConfig yangPlugin) 349 + public void translateToJava(YangPluginConfig yangPlugin)
348 throws IOException { 350 throws IOException {
349 - Iterator<YangFileInfo> yangFileIterator = yangFileInfoSet.iterator(); 351 + updateFilePriority(getYangNodeSet());
350 - while (yangFileIterator.hasNext()) { 352 + for (YangNode node : getYangNodeSet()) {
351 - YangFileInfo yangFileInfo = yangFileIterator.next(); 353 + if (node.isToTranslate()) {
352 - setCurYangFileInfo(yangFileInfo); 354 + generateJavaCode(node, yangPlugin);
353 - if (yangFileInfo.isForTranslator()) {
354 - generateJavaCode(yangFileInfo.getRootNode(), yangPlugin);
355 } 355 }
356 } 356 }
357 } 357 }
...@@ -383,7 +383,7 @@ public class YangUtilManager ...@@ -383,7 +383,7 @@ public class YangUtilManager
383 * 383 *
384 * @param yangFileInfoSet the YANG file info set 384 * @param yangFileInfoSet the YANG file info set
385 */ 385 */
386 - public void setYangFileInfoSet(Set<YangFileInfo> yangFileInfoSet) { 386 + void setYangFileInfoSet(Set<YangFileInfo> yangFileInfoSet) {
387 this.yangFileInfoSet = yangFileInfoSet; 387 this.yangFileInfoSet = yangFileInfoSet;
388 } 388 }
389 389
...@@ -392,7 +392,7 @@ public class YangUtilManager ...@@ -392,7 +392,7 @@ public class YangUtilManager
392 * 392 *
393 * @return the yangFileInfo 393 * @return the yangFileInfo
394 */ 394 */
395 - public YangFileInfo getCurYangFileInfo() { 395 + private YangFileInfo getCurYangFileInfo() {
396 return curYangFileInfo; 396 return curYangFileInfo;
397 } 397 }
398 398
...@@ -401,7 +401,7 @@ public class YangUtilManager ...@@ -401,7 +401,7 @@ public class YangUtilManager
401 * 401 *
402 * @param yangFileInfo the yangFileInfo to set 402 * @param yangFileInfo the yangFileInfo to set
403 */ 403 */
404 - public void setCurYangFileInfo(YangFileInfo yangFileInfo) { 404 + private void setCurYangFileInfo(YangFileInfo yangFileInfo) {
405 curYangFileInfo = yangFileInfo; 405 curYangFileInfo = yangFileInfo;
406 } 406 }
407 } 407 }
......
...@@ -88,6 +88,12 @@ public final class GeneratedJavaFileType { ...@@ -88,6 +88,12 @@ public final class GeneratedJavaFileType {
88 public static final int GENERATE_EVENT_SUBJECT_CLASS = 1024; 88 public static final int GENERATE_EVENT_SUBJECT_CLASS = 1024;
89 89
90 /** 90 /**
91 + * Java classes for events.
92 + */
93 + public static final int GENERATE_ALL_EVENT_CLASS_MASK = GENERATE_EVENT_CLASS | GENERATE_EVENT_LISTENER_INTERFACE
94 + | GENERATE_EVENT_SUBJECT_CLASS;
95 +
96 + /**
91 * Identity listener class. 97 * Identity listener class.
92 */ 98 */
93 public static final int GENERATE_IDENTITY_CLASS = 2048; 99 public static final int GENERATE_IDENTITY_CLASS = 2048;
......
...@@ -42,6 +42,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; ...@@ -42,6 +42,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
42 import static org.onosproject.yangutils.utils.UtilConstants.ONOS_EVENT_PKG; 42 import static org.onosproject.yangutils.utils.UtilConstants.ONOS_EVENT_PKG;
43 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 43 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
44 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; 44 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
45 +import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_OP_PARAM_INFO_CLASS;
45 import static java.util.Collections.sort; 46 import static java.util.Collections.sort;
46 47
47 /** 48 /**
...@@ -289,4 +290,14 @@ public class JavaImportData { ...@@ -289,4 +290,14 @@ public class JavaImportData {
289 public String getYangAugmentedInfoImport() { 290 public String getYangAugmentedInfoImport() {
290 return IMPORT + YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD + YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS; 291 return IMPORT + YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD + YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS;
291 } 292 }
293 +
294 + /**
295 + * Returns import string for YangAugmentedOpParamInfo class.
296 + *
297 + * @return import string for YangAugmentedOpParamInfo class
298 + */
299 + public String getYangAugmentedOpParamInfoImport() {
300 + return IMPORT + YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD +
301 + YANG_AUGMENTED_OP_PARAM_INFO_CLASS;
302 + }
292 } 303 }
......
...@@ -23,6 +23,7 @@ import org.onosproject.yangutils.datamodel.YangTypeHolder; ...@@ -23,6 +23,7 @@ import org.onosproject.yangutils.datamodel.YangTypeHolder;
23 import org.onosproject.yangutils.translator.exception.TranslatorException; 23 import org.onosproject.yangutils.translator.exception.TranslatorException;
24 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 24 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
25 25
26 +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ALL_EVENT_CLASS_MASK;
26 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS; 27 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
27 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 29 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
...@@ -56,6 +57,11 @@ public class TempJavaCodeFragmentFiles { ...@@ -56,6 +57,11 @@ public class TempJavaCodeFragmentFiles {
56 private TempJavaEnumerationFragmentFiles enumerationTempFiles; 57 private TempJavaEnumerationFragmentFiles enumerationTempFiles;
57 58
58 /** 59 /**
60 + * Has the temporary files required for enumeration generated classes.
61 + */
62 + private TempJavaEventFragmentFiles tempJavaEventFragmentFiles;
63 +
64 + /**
59 * Creates an instance of temporary java code fragment. 65 * Creates an instance of temporary java code fragment.
60 * 66 *
61 * @param javaFileInfo generated java file info 67 * @param javaFileInfo generated java file info
...@@ -80,6 +86,10 @@ public class TempJavaCodeFragmentFiles { ...@@ -80,6 +86,10 @@ public class TempJavaCodeFragmentFiles {
80 setServiceTempFiles(new TempJavaServiceFragmentFiles(javaFileInfo)); 86 setServiceTempFiles(new TempJavaServiceFragmentFiles(javaFileInfo));
81 } 87 }
82 88
89 + if ((javaFileInfo.getGeneratedFileTypes() & GENERATE_ALL_EVENT_CLASS_MASK) != 0) {
90 + setEventFragmentFiles(new TempJavaEventFragmentFiles(javaFileInfo));
91 + }
92 +
83 } 93 }
84 94
85 /** 95 /**
...@@ -156,6 +166,25 @@ public class TempJavaCodeFragmentFiles { ...@@ -156,6 +166,25 @@ public class TempJavaCodeFragmentFiles {
156 } 166 }
157 167
158 /** 168 /**
169 + * Retrieves the temp file handle for event file generation.
170 + *
171 + * @return temp file handle for enumeration file generation
172 + */
173 + public TempJavaEventFragmentFiles getEventFragmentFiles() {
174 + return tempJavaEventFragmentFiles;
175 + }
176 +
177 + /**
178 + * Sets temp file handle for event file generation.
179 + *
180 + * @param tempJavaEventFragmentFiles temp file handle for event file generation
181 + */
182 + public void setEventFragmentFiles(TempJavaEventFragmentFiles tempJavaEventFragmentFiles) {
183 + this.tempJavaEventFragmentFiles = tempJavaEventFragmentFiles;
184 + }
185 +
186 +
187 + /**
159 * Constructs java code exit. 188 * Constructs java code exit.
160 * 189 *
161 * @param fileType generated file type 190 * @param fileType generated file type
...@@ -183,6 +212,13 @@ public class TempJavaCodeFragmentFiles { ...@@ -183,6 +212,13 @@ public class TempJavaCodeFragmentFiles {
183 getServiceTempFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, curNode); 212 getServiceTempFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, curNode);
184 } 213 }
185 214
215 + /**
216 + * Creates event, event listener and event subject files.
217 + */
218 + if (fileType == GENERATE_ALL_EVENT_CLASS_MASK) {
219 + getEventFragmentFiles().generateJavaFile(GENERATE_ALL_EVENT_CLASS_MASK, curNode);
220 + }
221 +
186 /* 222 /*
187 * Creats enumeration class file. 223 * Creats enumeration class file.
188 */ 224 */
......
...@@ -16,23 +16,17 @@ ...@@ -16,23 +16,17 @@
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.ArrayList;
20 -import java.util.List;
21 19
22 import org.onosproject.yangutils.datamodel.YangAugment; 20 import org.onosproject.yangutils.datamodel.YangAugment;
23 -import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
24 import org.onosproject.yangutils.translator.exception.TranslatorException; 21 import org.onosproject.yangutils.translator.exception.TranslatorException;
25 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; 22 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
26 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; 23 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
27 import org.onosproject.yangutils.translator.tojava.JavaFileInfo; 24 import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
28 -import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
29 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 25 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
30 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
31 27
32 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 28 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
33 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfAugmentableNode; 29 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfAugmentableNode;
34 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
35 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
36 30
37 /** 31 /**
38 * Represents augment information extended to support java code generation. 32 * Represents augment information extended to support java code generation.
...@@ -44,23 +38,12 @@ public class YangJavaAugment ...@@ -44,23 +38,12 @@ public class YangJavaAugment
44 private static final long serialVersionUID = 806201632L; 38 private static final long serialVersionUID = 806201632L;
45 39
46 /** 40 /**
47 - * Prefix to be added to generated java file for augment node.
48 - */
49 - private static final String AUGMENTED = "Augmented";
50 -
51 - /**
52 * Contains the information of the java file being generated. 41 * Contains the information of the java file being generated.
53 */ 42 */
54 private JavaFileInfo javaFileInfo; 43 private JavaFileInfo javaFileInfo;
55 44
56 /** 45 /**
57 - * TargetNodes java qualified info. 46 + * File handle to maintain temporary java code fragments as per the code snippet types.
58 - */
59 - private List<JavaQualifiedTypeInfo> extendedClassInfo;
60 -
61 - /**
62 - * File handle to maintain temporary java code fragments as per the code
63 - * snippet types.
64 */ 47 */
65 private transient TempJavaCodeFragmentFiles tempFileHandle; 48 private transient TempJavaCodeFragmentFiles tempFileHandle;
66 49
...@@ -70,7 +53,6 @@ public class YangJavaAugment ...@@ -70,7 +53,6 @@ public class YangJavaAugment
70 public YangJavaAugment() { 53 public YangJavaAugment() {
71 super(); 54 super();
72 setJavaFileInfo(new JavaFileInfo()); 55 setJavaFileInfo(new JavaFileInfo());
73 - setExtendedClassInfo(new ArrayList<>());
74 getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER); 56 getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
75 } 57 }
76 58
...@@ -119,8 +101,7 @@ public class YangJavaAugment ...@@ -119,8 +101,7 @@ public class YangJavaAugment
119 } 101 }
120 102
121 /** 103 /**
122 - * Prepare the information for java code generation corresponding to YANG 104 + * Prepare the information for java code generation corresponding to YANG augment info.
123 - * augment info.
124 * 105 *
125 * @param yangPlugin YANG plugin config 106 * @param yangPlugin YANG plugin config
126 * @throws TranslatorException translator operation fail 107 * @throws TranslatorException translator operation fail
...@@ -148,46 +129,4 @@ public class YangJavaAugment ...@@ -148,46 +129,4 @@ public class YangJavaAugment
148 } 129 }
149 } 130 }
150 131
151 - /**
152 - * Returns augment class name.
153 - *
154 - * @return augment class name
155 - */
156 - public String getAugmentClassName() {
157 - YangNodeIdentifier nodeId = getTargetNode().get(getTargetNode().size() - 1).getNodeIdentifier();
158 - String name = getCapitalCase(getCamelCase(nodeId.getName(), null));
159 - if (nodeId.getPrefix() != null) {
160 - return AUGMENTED + getCapitalCase(nodeId.getPrefix()) + name;
161 - } else {
162 - return AUGMENTED + name;
163 - }
164 - }
165 -
166 - /**
167 - * Returns extended class info.
168 - *
169 - * @return extended class info
170 - */
171 - public List<JavaQualifiedTypeInfo> getExtendedClassInfo() {
172 - return extendedClassInfo;
173 - }
174 -
175 - /**
176 - * Sets extended class info.
177 - *
178 - * @param augmentedInfo extended class info
179 - */
180 - private void setExtendedClassInfo(List<JavaQualifiedTypeInfo> augmentedInfo) {
181 - extendedClassInfo = augmentedInfo;
182 - }
183 -
184 - /**
185 - * Adds to extended class info list.
186 - *
187 - * @param augmentedInfo extended class info
188 - */
189 - public void addToExtendedClassInfo(JavaQualifiedTypeInfo augmentedInfo) {
190 - getExtendedClassInfo().add(augmentedInfo);
191 - }
192 -
193 } 132 }
......
...@@ -15,6 +15,10 @@ ...@@ -15,6 +15,10 @@
15 */ 15 */
16 package org.onosproject.yangutils.translator.tojava.javamodel; 16 package org.onosproject.yangutils.translator.tojava.javamodel;
17 17
18 +import java.io.File;
19 +import java.io.IOException;
20 +import java.util.List;
21 +
18 import org.onosproject.yangutils.datamodel.YangIdentity; 22 import org.onosproject.yangutils.datamodel.YangIdentity;
19 import org.onosproject.yangutils.translator.exception.TranslatorException; 23 import org.onosproject.yangutils.translator.exception.TranslatorException;
20 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; 24 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
...@@ -25,12 +29,8 @@ import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo; ...@@ -25,12 +29,8 @@ import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
25 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 29 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
26 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 30 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
27 31
28 -import java.io.File;
29 -import java.io.IOException;
30 -import java.util.List;
31 -
32 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
33 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_IDENTITY_CLASS; 32 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_IDENTITY_CLASS;
33 +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
34 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.updatePackageInfo; 34 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.updatePackageInfo;
35 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; 35 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
36 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration; 36 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration;
...@@ -145,7 +145,7 @@ public class YangJavaIdentity extends YangIdentity ...@@ -145,7 +145,7 @@ public class YangJavaIdentity extends YangIdentity
145 } 145 }
146 } 146 }
147 147
148 - File file = getFileObject(path, className, JAVA_FILE_EXTENSION, getJavaFileInfo()); 148 + File file = getFileObject(path, className, JAVA_FILE_EXTENSION, getJavaFileInfo().getBaseCodeGenPath());
149 149
150 initiateJavaFileGeneration(file, GENERATE_IDENTITY_CLASS, imports, this, className); 150 initiateJavaFileGeneration(file, GENERATE_IDENTITY_CLASS, imports, this, className);
151 closeFile(file, false); 151 closeFile(file, false);
......
...@@ -29,14 +29,12 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; ...@@ -29,14 +29,12 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
29 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 29 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
30 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 30 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
31 31
32 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; 32 +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ALL_EVENT_CLASS_MASK;
33 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE;
34 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS;
35 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 33 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
36 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 34 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
37 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode; 35 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode;
38 -import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired;
39 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq; 36 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq;
37 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired;
40 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; 38 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
41 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; 39 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
42 import static org.onosproject.yangutils.utils.UtilConstants.SBI; 40 import static org.onosproject.yangutils.utils.UtilConstants.SBI;
...@@ -56,8 +54,7 @@ public class YangJavaModule ...@@ -56,8 +54,7 @@ public class YangJavaModule
56 private JavaFileInfo javaFileInfo; 54 private JavaFileInfo javaFileInfo;
57 55
58 /** 56 /**
59 - * File handle to maintain temporary java code fragments as per the code 57 + * File handle to maintain temporary java code fragments as per the code snippet types.
60 - * snippet types.
61 */ 58 */
62 private transient TempJavaCodeFragmentFiles tempFileHandle; 59 private transient TempJavaCodeFragmentFiles tempFileHandle;
63 60
...@@ -73,12 +70,7 @@ public class YangJavaModule ...@@ -73,12 +70,7 @@ public class YangJavaModule
73 super(); 70 super();
74 setJavaFileInfo(new JavaFileInfo()); 71 setJavaFileInfo(new JavaFileInfo());
75 setNotificationNodes(new ArrayList<>()); 72 setNotificationNodes(new ArrayList<>());
76 - int gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER; 73 + getJavaFileInfo().setGeneratedFileTypes(GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER);
77 - if (isNotificationChildNodePresent(this)) {
78 - gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_EVENT_SUBJECT_CLASS | GENERATE_EVENT_CLASS
79 - | GENERATE_EVENT_LISTENER_INTERFACE;
80 - }
81 - getJavaFileInfo().setGeneratedFileTypes(gentype);
82 74
83 } 75 }
84 76
...@@ -135,6 +127,11 @@ public class YangJavaModule ...@@ -135,6 +127,11 @@ public class YangJavaModule
135 public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { 127 public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException {
136 String modulePkg = getRootPackage(getVersion(), getNameSpace().getUri(), getRevision().getRevDate(), 128 String modulePkg = getRootPackage(getVersion(), getNameSpace().getUri(), getRevision().getRevDate(),
137 yangPlugin.getConflictResolver()); 129 yangPlugin.getConflictResolver());
130 +
131 + if (isNotificationChildNodePresent(this)) {
132 + getJavaFileInfo().setGeneratedFileTypes(getJavaFileInfo().getGeneratedFileTypes()
133 + | GENERATE_ALL_EVENT_CLASS_MASK);
134 + }
138 try { 135 try {
139 generateCodeOfRootNode(this, yangPlugin, modulePkg); 136 generateCodeOfRootNode(this, yangPlugin, modulePkg);
140 } catch (IOException e) { 137 } catch (IOException e) {
...@@ -157,17 +154,22 @@ public class YangJavaModule ...@@ -157,17 +154,22 @@ public class YangJavaModule
157 * 154 *
158 * The manager class needs to extend the "ListenerRegistry". 155 * The manager class needs to extend the "ListenerRegistry".
159 */ 156 */
160 -
161 try { 157 try {
162 - if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) { 158 + if ((getJavaFileInfo().getGeneratedFileTypes() & GENERATE_ALL_EVENT_CLASS_MASK) != 0) {
163 - if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null) || 159 + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_ALL_EVENT_CLASS_MASK, this);
164 - (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) { 160 + }
165 getTempJavaCodeFragmentFiles() 161 getTempJavaCodeFragmentFiles()
166 .generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this); 162 .generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
167 - getTempJavaCodeFragmentFiles() 163 + if (isManagerCodeGenRequired(this)) {
168 - .generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this); 164 + if (isGenerationOfCodeReq(getJavaFileInfo())) {
165 + if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null)
166 + || (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) {
167 + getTempJavaCodeFragmentFiles().getServiceTempFiles().setManagerNeedToBeGenerated(true);
168 + }
169 } 169 }
170 } 170 }
171 + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this);
172 +
171 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + 173 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() +
172 getJavaFileInfo().getPackageFilePath()); 174 getJavaFileInfo().getPackageFilePath());
173 searchAndDeleteTempDir(getJavaFileInfo().getPluginConfig().getCodeGenDir() + 175 searchAndDeleteTempDir(getJavaFileInfo().getPluginConfig().getCodeGenDir() +
......
...@@ -31,14 +31,12 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; ...@@ -31,14 +31,12 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
31 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; 31 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
32 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 32 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
33 33
34 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS; 34 +import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ALL_EVENT_CLASS_MASK;
35 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_LISTENER_INTERFACE;
36 -import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS;
37 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER; 35 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
38 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER; 36 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
39 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode; 37 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.generateCodeOfRootNode;
40 -import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired;
41 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq; 38 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq;
39 +import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired;
42 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; 40 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
43 import static org.onosproject.yangutils.utils.UtilConstants.SBI; 41 import static org.onosproject.yangutils.utils.UtilConstants.SBI;
44 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir; 42 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
...@@ -58,8 +56,7 @@ public class YangJavaSubModule ...@@ -58,8 +56,7 @@ public class YangJavaSubModule
58 private JavaFileInfo javaFileInfo; 56 private JavaFileInfo javaFileInfo;
59 57
60 /** 58 /**
61 - * File handle to maintain temporary java code fragments as per the code 59 + * File handle to maintain temporary java code fragments as per the code snippet types.
62 - * snippet types.
63 */ 60 */
64 private transient TempJavaCodeFragmentFiles tempFileHandle; 61 private transient TempJavaCodeFragmentFiles tempFileHandle;
65 62
...@@ -76,8 +73,7 @@ public class YangJavaSubModule ...@@ -76,8 +73,7 @@ public class YangJavaSubModule
76 setJavaFileInfo(new JavaFileInfo()); 73 setJavaFileInfo(new JavaFileInfo());
77 int gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER; 74 int gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_INTERFACE_WITH_BUILDER;
78 if (isNotificationChildNodePresent(this)) { 75 if (isNotificationChildNodePresent(this)) {
79 - gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_EVENT_SUBJECT_CLASS | GENERATE_EVENT_CLASS 76 + gentype = GENERATE_SERVICE_AND_MANAGER | GENERATE_ALL_EVENT_CLASS_MASK;
80 - | GENERATE_EVENT_LISTENER_INTERFACE;
81 } 77 }
82 getJavaFileInfo().setGeneratedFileTypes(gentype); 78 getJavaFileInfo().setGeneratedFileTypes(gentype);
83 } 79 }
...@@ -145,6 +141,11 @@ public class YangJavaSubModule ...@@ -145,6 +141,11 @@ public class YangJavaSubModule
145 public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException { 141 public void generateCodeEntry(YangPluginConfig yangPlugin) throws TranslatorException {
146 String subModulePkg = getRootPackage(getVersion(), getNameSpaceFromModule(getBelongsTo()), 142 String subModulePkg = getRootPackage(getVersion(), getNameSpaceFromModule(getBelongsTo()),
147 getRevision().getRevDate(), yangPlugin.getConflictResolver()); 143 getRevision().getRevDate(), yangPlugin.getConflictResolver());
144 +
145 + if (isNotificationChildNodePresent(this)) {
146 + getJavaFileInfo().setGeneratedFileTypes(getJavaFileInfo().getGeneratedFileTypes()
147 + | GENERATE_ALL_EVENT_CLASS_MASK);
148 + }
148 try { 149 try {
149 generateCodeOfRootNode(this, yangPlugin, subModulePkg); 150 generateCodeOfRootNode(this, yangPlugin, subModulePkg);
150 } catch (IOException e) { 151 } catch (IOException e) {
...@@ -169,13 +170,21 @@ public class YangJavaSubModule ...@@ -169,13 +170,21 @@ public class YangJavaSubModule
169 * The manager class needs to extend the "ListenerRegistry". 170 * The manager class needs to extend the "ListenerRegistry".
170 */ 171 */
171 try { 172 try {
172 - if (isManagerCodeGenRequired(this) && isGenerationOfCodeReq(getJavaFileInfo())) { 173 + if ((getJavaFileInfo().getGeneratedFileTypes() & GENERATE_ALL_EVENT_CLASS_MASK) != 0) {
173 - if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null) || 174 + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_ALL_EVENT_CLASS_MASK, this);
174 - (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) {
175 - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
176 - getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this);
177 } 175 }
176 + getTempJavaCodeFragmentFiles()
177 + .generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
178 + if (isManagerCodeGenRequired(this)) {
179 + if (isGenerationOfCodeReq(getJavaFileInfo())) {
180 + if ((getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi() == null)
181 + || (!getJavaFileInfo().getPluginConfig().getCodeGenerateForsbi().equals(SBI))) {
182 + getTempJavaCodeFragmentFiles().getServiceTempFiles().setManagerNeedToBeGenerated(true);
178 } 183 }
184 + }
185 + }
186 + getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_SERVICE_AND_MANAGER, this);
187 +
179 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() + 188 searchAndDeleteTempDir(getJavaFileInfo().getBaseCodeGenPath() +
180 getJavaFileInfo().getPackageFilePath()); 189 getJavaFileInfo().getPackageFilePath());
181 searchAndDeleteTempDir(getJavaFileInfo().getPluginConfig().getCodeGenDir() + 190 searchAndDeleteTempDir(getJavaFileInfo().getPluginConfig().getCodeGenDir() +
...@@ -185,6 +194,7 @@ public class YangJavaSubModule ...@@ -185,6 +194,7 @@ public class YangJavaSubModule
185 } 194 }
186 } 195 }
187 196
197 +
188 /** 198 /**
189 * Returns notifications node list. 199 * Returns notifications node list.
190 * 200 *
......
...@@ -95,8 +95,7 @@ public final class JavaCodeSnippetGen { ...@@ -95,8 +95,7 @@ public final class JavaCodeSnippetGen {
95 * Returns the textual java code information corresponding to the import list. 95 * Returns the textual java code information corresponding to the import list.
96 * 96 *
97 * @param importInfo import info 97 * @param importInfo import info
98 - * @return the textual java code information corresponding to the import 98 + * @return the textual java code information corresponding to the import list
99 - * list
100 */ 99 */
101 public static String getImportText(JavaQualifiedTypeInfo importInfo) { 100 public static String getImportText(JavaQualifiedTypeInfo importInfo) {
102 return IMPORT + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN + NEW_LINE; 101 return IMPORT + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN + NEW_LINE;
...@@ -147,8 +146,7 @@ public final class JavaCodeSnippetGen { ...@@ -147,8 +146,7 @@ public final class JavaCodeSnippetGen {
147 } 146 }
148 147
149 /** 148 /**
150 - * Returns based on the file type and the YANG name of the file, generate the class 149 + * Returns based on the file type and the YANG name of the file, generate the class / interface definition close.
151 - * / interface definition close.
152 * 150 *
153 * @return corresponding textual java code information 151 * @return corresponding textual java code information
154 */ 152 */
......
...@@ -31,8 +31,8 @@ import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles; ...@@ -31,8 +31,8 @@ import org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles;
31 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 31 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
32 32
33 /** 33 /**
34 - * Represent the extends list for generated java classes. It holds the class details which needs 34 + * Represent the extends list for generated java classes. It holds the class details which needs to be extended by the
35 - * to be extended by the generated java code. 35 + * generated java code.
36 */ 36 */
37 public class JavaExtendsListHolder { 37 public class JavaExtendsListHolder {
38 38
......
...@@ -517,11 +517,6 @@ public final class UtilConstants { ...@@ -517,11 +517,6 @@ public final class UtilConstants {
517 public static final String IF = "if"; 517 public static final String IF = "if";
518 518
519 /** 519 /**
520 - * Static attribute for "for" syntax.
521 - */
522 - public static final String FOR = "for";
523 -
524 - /**
525 * Static attribute for of. 520 * Static attribute for of.
526 */ 521 */
527 public static final String OF = "of"; 522 public static final String OF = "of";
...@@ -1185,7 +1180,7 @@ public final class UtilConstants { ...@@ -1185,7 +1180,7 @@ public final class UtilConstants {
1185 /** 1180 /**
1186 * Static attribute for augmentation class. 1181 * Static attribute for augmentation class.
1187 */ 1182 */
1188 - public static final String AUGMENTATION = "Augmentation"; 1183 + public static final String AUGMENTED_INFO = "AugmentedInfo";
1189 1184
1190 /** 1185 /**
1191 * Static attribute for AugmentedInfo class. 1186 * Static attribute for AugmentedInfo class.
...@@ -1383,6 +1378,43 @@ public final class UtilConstants { ...@@ -1383,6 +1378,43 @@ public final class UtilConstants {
1383 public static final String JAR = "jar"; 1378 public static final String JAR = "jar";
1384 1379
1385 /** 1380 /**
1381 + * Static attribute for for.
1382 + */
1383 + public static final String FOR = "for";
1384 +
1385 + /**
1386 + * Static attribute for YangAugmentedOpParamInfo.
1387 + */
1388 + public static final String YANG_AUGMENTED_OP_PARAM_INFO = "YangAugmentedOpParamInfo";
1389 +
1390 + /**
1391 + * Static attribute for YangAugmentedOpParamInfo.
1392 + */
1393 + public static final String YANG_AUGMENTED_OP_PARAM_INFO_CLASS = "YangAugmentedOpParamInfo;\n";
1394 +
1395 + /**
1396 + * Static attribute for IllegalArgumentException.
1397 + */
1398 + public static final String ILLEGAL_ARGUMENT_EXCEPTION = "IllegalArgumentException";
1399 +
1400 + /**
1401 + * Static attribute for IllegalArgumentException.
1402 + */
1403 + public static final String ILLEGAL_ARGUMENT_EXCEPTION_MSG = "\"provided augmented info is invalid for content " +
1404 + "match.\"";
1405 +
1406 + /**
1407 + * Static attribute for throw.
1408 + */
1409 + public static final String THROW = "throw";
1410 +
1411 + /**
1412 + * Static attribute for baseClass().
1413 + */
1414 + public static final String BASE_CLASS = "BaseClass()";
1415 +
1416 +
1417 + /**
1386 * Creates an instance of util constants. 1418 * Creates an instance of util constants.
1387 */ 1419 */
1388 private UtilConstants() { 1420 private UtilConstants() {
......
...@@ -56,7 +56,7 @@ public class IetfYangFileTest { ...@@ -56,7 +56,7 @@ public class IetfYangFileTest {
56 yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/"); 56 yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/");
57 yangPluginConfig.setManagerCodeGenDir("target/ietfyang/l3vpnservice/"); 57 yangPluginConfig.setManagerCodeGenDir("target/ietfyang/l3vpnservice/");
58 58
59 - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); 59 + utilManager.translateToJava(yangPluginConfig);
60 60
61 deleteDirectory(userDir + "/target/ietfyang/"); 61 deleteDirectory(userDir + "/target/ietfyang/");
62 } 62 }
......
...@@ -50,7 +50,7 @@ public class AugmentTranslatorTest { ...@@ -50,7 +50,7 @@ public class AugmentTranslatorTest {
50 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 50 YangPluginConfig yangPluginConfig = new YangPluginConfig();
51 yangPluginConfig.setCodeGenDir("target/augmentTranslator/"); 51 yangPluginConfig.setCodeGenDir("target/augmentTranslator/");
52 yangPluginConfig.setManagerCodeGenDir("target/augmentTranslator/"); 52 yangPluginConfig.setManagerCodeGenDir("target/augmentTranslator/");
53 - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); 53 + utilManager.translateToJava(yangPluginConfig);
54 54
55 deleteDirectory("target/augmentTranslator/"); 55 deleteDirectory("target/augmentTranslator/");
56 } 56 }
......
...@@ -638,7 +638,7 @@ public class InterFileLinkingTest { ...@@ -638,7 +638,7 @@ public class InterFileLinkingTest {
638 yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/"); 638 yangPluginConfig.setCodeGenDir("target/interfilewithusesreferringtype/");
639 yangPluginConfig.setManagerCodeGenDir("target/interfilewithusesreferringtype/"); 639 yangPluginConfig.setManagerCodeGenDir("target/interfilewithusesreferringtype/");
640 640
641 - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); 641 + utilManager.translateToJava(yangPluginConfig);
642 642
643 deleteDirectory("target/interfilewithusesreferringtype/"); 643 deleteDirectory("target/interfilewithusesreferringtype/");
644 644
...@@ -660,7 +660,7 @@ public class InterFileLinkingTest { ...@@ -660,7 +660,7 @@ public class InterFileLinkingTest {
660 yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/"); 660 yangPluginConfig.setCodeGenDir("target/file1UsesFile2TypeDefFile3Type/");
661 yangPluginConfig.setManagerCodeGenDir("target/file1UsesFile2TypeDefFile3Type/"); 661 yangPluginConfig.setManagerCodeGenDir("target/file1UsesFile2TypeDefFile3Type/");
662 662
663 - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); 663 + utilManager.translateToJava(yangPluginConfig);
664 664
665 deleteDirectory("target/file1UsesFile2TypeDefFile3Type/"); 665 deleteDirectory("target/file1UsesFile2TypeDefFile3Type/");
666 666
...@@ -682,7 +682,7 @@ public class InterFileLinkingTest { ...@@ -682,7 +682,7 @@ public class InterFileLinkingTest {
682 yangPluginConfig.setCodeGenDir("target/interfileietf/"); 682 yangPluginConfig.setCodeGenDir("target/interfileietf/");
683 yangPluginConfig.setManagerCodeGenDir("target/interfileietf/"); 683 yangPluginConfig.setManagerCodeGenDir("target/interfileietf/");
684 684
685 - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); 685 + utilManager.translateToJava(yangPluginConfig);
686 686
687 deleteDirectory("target/interfileietf/"); 687 deleteDirectory("target/interfileietf/");
688 688
...@@ -704,7 +704,7 @@ public class InterFileLinkingTest { ...@@ -704,7 +704,7 @@ public class InterFileLinkingTest {
704 yangPluginConfig.setCodeGenDir("target/usesInContainer/"); 704 yangPluginConfig.setCodeGenDir("target/usesInContainer/");
705 yangPluginConfig.setManagerCodeGenDir("target/usesInContainer/"); 705 yangPluginConfig.setManagerCodeGenDir("target/usesInContainer/");
706 706
707 - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); 707 + utilManager.translateToJava(yangPluginConfig);
708 708
709 deleteDirectory("target/usesInContainer/"); 709 deleteDirectory("target/usesInContainer/");
710 710
...@@ -726,7 +726,7 @@ public class InterFileLinkingTest { ...@@ -726,7 +726,7 @@ public class InterFileLinkingTest {
726 yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/"); 726 yangPluginConfig.setCodeGenDir("target/groupingNodeSameAsModule/");
727 yangPluginConfig.setManagerCodeGenDir("target/groupingNodeSameAsModule/"); 727 yangPluginConfig.setManagerCodeGenDir("target/groupingNodeSameAsModule/");
728 728
729 - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); 729 + utilManager.translateToJava(yangPluginConfig);
730 730
731 deleteDirectory("target/groupingNodeSameAsModule/"); 731 deleteDirectory("target/groupingNodeSameAsModule/");
732 732
......
...@@ -191,7 +191,7 @@ public class InterJarLinkerTest { ...@@ -191,7 +191,7 @@ public class InterJarLinkerTest {
191 yangPluginConfig.setCodeGenDir(TARGET); 191 yangPluginConfig.setCodeGenDir(TARGET);
192 yangPluginConfig.setManagerCodeGenDir(TARGET); 192 yangPluginConfig.setManagerCodeGenDir(TARGET);
193 193
194 - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); 194 + utilManager.translateToJava(yangPluginConfig);
195 195
196 testIfFlowClassifierFilesExists(); 196 testIfFlowClassifierFilesExists();
197 testIfPortPairFileDoesNotExist(); 197 testIfPortPairFileDoesNotExist();
...@@ -308,6 +308,7 @@ public class InterJarLinkerTest { ...@@ -308,6 +308,7 @@ public class InterJarLinkerTest {
308 308
309 for (YangNode node : interJarResolvedNodes) { 309 for (YangNode node : interJarResolvedNodes) {
310 YangFileInfo dependentFileInfo = new YangFileInfo(); 310 YangFileInfo dependentFileInfo = new YangFileInfo();
311 + node.setToTranslate(false);
311 dependentFileInfo.setRootNode(node); 312 dependentFileInfo.setRootNode(node);
312 dependentFileInfo.setForTranslator(false); 313 dependentFileInfo.setForTranslator(false);
313 dependentFileInfo.setYangFileName(node.getName()); 314 dependentFileInfo.setYangFileName(node.getName());
......
...@@ -44,7 +44,7 @@ public class ManagerCodeGeneratorTest { ...@@ -44,7 +44,7 @@ public class ManagerCodeGeneratorTest {
44 @Test 44 @Test
45 public void processManagerTranslator() throws IOException, ParserException, MojoExecutionException { 45 public void processManagerTranslator() throws IOException, ParserException, MojoExecutionException {
46 46
47 - String searchDir = "src/test/resources/manager"; 47 + String searchDir = "src/test/resources/manager/singleChild";
48 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); 48 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
49 utilManager.parseYangFileInfoSet(); 49 utilManager.parseYangFileInfoSet();
50 utilManager.createYangNodeSet(); 50 utilManager.createYangNodeSet();
...@@ -54,7 +54,7 @@ public class ManagerCodeGeneratorTest { ...@@ -54,7 +54,7 @@ public class ManagerCodeGeneratorTest {
54 yangPluginConfig.setCodeGenDir("target/manager/"); 54 yangPluginConfig.setCodeGenDir("target/manager/");
55 yangPluginConfig.setManagerCodeGenDir("target/manager/"); 55 yangPluginConfig.setManagerCodeGenDir("target/manager/");
56 56
57 - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); 57 + utilManager.translateToJava(yangPluginConfig);
58 String file1 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5Manager.java"; 58 String file1 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5Manager.java";
59 String file2 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test6Manager.java"; 59 String file2 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test6Manager.java";
60 String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java"; 60 String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java";
...@@ -79,7 +79,7 @@ public class ManagerCodeGeneratorTest { ...@@ -79,7 +79,7 @@ public class ManagerCodeGeneratorTest {
79 public void processManagerInDifferentPackageTranslator() throws IOException, ParserException, 79 public void processManagerInDifferentPackageTranslator() throws IOException, ParserException,
80 MojoExecutionException { 80 MojoExecutionException {
81 81
82 - String searchDir = "src/test/resources/manager"; 82 + String searchDir = "src/test/resources/manager/singleChild";
83 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir)); 83 utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
84 utilManager.parseYangFileInfoSet(); 84 utilManager.parseYangFileInfoSet();
85 utilManager.createYangNodeSet(); 85 utilManager.createYangNodeSet();
...@@ -87,10 +87,10 @@ public class ManagerCodeGeneratorTest { ...@@ -87,10 +87,10 @@ public class ManagerCodeGeneratorTest {
87 87
88 YangPluginConfig yangPluginConfig = new YangPluginConfig(); 88 YangPluginConfig yangPluginConfig = new YangPluginConfig();
89 yangPluginConfig.setCodeGenDir("target/manager/"); 89 yangPluginConfig.setCodeGenDir("target/manager/");
90 - yangPluginConfig.setManagerCodeGenDir("target/manager1/"); 90 + yangPluginConfig.setManagerCodeGenDir("target/manager/");
91 91
92 - utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig); 92 + utilManager.translateToJava(yangPluginConfig);
93 - String file3 = "target/manager1/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java"; 93 + String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java";
94 94
95 File manager3 = new File(file3); 95 File manager3 = new File(file3);
96 assertThat(true, is(manager3.exists())); 96 assertThat(true, is(manager3.exists()));
...@@ -98,4 +98,48 @@ public class ManagerCodeGeneratorTest { ...@@ -98,4 +98,48 @@ public class ManagerCodeGeneratorTest {
98 deleteDirectory("target/manager/"); 98 deleteDirectory("target/manager/");
99 deleteDirectory("target/manager1/"); 99 deleteDirectory("target/manager1/");
100 } 100 }
101 +
102 + /**
103 + * Checks manager translation in different package should not result in any exception.
104 + *
105 + * @throws MojoExecutionException
106 + */
107 + @Test
108 + public void processManagerforMultiChildTranslator() throws IOException, ParserException,
109 + MojoExecutionException {
110 +
111 + String searchDir = "src/test/resources/manager/MultiChild";
112 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
113 + utilManager.parseYangFileInfoSet();
114 + utilManager.createYangNodeSet();
115 + utilManager.resolveDependenciesUsingLinker();
116 +
117 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
118 + yangPluginConfig.setCodeGenDir("target/manager/");
119 + yangPluginConfig.setManagerCodeGenDir("target/manager/");
120 +
121 + utilManager.translateToJava(yangPluginConfig);
122 + String file1 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test5Manager.java";
123 +
124 + File manager1 = new File(file1);
125 + assertThat(false, is(manager1.exists()));
126 +
127 + String file2 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test6Manager.java";
128 +
129 + File manager2 = new File(file2);
130 + assertThat(false, is(manager2.exists()));
131 +
132 + String file3 = "target/manager/org/onosproject/yang/gen/v1/test5/test/rev20160704/Test7Manager.java";
133 +
134 + File manager3 = new File(file3);
135 + assertThat(false, is(manager3.exists()));
136 +
137 + String file4 = "target/manager/org/onosproject/yang/gen/v1/test8/test/rev20160704/Test8Manager.java";
138 +
139 + File manager4 = new File(file4);
140 + assertThat(true, is(manager4.exists()));
141 +
142 + deleteDirectory("target/manager/");
143 + deleteDirectory("target/manager1/");
144 + }
101 } 145 }
......
1 +module test5 {
2 + namespace "test5:test";
3 + prefix test ;
4 +
5 + revision "2016-07-04" {
6 + description "Initial revision.";
7 + }
8 + typedef typedef1 {
9 + type int32;
10 + }
11 + typedef typedef2 {
12 + type int32;
13 + }
14 + typedef typedef3 {
15 + type int32;
16 + }
17 +
18 +}
1 +submodule test6 {
2 +
3 + belongs-to "test5" {
4 + prefix "test";
5 + }
6 +
7 + revision "2016-07-04" {
8 + description "Initial revision.";
9 + }
10 + grouping grouping1 {
11 + leaf leaf1 {
12 + type int32;
13 + }
14 + }
15 + grouping grouping2 {
16 + leaf leaf1 {
17 + type int32;
18 + }
19 + }
20 +
21 + grouping grouping3 {
22 + leaf leaf1 {
23 + type int32;
24 + }
25 + }
26 +}
1 +module test7 {
2 + namespace "test5:test";
3 + prefix test ;
4 +
5 + revision "2016-07-04" {
6 + description "Initial revision.";
7 + }
8 +
9 + grouping grouping1 {
10 + leaf leaf1 {
11 + type int32;
12 + }
13 + }
14 +
15 + typedef typedef3 {
16 + type int32;
17 + }
18 +
19 +}
1 +module test8 {
2 + namespace "test8:test";
3 + prefix test ;
4 +
5 + revision "2016-07-04" {
6 + description "Initial revision.";
7 + }
8 +
9 + grouping grouping1 {
10 + leaf leaf1 {
11 + type int32;
12 + }
13 + }
14 +
15 + typedef typedef3 {
16 + type int32;
17 + }
18 +
19 + container container2 {
20 + }
21 +
22 +}
...@@ -5,7 +5,7 @@ module test5 { ...@@ -5,7 +5,7 @@ module test5 {
5 revision "2016-07-04" { 5 revision "2016-07-04" {
6 description "Initial revision."; 6 description "Initial revision.";
7 } 7 }
8 - typedef abc { 8 + typedef typedef1 {
9 type int32; 9 type int32;
10 } 10 }
11 11
......
...@@ -7,7 +7,7 @@ submodule test6 { ...@@ -7,7 +7,7 @@ submodule test6 {
7 revision "2016-07-04" { 7 revision "2016-07-04" {
8 description "Initial revision."; 8 description "Initial revision.";
9 } 9 }
10 - grouping abc { 10 + grouping grouping1 {
11 leaf leaf1 { 11 leaf leaf1 {
12 type int32; 12 type int32;
13 } 13 }
......
...@@ -6,8 +6,7 @@ module test7 { ...@@ -6,8 +6,7 @@ module test7 {
6 description "Initial revision."; 6 description "Initial revision.";
7 } 7 }
8 8
9 - leaf abc { 9 + container cont1 {
10 - type int32;
11 } 10 }
12 11
13 } 12 }
......