import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.*;
import static org.opendaylight.yangtools.binding.generator.util.BindingTypes.*;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.*;
-
+import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort\r
\r
public class BindingGeneratorImpl implements BindingGenerator {\r
\r
schemaContext = context;\r
typeProvider = new TypeProviderImpl(context);\r
val Set<Module> modules = context.modules;\r
- genTypeBuilders = new HashMap();\r
- for (module : modules) {\r
-\r
- generatedTypes.addAll(allGroupingsToGenTypes(module));\r
-\r
- if (false == module.childNodes.isEmpty()) {\r
- generatedTypes.add(moduleToDataType(module));\r
- }\r
- generatedTypes.addAll(allTypeDefinitionsToGenTypes(module));\r
- generatedTypes.addAll(allContainersToGenTypes(module));\r
- generatedTypes.addAll(allListsToGenTypes(module));\r
- generatedTypes.addAll(allChoicesToGenTypes(module));\r
- generatedTypes.addAll(allRPCMethodsToGenType(module));\r
- generatedTypes.addAll(allNotificationsToGenType(module));\r
- generatedTypes.addAll(allIdentitiesToGenTypes(module, context));\r
- }\r
- for (module : modules) {\r
- generatedTypes.addAll(allAugmentsToGenTypes(module));\r
- \r
- }\r
- return generatedTypes;\r
+ return generateTypes(context,modules);
}\r
\r
/**\r
checkState(context.modules !== null,"Schema Context does not contain defined modules.");\r
checkArgument(modules !== null,"Set of Modules cannot be NULL.");\r
\r
- val List<Type> filteredGenTypes = new ArrayList();\r
+ val List<Type> filteredGenTypes = new ArrayList();
+ \r
schemaContext = context;\r
typeProvider = new TypeProviderImpl(context);\r
- val Set<Module> contextModules = context.modules;\r
+ val contextModules = ModuleDependencySort.sort(context.modules);\r
genTypeBuilders = new HashMap();\r
\r
for (contextModule : contextModules) {\r
val List<Type> generatedTypes = new ArrayList();\r
-\r
+ generatedTypes.addAll(allTypeDefinitionsToGenTypes(contextModule));\r
generatedTypes.addAll(allGroupingsToGenTypes(contextModule));\r
if (false == contextModule.childNodes.isEmpty()) {\r
generatedTypes.add(moduleToDataType(contextModule));\r
}\r
- generatedTypes.addAll(allTypeDefinitionsToGenTypes(contextModule));\r
generatedTypes.addAll(allContainersToGenTypes(contextModule));\r
generatedTypes.addAll(allListsToGenTypes(contextModule));\r
generatedTypes.addAll(allChoicesToGenTypes(contextModule));\r
checkArgument(module.name !== null,"Module name cannot be NULL.");\r
val Set<TypeDefinition<?>> typeDefinitions = module.typeDefinitions;\r
checkState(typeDefinitions !== null,'''Type Definitions for module «module.name» cannot be NULL.''');\r
-\r
\r
val List<Type> generatedTypes = new ArrayList();\r
for ( TypeDefinition<?> typedef : typeDefinitions) {\r
// and DataObject interface!!!\r
val targetPath = augSchema.targetPath;\r
val targetSchemaNode = findDataSchemaNode(schemaContext, targetPath);\r
- var targetType = yangToJavaMapping.get(targetSchemaNode.path);\r
- if(targetType == null) {\r
- // FIXME: augmentation should be added as last, all types should already be generated\r
- // and have assigned Java Types,\r
- val targetModule = findParentModule(schemaContext, targetSchemaNode);\r
- val targetBasePackage = moduleNamespaceToPackageName(targetModule);\r
- val typePackage = packageNameForGeneratedType(targetBasePackage, targetSchemaNode.getPath());\r
- val targetSchemaNodeName = targetSchemaNode.getQName().getLocalName();\r
- val typeName = parseToClassName(targetSchemaNodeName);\r
- targetType = new ReferencedTypeImpl(typePackage,typeName);\r
- }\r
if (targetSchemaNode !== null) {\r
+ var targetType = yangToJavaMapping.get(targetSchemaNode.path);
+ if(targetType == null) {
+ // FIXME: augmentation should be added as last, all types should already be generated
+ // and have assigned Java Types,
+ val targetModule = findParentModule(schemaContext, targetSchemaNode);
+ val targetBasePackage = moduleNamespaceToPackageName(targetModule);
+ val typePackage = packageNameForGeneratedType(targetBasePackage, targetSchemaNode.getPath());
+ val targetSchemaNodeName = targetSchemaNode.getQName().getLocalName();
+ val typeName = parseToClassName(targetSchemaNodeName);
+ targetType = new ReferencedTypeImpl(typePackage,typeName);
+ }
val augChildNodes = augSchema.childNodes;\r
if (!(targetSchemaNode instanceof ChoiceNode)) {\r
val augTypeBuilder = addRawAugmentGenTypeDefinition(augmentPackageName,\r
*/
private Type provideTypeForIdentityref(IdentityrefTypeDefinition idref) {
QName baseIdQName = idref.getIdentity();
- Module module = schemaContext.findModuleByNamespace(baseIdQName.getNamespace());
+ Module module = schemaContext.findModuleByNamespaceAndRevision(baseIdQName.getNamespace(),baseIdQName.getRevision());
IdentitySchemaNode identity = null;
for (IdentitySchemaNode id : module.getIdentities()) {
if (id.getQName().equals(baseIdQName)) {
assertNotNull("Lf TO wasn't found.", lfLeaf);
assertEquals("Lf TO has incorrect number of occurences.", 1, lfLeafCounter);
assertEquals("Lf has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev2013626.ParentContainer",
+ "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
lfLeaf.getPackageName());
assertEquals("Lf generated TO has incorrect number of properties", 2, lfLeaf.getProperties().size());
assertNotNull("Lf1 TO wasn't found.", lf1Leaf);
assertEquals("Lf1 TO has incorrect number of occurences.", 1, lf1LeafCounter);
assertEquals("Lf1 has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev2013626.ParentContainer",
+ "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
lf1Leaf.getPackageName());
assertEquals("Lf generated TO has incorrect number of properties", 4, lf1Leaf.getProperties().size());
assertNotNull("Lf2 TO wasn't found.", lf2Leaf);
assertEquals("Lf2 TO has incorrect number of occurences.", 1, lf2LeafCounter);
assertEquals("Lf2 has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev2013626.ParentContainer",
+ "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
lf2Leaf.getPackageName());
assertEquals("Lf generated TO has incorrect number of properties", 2, lf2Leaf.getProperties().size());
assertNotNull("TypeUnion TO wasn't found.", typeUnionTypedef);
assertEquals("TypeUnion TO has incorrect number of occurences.", 1, typeUnionTypedefCounter);
assertEquals("TypeUnion has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev2013626", typeUnionTypedef.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnionTypedef.getPackageName());
assertEquals("TypeUnion generated TO has incorrect number of properties", 2, typeUnionTypedef.getProperties()
.size());
assertEquals("TypeUnion1 TO has incorrect number of occurences.", 1, typeUnion1Counter);
assertEquals("TypeUnion1 has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev2013626", typeUnion1.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion1.getPackageName());
assertEquals("TypeUnion1 generated TO has incorrect number of properties", 4, typeUnion1.getProperties().size());
assertEquals("TypeUnion2 TO has incorrect number of occurences.", 1, typeUnion2Counter);
assertEquals("TypeUnion2 has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev2013626", typeUnion2.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626", typeUnion2.getPackageName());
assertEquals("TypeUnion2 generated TO has incorrect number of properties", 2, typeUnion2.getProperties().size());
containsAttributes(typeUnion2, true, true, true, new NameTypePattern("string", "String"));
assertNotNull("UnionLeaf TO wasn't found.", unionLeaf);
assertEquals("BitLeaf has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev2013626.ParentContainer",
+ "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
bitLeaf.getPackageName());
assertEquals("UnionLeaf has incorrect package name.",
- "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev2013626.ParentContainer",
+ "org.opendaylight.yang.gen.v1.urn.bit.union.in.leaf.rev130626.ParentContainer",
bitLeaf.getPackageName());
List<GeneratedProperty> propertiesBitLeaf = bitLeaf.getProperties();
assertFalse("genTypes is empty", genTypes.isEmpty());
// test for file choice-monitoring
- String pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.choice.monitoring.rev201371.netconf.state.datastores.datastore.locks";
+ String pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.choice.monitoring.rev130701.netconf.state.datastores.datastore.locks";
GeneratedType genType = null;
checkGeneratedType(genTypes, "LockType", pcgPref); // choice
// test for file augment-monitoring
// augment
// "/nm:netconf-state/nm:datastores/nm:datastore/nm:locks/nm:lock-type"
- pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.augment.monitoring.rev201371";
+ pcgPref = "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.augment.monitoring.rev130701";
genType = null;
genType = checkGeneratedType(genTypes, "AutonomousLock", pcgPref
GeneratedType genInterface = null;\r
for (final Type type : genTypes) {\r
if (type instanceof GeneratedType) {\r
- if (type.getPackageName().equals("org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev201328.topology.interfaces")\r
+ if (type.getPackageName().equals("org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208.topology.interfaces")\r
&& type.getName().equals("Interface")) {\r
genInterface = (GeneratedType) type;\r
}\r
assertTrue("Expected LinkUpDownTrapEnable of type ReferencedTypeImpl",\r
linkUpDownTrapEnable instanceof ReferencedTypeImpl);\r
assertEquals(linkUpDownTrapEnable.getPackageName(),\r
- "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev20121115.interfaces.Interface");\r
+ "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");\r
\r
assertNotNull("Expected Referenced Enum OperStatus, but was NULL!",\r
operStatus);\r
assertTrue("Expected OperStatus of type ReferencedTypeImpl",\r
operStatus instanceof ReferencedTypeImpl);\r
assertEquals(operStatus.getPackageName(),\r
- "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev20121115.interfaces.Interface");\r
+ "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");\r
}\r
}\r
assertNotNull("Generated type for grouping-U wasn't generated.", groupingU);
assertEquals("GroupingU interface generated more than one time.", 1, groupingUCounter);
assertEquals("GroupingU is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev2013718", groupingU.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingU.getPackageName());
assertNotNull("Generated type for grouping-V wasn't generated.", groupingV);
assertEquals("GroupingV interface generated more than one time.", 1, groupingVCounter);
assertEquals("GroupingV is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev2013718", groupingV.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingV.getPackageName());
assertNotNull("Generated type for grouping-X wasn't generated.", groupingX);
assertEquals("GroupingX interface generated more than one time.", 1, groupingXCounter);
assertEquals("GroupingX is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev2013718", groupingX.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.dependencies.rev130718", groupingX.getPackageName());
containsInterface("GroupingV", groupingU);
containsInterface("GroupingX", groupingU);
assertEquals("Case C interface generated more than one time.", 1, caseCCounter);
assertEquals(
"Case C is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev2013718.container.with.choicetest.choice.test",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev130718.container.with.choicetest.choice.test",
caseC.getPackageName());
assertNotNull("Generated type for grouping-case-test wasn't generated.", groupingCaseTest);
assertEquals("GroupingCaseTest interface generated more than one time.", 1, groupingCaseTestCounter);
assertEquals("GroupingCaseTest is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev2013718", groupingCaseTest.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses._case.rev130718", groupingCaseTest.getPackageName());
containsInterface("GroupingCaseTest", caseC);
assertTrue("Case C shouldn't contain any method.", caseC.getMethodDefinitions().isEmpty());
assertEquals("GroupingContainerTest interface - incorrect number of occurences", 1,
groupingContainerTestCounter);
assertEquals("GroupingContainerTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev2013718",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev130718",
groupingContainerTest.getPackageName());
assertNotNull("Generated type for container-test wasn't generated", containerTest);
assertEquals("ContainerTest interface - incorrect number of occurences", 1, containerTestCount);
assertEquals("ContainerTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev2013718", containerTest.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.container.rev130718", containerTest.getPackageName());
containsInterface("GroupingContainerTest", containerTest);
assertNotNull("Generated type for grouping-grouping-test wasn't generated", groupingGroupingTest);
assertEquals("GroupingGroupingTest interface - incorrect number of occurences", 1, groupingGroupingTestCounter);
assertEquals("GroupingGroupingTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev2013718",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev130718",
groupingGroupingTest.getPackageName());
assertNotNull("Generated type for grouping-test wasn't generated", groupingTest);
assertEquals("GroupingTest interface - incorrect number of occurences", 1, groupingTestCount);
assertEquals("GroupingTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev2013718", groupingTest.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.grouping.rev130718", groupingTest.getPackageName());
containsInterface("GroupingGroupingTest", groupingTest);
assertNotNull("Generated type for grouping-list-test wasn't generated", groupingListTest);
assertEquals("GroupingListTest interface - incorrect number of occurences", 1, groupingListTestCounter);
assertEquals("GroupingListTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev2013718", groupingListTest.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718", groupingListTest.getPackageName());
assertNotNull("Generated type for list-test wasn't generated", listTest);
assertEquals("ListTest interface - incorrect number of occurences", 1, listTestCounter);
assertEquals("ListTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev2013718", listTest.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718", listTest.getPackageName());
assertNotNull("Generated type for container-grouping-list-test wasn't generated", containerGroupingListTest);
assertEquals("ContainerGroupingListTest interface - incorrect number of occurences", 1,
containerGroupingListTestCounter);
assertEquals("ContainerGroupingListTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev2013718.grouping.list.test",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718.grouping.list.test",
containerGroupingListTest.getPackageName());
assertNotNull("Generated type for list-grouping-list-test wasn't generated", listGroupingListTest);
assertEquals("ListGroupingListTest interface - incorrect number of occurences", 1, listGroupingListTestCounter);
assertEquals("ListGroupingListTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev2013718.grouping.list.test",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.list.rev130718.grouping.list.test",
listGroupingListTest.getPackageName());
containsInterface("GroupingListTest", listTest);
assertNotNull("Generated type for grouping-list-test wasn't generated", groupingModulTest);
assertEquals("GroupingModulTest interface - incorrect number of occurences", 1, groupingModulTestCounter);
assertEquals("GroupingModulTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev2013718", groupingModulTest.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev130718", groupingModulTest.getPackageName());
assertNotNull("Generated type for modul wasn't generated", groupingUsesModulData);
assertEquals("GroupingUsesModulData interface - incorrect number of occurences", 1,
groupingUsesModulDataCounter);
assertEquals("GroupingUsesModulData isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev2013718",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.modul.rev130718",
groupingUsesModulData.getPackageName());
containsInterface("GroupingModulTest", groupingUsesModulData);
assertNotNull("Generated type for RPC test input wasn't generated", rpcTestInput);
assertEquals("RpcTestInput interface - incorrect number of occurences", 1, rpcTestInputCounter);
assertEquals("RpcTestInput isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev2013718", rpcTestInput.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestInput.getPackageName());
assertNotNull("Generated type for RPC test output wasn't generated", rpcTestOutput);
assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, rpcTestOutputCounter);
assertEquals("RpcTestOutput isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev2013718", rpcTestOutput.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", rpcTestOutput.getPackageName());
assertNotNull("Generated type for grouping-rpc-input-test wasn't generated", groupingRpcInputTest);
assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, groupingRpcInputTestCounter);
assertEquals("GroupingRpcInputTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev2013718", groupingRpcInputTest.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", groupingRpcInputTest.getPackageName());
assertNotNull("Generated type for grouping-rpc-output-test wasn't generated", groupingRpcOutputTest);
assertEquals("RpcTestOutput interface - incorrect number of occurences", 1, groupingRpcOutputTestCounter);
assertEquals("GroupingRpcOutputTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev2013718", groupingRpcOutputTest.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718", groupingRpcOutputTest.getPackageName());
assertNotNull("Generated type for container-grouping-rpc-input-test wasn't generated",
containerGroupingRpcInputTest);
assertEquals("ContainerGroupingRpcInputTest interface - incorrect number of occurences", 1,
containerGroupingRpcInputTestCounter);
assertEquals("ContainerGroupingRpcInputTest isn't in correct package",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev2013718.grouping.rpc.input.test",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.rpc.rev130718.grouping.rpc.input.test",
containerGroupingRpcInputTest.getPackageName());
containsInterface("GroupingRpcInputTest", rpcTestInput);
assertNotNull("Generated type for augment /container-augment wasn't generated.", containerAugment1);
assertEquals("ContainerAugment1 interface generated more than one time.", 1, containerAugment1Counter);
assertEquals("ContainerAugment1 is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev2013718", containerAugment1.getPackageName());
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev130718", containerAugment1.getPackageName());
assertNotNull("Generated type for grouping-augment-test wasn't generated.", groupingAugmentTest);
assertEquals("GroupingAugmentTest interface generated more than one time.", 1, groupingAugmentTestCounter);
assertEquals("groupingAugmentTest is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev2013718",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.augment.rev130718",
groupingAugmentTest.getPackageName());
containsInterface("GroupingAugmentTest", containerAugment1);
assertNotNull("Generated type for notification-test wasn't generated.", notificationTest);
assertEquals("NotificationTest interface generated more than one time.", 1, notificationTestCounter);
assertEquals("NotificationTest is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev2013718",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718",
notificationTest.getPackageName());
assertNotNull("Generated type for grouping-notification-test wasn't generated.", groupingNotificationTest);
assertEquals("GroupingNotificationTest interface generated more than one time.", 1,
groupingNotificationTestCounter);
assertEquals("groupingNotificationTest is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev2013718",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718",
groupingNotificationTest.getPackageName());
assertNotNull("Generated type for container-grouping-notification-test wasn't generated.",
assertEquals("ContainerGroupingNotificationTest interface generated more than one time.", 1,
containerGroupingNotificationTestCounter);
assertEquals("ContainerGroupingNotificationTest is in wrong package.",
- "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev2013718.grouping.notification.test",
+ "org.opendaylight.yang.gen.v1.urn.grouping.uses.notification.rev130718.grouping.notification.test",
containerGroupingNotificationTest.getPackageName());
containsInterface("GroupingNotificationTest", notificationTest);
package org.opendaylight.yangtools.binding.generator.util;\r
\r
+import java.text.DateFormat;\r
+import java.text.SimpleDateFormat;\r
import java.util.Arrays;\r
import java.util.Calendar;\r
import java.util.HashSet;\r
*/\r
public final class BindingGeneratorUtil {\r
\r
+ private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyMMdd");\r
+ \r
/**\r
* Array of strings values which represents JAVA reserved words.\r
*/\r
public static String moduleNamespaceToPackageName(final Module module) {\r
final StringBuilder packageNameBuilder = new StringBuilder();\r
\r
- final Calendar calendar = Calendar.getInstance();\r
if (module.getRevision() == null) {\r
throw new IllegalArgumentException("Module " + module.getName() + " does not specify revision date!");\r
}\r
namespace = namespace.replace("=", ".");\r
\r
packageNameBuilder.append(namespace);\r
- calendar.setTime(module.getRevision());\r
packageNameBuilder.append(".rev");\r
- packageNameBuilder.append(calendar.get(Calendar.YEAR));\r
- packageNameBuilder.append((calendar.get(Calendar.MONTH) + 1));\r
- packageNameBuilder.append(calendar.get(Calendar.DAY_OF_MONTH));\r
-\r
+ packageNameBuilder.append(DATE_FORMAT.format(module.getRevision()));\r
+ \r
return validateJavaPackage(packageNameBuilder.toString());\r
}\r
\r
* @return module instance which has namespace equal to the
* <code>namespace</code> or <code>null</code> in other cases
*/
- Module findModuleByNamespace(final URI namespace);
+ Set<Module> findModuleByNamespace(final URI namespace);
+
+ Module findModuleByNamespaceAndRevision(final URI namespace,final Date revision);
}
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition
import java.io.ObjectOutputStream.PutField
import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
+import java.util.Date
/**
* The Schema Context Util contains support methods for searching through Schema Context modules for specified schema
* <code>null</code> if the Node is not present.
*/
public static def SchemaNode findDataSchemaNode( SchemaContext context, SchemaPath schemaPath) {
- if (context == null) {
+ if (context === null) {
throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
}
- if (schemaPath == null) {
+ if (schemaPath === null) {
throw new IllegalArgumentException("Schema Path reference cannot be NULL");
}
val prefixedPath = (schemaPath.getPath());
*/
public static def SchemaNode findDataSchemaNode( SchemaContext context, Module module,
RevisionAwareXPath nonCondXPath) {
- if (context == null) {
+ if (context === null) {
throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
}
- if (module == null) {
+ if (module === null) {
throw new IllegalArgumentException("Module reference cannot be NULL!");
}
- if (nonCondXPath == null) {
+ if (nonCondXPath === null) {
throw new IllegalArgumentException("Non Conditional Revision Aware XPath cannot be NULL!");
}
*/
public static def SchemaNode findDataSchemaNodeForRelativeXPath( SchemaContext context, Module module,
SchemaNode actualSchemaNode, RevisionAwareXPath relativeXPath) {
- if (context == null) {
+ if (context === null) {
throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
}
- if (module == null) {
+ if (module === null) {
throw new IllegalArgumentException("Module reference cannot be NULL!");
}
- if (actualSchemaNode == null) {
+ if (actualSchemaNode === null) {
throw new IllegalArgumentException("Actual Schema Node reference cannot be NULL!");
}
- if (relativeXPath == null) {
+ if (relativeXPath === null) {
throw new IllegalArgumentException("Non Conditional Revision Aware XPath cannot be NULL!");
}
if (relativeXPath.isAbsolute()) {
* the method will returns <code>null</code>
*/
public static def Module findParentModule( SchemaContext context, SchemaNode schemaNode) {
- if (context == null) {
+ if (context === null) {
throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
}
- if (schemaNode == null) {
+ if (schemaNode === null) {
throw new IllegalArgumentException("Schema Node cannot be NULL!");
}
val schemaPath = schemaNode.getPath();
- if (schemaPath == null) {
+ if (schemaPath === null) {
throw new IllegalStateException("Schema Path for Schema Node is not "
+ "set properly (Schema Path is NULL)");
}
- val qnamedPath = schemaPath.getPath();
- if (qnamedPath == null || qnamedPath.isEmpty()) {
+ val qnamedPath = schemaPath.path;
+ if (qnamedPath === null || qnamedPath.empty) {
throw new IllegalStateException("Schema Path contains invalid state of path parts."
+ "The Schema Path MUST contain at least ONE QName which defines namespace and Local name"
+ "of path.");
}
val qname = qnamedPath.get(qnamedPath.size() - 1);
- return context.findModuleByNamespace(qname.getNamespace());
+ return context.findModuleByNamespaceAndRevision(qname.namespace,qname.revision);
}
/**
*/
private static def SchemaNode findSchemaNodeForGivenPath( SchemaContext context, Module module,
Queue<QName> qnamedPath) {
- if (context == null) {
+ if (context === null) {
throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
}
- if (module == null) {
+ if (module === null) {
throw new IllegalArgumentException("Module reference cannot be NULL!");
}
- if (module.getNamespace() == null) {
+ if (module.getNamespace() === null) {
throw new IllegalArgumentException("Namespace for Module cannot contains NULL reference!");
}
- if (qnamedPath == null || qnamedPath.isEmpty()) {
+ if (qnamedPath === null || qnamedPath.isEmpty()) {
throw new IllegalStateException("Schema Path contains invalid state of path parts."
+ "The Schema Path MUST contain at least ONE QName which defines namespace and Local name"
+ "of path.");
while ((nextNode != null) && !qnamedPath.isEmpty()) {
childNodeQName = qnamedPath.peek();
if (childNodeQName != null) {
- val URI childNodeNamespace = childNodeQName.getNamespace();
-
schemaNode = nextNode.getDataChildByName(childNodeQName.getLocalName());
- if(schemaNode == null && nextNode instanceof Module) {
+ if(schemaNode === null && nextNode instanceof Module) {
schemaNode = (nextNode as Module).getNotificationByName(childNodeQName);
}
- if(schemaNode == null && nextNode instanceof Module) {
+ if(schemaNode === null && nextNode instanceof Module) {
}
+ val URI childNamespace = childNodeQName.getNamespace();
+ val Date childRevision = childNodeQName.getRevision();
+
if (schemaNode != null) {
if (schemaNode instanceof ContainerSchemaNode) {
nextNode = schemaNode as ContainerSchemaNode;
} else {
nextNode = null;
}
- } else if (!childNodeNamespace.equals(moduleNamespace)) {
- val Module nextModule = context.findModuleByNamespace(childNodeNamespace);
+ } else if (!childNamespace.equals(moduleNamespace)) {
+ val Module nextModule = context.findModuleByNamespaceAndRevision(childNamespace,childRevision);
schemaNode = findSchemaNodeForGivenPath(context, nextModule, qnamedPath);
return schemaNode;
}
private static def SchemaNode findNodeInSchemaContext(SchemaContext context, List<QName> path) {
val current = path.get(0);
- val module = context.findModuleByNamespace(current.namespace);
- if(module == null) return null;
+ val module = context.findModuleByNamespaceAndRevision(current.namespace,current.revision);
+ if(module === null) return null;
return findNodeInModule(module,path);
}
*/
private static def xpathToQNamePath( SchemaContext context, Module parentModule,
String xpath) {
- if (context == null) {
+ if (context === null) {
throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
}
- if (parentModule == null) {
+ if (parentModule === null) {
throw new IllegalArgumentException("Parent Module reference cannot be NULL!");
}
- if (xpath == null) {
+ if (xpath === null) {
throw new IllegalArgumentException("XPath string reference cannot be NULL!");
}
*/
private static def QName stringPathPartToQName( SchemaContext context, Module parentModule,
String prefixedPathPart) {
- if (context == null) {
+ if (context === null) {
throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
}
- if (parentModule == null) {
+ if (parentModule === null) {
throw new IllegalArgumentException("Parent Module reference cannot be NULL!");
}
- if (prefixedPathPart == null) {
+ if (prefixedPathPart === null) {
throw new IllegalArgumentException("Prefixed Path Part cannot be NULL!");
}
* @return Module for given prefix in specified Schema Context if is present, otherwise returns <code>null</code>
*/
private static def Module resolveModuleForPrefix( SchemaContext context, Module module, String prefix) {
- if (context == null) {
+ if (context === null) {
throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
}
- if (module == null) {
+ if (module === null) {
throw new IllegalArgumentException("Module reference cannot be NULL!");
}
- if (prefix == null) {
+ if (prefix === null) {
throw new IllegalArgumentException("Prefix string cannot be NULL!");
}
private static def resolveRelativeXPath( SchemaContext context, Module module,
RevisionAwareXPath relativeXPath, SchemaNode leafrefParentNode) {
- if (context == null) {
+ if (context === null) {
throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
}
- if (module == null) {
+ if (module === null) {
throw new IllegalArgumentException("Module reference cannot be NULL!");
}
- if (relativeXPath == null) {
+ if (relativeXPath === null) {
throw new IllegalArgumentException("Non Conditional Revision Aware XPath cannot be NULL!");
}
if (relativeXPath.isAbsolute()) {
throw new IllegalArgumentException("Revision Aware XPath MUST be relative i.e. MUST contains ../, "
+ "for non relative Revision Aware XPath use findDataSchemaNode method!");
}
- if (leafrefParentNode.getPath() == null) {
+ if (leafrefParentNode.getPath() === null) {
throw new IllegalArgumentException("Schema Path reference for Leafref cannot be NULL!");
}
val absolutePath = new LinkedList<QName>();
}
@Override
- public Module findModuleByNamespace(final URI namespace) {
+ public Set<Module> findModuleByNamespace(final URI namespace) {
+ final Set<Module> ret = new HashSet<Module>();
if (namespace != null) {
for (final Module module : modules) {
if (module.getNamespace().equals(namespace)) {
- return module;
+ ret.add(module);
+ }
+ }
+ }
+ return ret;
+ }
+
+ @Override
+ public Module findModuleByNamespaceAndRevision(URI namespace, Date revision) {
+ if (namespace != null) {
+ for (final Module module : modules) {
+ if (module.getNamespace().equals(namespace) && module.getRevision().equals(revision)) {
+ return(module);
}
}
}
// suffix _g = defined in grouping from context
// get grouping
- Module contextModule = context.findModuleByNamespace(URI.create("urn:custom.nodes.test"));
+ Module contextModule = context.findModuleByNamespace(URI.create("urn:custom.nodes.test")).iterator().next();
assertNotNull(contextModule);
Set<GroupingDefinition> groupings = contextModule.getGroupings();
assertEquals(1, groupings.size());