bin
xtend-gen
target
+.DS_Store
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../common/parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>benchmarks</artifactId>
<properties>
- <yangtools.version>0.6.2-SNAPSHOT</yangtools.version>
- <yang.maven.plugin.version>0.6.2-SNAPSHOT</yang.maven.plugin.version>
+ <yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
+ <yang.maven.plugin.version>0.7.0-SNAPSHOT</yang.maven.plugin.version>
<java.source.version>1.7</java.source.version>
<java.target.version>1.7</java.target.version>
<jmh.version>0.9.7</jmh.version>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
import org.opendaylight.yangtools.concepts.Codec;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
import org.opendaylight.yangtools.util.ClassLoaderUtils;
import org.opendaylight.yangtools.yang.binding.BaseIdentity;
import org.opendaylight.yangtools.yang.binding.BindingMapping;
import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
} catch (Exception e) {
throw new IllegalStateException("Unable to load codec for " + valueType, e);
}
+ } else if(rootType instanceof LeafrefTypeDefinition) {
+ Entry<GeneratedType, Object> typeWithSchema = context.getTypeWithSchema(valueType);
+ Object schema = typeWithSchema.getValue();
+ Preconditions.checkState(schema instanceof TypeDefinition<?>);
+ return getCodec(valueType, (TypeDefinition<?>) schema);
}
return ValueTypeCodec.getCodecFor(valueType, instantiatedType);
}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.binding.data.codec.test;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Map.Entry;
+import javassist.ClassPool;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.ThirdParty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexLeaves;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.augment.rev140709.TreeComplexLeavesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Int32StringUnion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.Top;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701.two.level.list.TopLevelListKey;
+import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
+import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+
+public class LeafReferenceTest extends AbstractBindingRuntimeTest {
+
+ private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
+ private static final InstanceIdentifier<TreeComplexLeaves> BA_TOP_LEVEL_LIST = InstanceIdentifier.builder(Top.class)
+ .child(TopLevelList.class, TOP_FOO_KEY).augmentation(TreeComplexLeaves.class).toInstance();
+
+ private BindingNormalizedNodeCodecRegistry registry;
+
+ @Override
+ public void setup() {
+ super.setup();
+ JavassistUtils utils = JavassistUtils.forClassPool(ClassPool.getDefault());
+ registry = new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(utils));
+ registry.onBindingRuntimeContextUpdated(getRuntimeContext());
+ }
+
+ @Test
+ public void testCaseWithLeafReferencesType() {
+ TreeComplexLeaves binding = new TreeComplexLeavesBuilder()
+ .setIdentity(ThirdParty.class)
+ .setIdentityRef(ThirdParty.class)
+ .setSimpleType(10)
+ .setSimpleTypeRef(10)
+ .setSchemaUnawareUnion(new Int32StringUnion("foo"))
+ .setSchemaUnawareUnionRef(new Int32StringUnion(10))
+ .build();
+ Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> dom = registry.toNormalizedNode(BA_TOP_LEVEL_LIST, binding);
+ Entry<InstanceIdentifier<?>, DataObject> readed = registry.fromNormalizedNode(dom.getKey(),dom.getValue());
+ TreeComplexLeaves readedAugment = ((TreeComplexLeaves) readed.getValue());
+
+ assertEquals(binding,readedAugment);
+
+ }
+
+
+
+}
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeInSchemaContext;
import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;
-
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
final Type type = ((TypeProviderImpl) typeProvider).generatedTypeForExtendedDefinitionType(typedef,
typedef);
if (type != null) {
- genCtx.get(module).addTypedefType(typedef.getPath(), type);
+ final ModuleContext ctx = genCtx.get(module);
+ ctx.addTypedefType(typedef.getPath(), type);
+ ctx.addTypeToSchema(type,typedef);
}
}
}
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
public final class ModuleContext {
private GeneratedTypeBuilder moduleNode;
return Collections.unmodifiableMap(typeToSchema);
}
+ protected void addTypeToSchema(Type type, TypeDefinition<?> typedef) {
+ typeToSchema.put(type, typedef);
+ }
+
}
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.yangtools.sal.binding.generator.util;
import com.google.common.base.Optional;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimap;
-
import java.util.AbstractMap;
import java.util.AbstractMap.SimpleEntry;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-
import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
for (ModuleContext ctx : modules.values()) {
augmentationToSchema.putAll(ctx.getTypeToAugmentation());
typeToDefiningSchema.putAll(ctx.getTypeToSchema());
+
+ ctx.getTypedefs();
augmentableToAugmentations.putAll(ctx.getAugmentableToAugmentations());
choiceToCases.putAll(ctx.getChoiceToCases());
identities.putAll(ctx.getIdentities());
return new ReferencedTypeImpl(type.getPackage().getName(), type.getSimpleName());
}
+ /**
+ * Returns schema ({@link DataSchemaNode}, {@link AugmentationSchema} or {@link TypeDefinition})
+ * from which supplied class was generated. Returned schema may be augmented with
+ * additional information, which was not available at compile type
+ * (e.g. third party augmentations).
+ *
+ * @param type Binding Class for which schema should be retrieved.
+ * @return Instance of generated type (definition of Java API), along with
+ * {@link DataSchemaNode}, {@link AugmentationSchema} or {@link TypeDefinition}
+ * which was used to generate supplied class.
+ */
public Entry<GeneratedType, Object> getTypeWithSchema(final Class<?> type) {
Object schema = typeToDefiningSchema.get(referencedType(type));
Type definedType = typeToDefiningSchema.inverse().get(schema);
Preconditions.checkNotNull(schema);
Preconditions.checkNotNull(definedType);
+ if(definedType instanceof GeneratedTypeBuilder) {
+ return new SimpleEntry<>(((GeneratedTypeBuilder) definedType).toInstance(), schema);
+ }
+ Preconditions.checkArgument(definedType instanceof GeneratedType,"Type {} is not GeneratedType",type);
+ return new SimpleEntry<>((GeneratedType) definedType,schema);
- return new SimpleEntry<>(((GeneratedTypeBuilder) definedType).toInstance(), schema);
}
public ImmutableMap<Type, Entry<Type, Type>> getChoiceCaseChildren(final DataNodeContainer schema) {
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangtools.test.binding.rev140701;
+
+
+/**
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
+ * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ * The reason behind putting it under src/main/java is:
+ * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
+ * loss of user code.
+ */
+public class Int32StringUnionBuilder {
+
+ public static Int32StringUnion getDefaultInstance(final String defaultValue) {
+ try {
+ return new Int32StringUnion(Integer.parseInt(defaultValue));
+ } catch (NumberFormatException e) {
+ return new Int32StringUnion(defaultValue);
+ }
+ }
+
+}
"Test model for testing data broker with nested lists.";
}
+ identity third-party {
+ base test:test-root;
+ }
+
grouping leaf-from-grouping {
leaf leaf-from-grouping {
type string;
type string;
}
}
-
}
augment "/test:top/test:top-level-list" {
uses leaf-from-grouping;
}
+ augment "/test:top/test:top-level-list" {
+ ext:augment-identifier tree-complex-leaves;
+ leaf simple-type {
+ type int32;
+ }
+ leaf identity {
+ type test:test-identityref;
+ }
+ leaf schema-unaware-union {
+ type test:int32-string-union;
+ }
+
+ leaf simple-type-ref {
+ type leafref {
+ path "../simple-type";
+ }
+ }
+ leaf identity-ref {
+ type leafref {
+ path "../identity";
+ }
+ }
+ leaf schema-unaware-union-ref {
+ type leafref {
+ path "../schema-unaware-union";
+ }
+ }
+ }
+
+
augment "/test:put-top/test:input/test:top-level-list" {
ext:augment-identifier rpc-leaf-only-uses-augment;
uses leaf-from-grouping;
"Test model for testing data broker with nested lists.";
}
+ typedef int32-string-union {
+ type union {
+ type int32;
+ type string;
+ }
+ }
+
+ identity test-root;
+
+ identity test-one {
+ base test-root;
+ }
+
+ identity test-two {
+ base test-root;
+ }
+
+ typedef test-identityref {
+ type identityref {
+ base test-root;
+ }
+ }
+
grouping two-level-list {
list top-level-list {
description
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-sal-api-gen-plugin</artifactId>
*/
package org.opendaylight.yangtools.yang.unified.doc.generator
+import com.google.common.collect.Iterables
import java.io.BufferedWriter
import java.io.File
import java.io.IOException
import java.util.Map
import java.util.Set
import org.opendaylight.yangtools.yang.common.QName
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates
import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
import org.opendaylight.yangtools.yang.model.api.AugmentationTarget
import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
import org.slf4j.LoggerFactory
import org.sonatype.plexus.build.incremental.BuildContext
import org.sonatype.plexus.build.incremental.DefaultBuildContext
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
-import com.google.common.collect.Iterables
class GeneratorImpl {
case reconnect-immediately-strategy-factory {
when "/config:modules/config:module/config:type = 'reconnect-immediately-strategy-factory'";
- leaf timeout {
+ leaf timeout2 {
mandatory true;
type int32;
}
- container executor {
+ container executor2 {
uses config:service-ref {
refine type {
mandatory true;
units "milliseconds";
}
- container executor {
+ container executor3 {
uses config:service-ref {
refine type {
mandatory true;
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../common/parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<artifactId>maven-code-gen-sample</artifactId>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<artifactId>modeling-sample</artifactId>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<artifactId>checkstyle-logging</artifactId>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>features-test</artifactId>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>features-yangtools</artifactId>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<packaging>bundle</packaging>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<packaging>bundle</packaging>
<modelVersion>4.0.0</modelVersion>
<artifactId>yangtools-parent</artifactId>
<groupId>org.opendaylight.yangtools</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<packaging>pom</packaging>
<prerequisites>
<maven>3.0.4</maven>
<ctrie.version>0.2.0</ctrie.version>
<exam.version>3.0.0</exam.version>
<groovy.version>2.1.6</groovy.version>
- <yangtools.version>0.6.2-SNAPSHOT</yangtools.version>
- <ietf.topology.version>2013.10.21.2-SNAPSHOT</ietf.topology.version>
- <ietf.inet.types.version>2010.09.24.4-SNAPSHOT</ietf.inet.types.version>
- <ietf.yang.types.version>2010.09.24.4-SNAPSHOT</ietf.yang.types.version>
- <ietf.yang.types.20130715.version>2013.07.15.1-SNAPSHOT</ietf.yang.types.20130715.version>
- <ietf.restconf.version>2013.10.19.1-SNAPSHOT</ietf.restconf.version>
+ <yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
<karaf.version>3.0.1</karaf.version>
<nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
- <opendaylight.l2.types.version>2013.08.27.4-SNAPSHOT</opendaylight.l2.types.version>
- <yang.ext.version>2013.09.07.4-SNAPSHOT</yang.ext.version>
<maven.javadoc.version>2.9.1</maven.javadoc.version>
<jsr305.version>2.0.1</jsr305.version>
+ <!-- Model versions -->
+ <ietf.topology.version>2013.10.21.7-SNAPSHOT</ietf.topology.version>
+ <ietf.inet.types.version>2010.09.24.7-SNAPSHOT</ietf.inet.types.version>
+ <ietf.yang.types.version>2010.09.24.7-SNAPSHOT</ietf.yang.types.version>
+ <ietf.yang.types.20130715.version>2013.07.15.7-SNAPSHOT</ietf.yang.types.20130715.version>
+ <ietf.restconf.version>2013.10.19.7-SNAPSHOT</ietf.restconf.version>
+ <opendaylight.l2.types.version>2013.08.27.7-SNAPSHOT</opendaylight.l2.types.version>
+ <yang.ext.version>2013.09.07.7-SNAPSHOT</yang.ext.version>
+
<!-- Sonar config -->
<sonar-jacoco-listeners.version>2.4</sonar-jacoco-listeners.version>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>parent</relativePath>
</parent>
<groupId>org.opendaylight.yangtools</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<artifactId>common-aggregator</artifactId>
<packaging>pom</packaging>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<packaging>bundle</packaging>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>mockito-configuration</artifactId>
<scope>test</scope>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-binding</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools.model</groupId>
<artifactId>yang-ext</artifactId>
- <version>2013.09.07.4-SNAPSHOT</version>
+ <version>${yang.ext.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools.model</groupId>
<artifactId>ietf-inet-types</artifactId>
- <version>2010.09.24.4-SNAPSHOT</version>
+ <version>${ietf.inet.types.version}</version>
</dependency>
</dependencies>
</plugin>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<artifactId>yangtools-parent</artifactId>
<groupId>org.opendaylight.yangtools</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../common/parent</relativePath>
</parent>
<groupId>org.opendaylight.yangtools</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<artifactId>integration-tests-aggregator</artifactId>
<packaging>pom</packaging>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<artifactId>yangtools-parent</artifactId>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<artifactId>model-iana</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iana-afn-safi</artifactId>
- <version>2013.07.04.4-SNAPSHOT</version>
+ <version>2013.07.04.7-SNAPSHOT</version>
<build>
<plugins>
<parent>
<artifactId>model-iana</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>iana-if-type</artifactId>
- <version>2013.07.04.4-SNAPSHOT</version>
+ <version>2013.07.04.7-SNAPSHOT</version>
<build>
<plugins>
<parent>
<artifactId>model-parent</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<parent>
<artifactId>model-ietf</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ietf-inet-types</artifactId>
- <version>2010.09.24.4-SNAPSHOT</version>
+ <version>2010.09.24.7-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<parent>
<artifactId>model-ietf</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>model-ietf</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ietf-restconf</artifactId>
- <version>2013.10.19.1-SNAPSHOT</version>
+ <version>2013.10.19.7-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<dependency>
<groupId>org.opendaylight.yangtools.model</groupId>
<artifactId>ietf-yang-types-20130715</artifactId>
- <version>2013.07.15.1-SNAPSHOT</version>
</dependency>
<dependency>
<parent>
<artifactId>model-ietf</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ietf-ted</artifactId>
- <version>2013.10.21.2-SNAPSHOT</version>
+ <version>2013.10.21.7-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<parent>
<artifactId>model-ietf</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ietf-topology-isis</artifactId>
- <version>2013.10.21.2-SNAPSHOT</version>
+ <version>2013.10.21.7-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<parent>
<artifactId>model-ietf</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ietf-topology-l3-unicast-igp</artifactId>
- <version>2013.10.21.2-SNAPSHOT</version>
+ <version>2013.10.21.7-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<parent>
<artifactId>model-ietf</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ietf-topology-ospf</artifactId>
- <version>2013.10.21.2-SNAPSHOT</version>
+ <version>2013.10.21.7-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<parent>
<artifactId>model-ietf</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ietf-topology</artifactId>
- <version>2013.10.21.2-SNAPSHOT</version>
+ <version>2013.10.21.7-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<parent>
<artifactId>model-ietf</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ietf-yang-types-20130715</artifactId>
- <version>2013.07.15.1-SNAPSHOT</version>
+ <version>2013.07.15.7-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<parent>
<artifactId>model-ietf</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ietf-yang-types</artifactId>
- <version>2010.09.24.4-SNAPSHOT</version>
+ <version>2010.09.24.7-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<parent>
<artifactId>model-parent</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>model-parent</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>opendaylight-l2-types</artifactId>
- <version>2013.08.27.4-SNAPSHOT</version>
+ <version>2013.08.27.7-SNAPSHOT</version>
<build>
<plugins>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../common/parent</relativePath>
</parent>
<groupId>org.opendaylight.yangtools.model</groupId>
- <!--<version>0.6.2-SNAPSHOT</version>-->
+ <!--<version>0.7.0-SNAPSHOT</version>-->
<modelVersion>4.0.0</modelVersion>
<artifactId>model-parent</artifactId>
<packaging>pom</packaging>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>maven-sal-api-gen-plugin</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
<parent>
<artifactId>model-parent</artifactId>
<groupId>org.opendaylight.yangtools.model</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yang-ext</artifactId>
- <version>2013.09.07.4-SNAPSHOT</version>
+ <version>2013.09.07.7-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>common/parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yangtools-aggregator</artifactId>
<groupId>org.opendaylight.yangtools</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<packaging>pom</packaging>
<scm>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../common/parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>restconf-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>restconf-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<artifactId>restconf-client-impl</artifactId>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>restconf-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<artifactId>restconf-common</artifactId>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>restconf-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<artifactId>restconf-jaxrs-api</artifactId>
<name>restconf-jaxrs-api</name>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>restconf-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<artifactId>restconf-test-service</artifactId>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>restconf-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
</parent>
<artifactId>restconf-util</artifactId>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-data-codec</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>third-party-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>third-party-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../common/parent</relativePath>
</parent>
<groupId>org.opendaylight.yangtools</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<artifactId>websocket-aggregator</artifactId>
<packaging>pom</packaging>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>../common/parent</relativePath>
</parent>
<groupId>org.opendaylight.yangtools</groupId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<artifactId>yang-aggregator</artifactId>
<packaging>pom</packaging>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
<parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-parent</artifactId>
- <version>0.6.2-SNAPSHOT</version>
+ <version>0.7.0-SNAPSHOT</version>
<relativePath>/../../common/parent/pom.xml</relativePath>
</parent>
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import com.google.common.base.Splitter;
import com.google.common.collect.HashBiMap;
import com.google.common.io.ByteSource;
import java.io.File;
import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.YangContext;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
@Immutable
public final class YangParserImpl implements YangContextParser {
private static final Logger LOG = LoggerFactory.getLogger(YangParserImpl.class);
- private static final Splitter COLON_SPLITTER = Splitter.on(':');
private static final YangParserImpl INSTANCE = new YangParserImpl();
public static YangParserImpl getInstance() {
resolveUsesForNodes(modules);
resolveAugments(modules);
resolveIdentities(modules);
+ checkChoiceCasesForDuplicityQNames(modules);
// build
final Map<ModuleBuilder, Module> result = new LinkedHashMap<>();
return null;
}
+
+ /**
+ * Traverse through modules and check if choice has choice cases with the
+ * same qname.
+ *
+ * @param modules
+ * all loaded modules
+ */
+ private void checkChoiceCasesForDuplicityQNames(final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
+ for (Map.Entry<URI, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+ for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue().entrySet()) {
+ final ModuleBuilder moduleBuilder = childEntry.getValue();
+ final Module module = moduleBuilder.build();
+ final List<ChoiceNode> allChoicesFromModule = getChoicesFrom(module);
+
+ for (ChoiceNode choiceNode : allChoicesFromModule) {
+ findDuplicityNodesIn(choiceNode, module, moduleBuilder, modules);
+ }
+ }
+ }
+ }
+
+ private void findDuplicityNodesIn(final ChoiceNode choiceNode, final Module module, final ModuleBuilder moduleBuilder,
+ final Map<URI, TreeMap<Date, ModuleBuilder>> modules) {
+ final Set<QName> duplicityTestSet = new HashSet<QName>();
+
+ for (ChoiceCaseNode choiceCaseNode : choiceNode.getCases()) {
+
+ for (DataSchemaNode childSchemaNode : choiceCaseNode.getChildNodes()) {
+ if (!duplicityTestSet.add(childSchemaNode.getQName())) {
+ final Optional<SchemaNodeBuilder> schemaNodeBuilder = BuilderUtils.findSchemaNodeInModule(childSchemaNode.getPath(), moduleBuilder);
+ final String nameOfSchemaNode = childSchemaNode.getQName().getLocalName();
+ int lineOfSchemaNode = 0;
+
+ if (schemaNodeBuilder.isPresent()) {
+ lineOfSchemaNode = schemaNodeBuilder.get().getLine();
+ }
+ throw new YangParseException(module.getName(), lineOfSchemaNode,
+ String.format("Choice has two nodes case with same qnames - %s", nameOfSchemaNode));
+ }
+ }
+
+ for (UnknownSchemaNode unknownNode : choiceCaseNode.getUnknownSchemaNodes()) {
+ if (!duplicityTestSet.add(unknownNode.getQName())) {
+ final Optional<SchemaNodeBuilder> schemaNodeBuilder = BuilderUtils.findSchemaNodeInModule(unknownNode.getPath(), moduleBuilder);
+ final String nameOfUnknownNode = unknownNode.getQName().getLocalName();
+ int lineOfUnknownNode = 0;
+
+ if (schemaNodeBuilder.isPresent()) {
+ lineOfUnknownNode = schemaNodeBuilder.get().getLine();
+ }
+ throw new YangParseException(module.getName(), lineOfUnknownNode,
+ String.format("Choice has two nodes case with same qnames - %s", nameOfUnknownNode));
+ }
+ }
+ }
+ }
+
+ private List<ChoiceNode> getChoicesFrom(final Module module) {
+ final List<ChoiceNode> allChoices = new ArrayList<ChoiceNode>();
+
+ for (DataSchemaNode dataSchemaNode : module.getChildNodes()) {
+ findChoicesIn(dataSchemaNode, allChoices);
+ }
+ return allChoices;
+ }
+
+ private void findChoicesIn(final SchemaNode schemaNode, final Collection<ChoiceNode> choiceNodes) {
+ if (schemaNode instanceof ContainerSchemaNode) {
+ final ContainerSchemaNode contSchemaNode = (ContainerSchemaNode) schemaNode;
+ for (DataSchemaNode dataSchemaNode : contSchemaNode.getChildNodes()) {
+ findChoicesIn(dataSchemaNode, choiceNodes);
+ }
+ } else if (schemaNode instanceof ListSchemaNode) {
+ final ListSchemaNode listSchemaNode = (ListSchemaNode) schemaNode;
+ for (DataSchemaNode dataSchemaNode : listSchemaNode.getChildNodes()) {
+ findChoicesIn(dataSchemaNode, choiceNodes);
+ }
+ } else if (schemaNode instanceof ChoiceNode) {
+ choiceNodes.add((ChoiceNode) schemaNode);
+ }
+ }
+
}
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.Collections2;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import com.google.common.util.concurrent.AsyncFunction;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.ListenableFuture;
import java.net.URI;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.TreeMap;
+import javax.annotation.Nullable;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
final Map<SourceIdentifier, ParserRuleContext> asts =
Maps.transformValues(srcs, ASTSchemaSource.GET_AST);
final Map<String, TreeMap<Date, URI>> namespaceContext = BuilderUtils.createYangNamespaceContext(
- asts.values(), Optional.<SchemaContext> absent());
+ asts.values(), Optional.<SchemaContext>absent());
final ParseTreeWalker walker = new ParseTreeWalker();
final Map<SourceIdentifier, ModuleBuilder> sourceToBuilder = new LinkedHashMap<>();
- for (Entry<SourceIdentifier, ParserRuleContext> entry : asts.entrySet()) {
- ModuleBuilder moduleBuilder = YangParserListenerImpl.create(namespaceContext, entry.getKey().getName(),
+ for (final Entry<SourceIdentifier, ParserRuleContext> entry : asts.entrySet()) {
+ final ModuleBuilder moduleBuilder = YangParserListenerImpl.create(namespaceContext, entry.getKey().getName(),
walker, entry.getValue()).getModuleBuilder();
moduleBuilder.setSource(srcs.get(entry.getKey()).getYangText());
// FIXME: ignored right now
private final SchemaSourceFilter filter;
+ // FIXME SchemaRepository should be the type for repository parameter instead of SharedSchemaRepository (final implementation)
public SharedSchemaContextFactory(final SharedSchemaRepository repository, final SchemaSourceFilter filter) {
this.repository = Preconditions.checkNotNull(repository);
this.filter = Preconditions.checkNotNull(filter);
@Override
public CheckedFuture<SchemaContext, SchemaResolutionException> createSchemaContext(final Collection<SourceIdentifier> requiredSources) {
- final SchemaContext existing = cache.getIfPresent(requiredSources);
+ // Make sources unique
+ final List<SourceIdentifier> uniqueSourceIdentifiers = deDuplicateSources(requiredSources);
+
+ final SchemaContext existing = cache.getIfPresent(uniqueSourceIdentifiers);
if (existing != null) {
LOG.debug("Returning cached context {}", existing);
return Futures.immediateCheckedFuture(existing);
}
// Request all sources be loaded
- final ListenableFuture<List<ASTSchemaSource>> sf = Futures.allAsList(Collections2.transform(requiredSources, requestSources));
+ ListenableFuture<List<ASTSchemaSource>> sf = Futures.allAsList(Collections2.transform(uniqueSourceIdentifiers, requestSources));
+
+ // Detect mismatch between requested Source IDs and IDs that are extracted from parsed source
+ // Also remove duplicates if present
+ // We are relying on preserved order of uniqueSourceIdentifiers as well as sf
+ sf = Futures.transform(sf, new SourceIdMismatchDetector(uniqueSourceIdentifiers));
// Assemble sources into a schema context
final ListenableFuture<SchemaContext> cf = Futures.transform(sf, assembleSources);
Futures.addCallback(cf, new FutureCallback<SchemaContext>() {
@Override
public void onSuccess(final SchemaContext result) {
- cache.put(requiredSources, result);
+ cache.put(uniqueSourceIdentifiers, result);
}
@Override
return Futures.makeChecked(cf, MAPPER);
}
+
+ /**
+ * @return set (preserving ordering) from the input collection
+ */
+ private List<SourceIdentifier> deDuplicateSources(final Collection<SourceIdentifier> requiredSources) {
+ final Set<SourceIdentifier> uniqueSourceIdentifiers = Collections.unmodifiableSet(Sets.newLinkedHashSet(requiredSources));
+ if(uniqueSourceIdentifiers.size() != requiredSources.size()) {
+ LOG.warn("Duplicate sources requested for schema context, removed duplicate sources: {}", Collections2.filter(uniqueSourceIdentifiers, new Predicate<SourceIdentifier>() {
+ @Override
+ public boolean apply(@Nullable final SourceIdentifier input) {
+ return Iterables.frequency(requiredSources, input) > 1;
+ }
+ }));
+ }
+ return Lists.newArrayList(uniqueSourceIdentifiers);
+ }
+
+ private static final class SourceIdMismatchDetector implements Function<List<ASTSchemaSource>, List<ASTSchemaSource>> {
+ private final List<SourceIdentifier> sourceIdentifiers;
+
+ public SourceIdMismatchDetector(final List<SourceIdentifier> sourceIdentifiers) {
+ this.sourceIdentifiers = sourceIdentifiers;
+ }
+
+ @Override
+ public List<ASTSchemaSource> apply(final List<ASTSchemaSource> input) {
+ final Map<SourceIdentifier, ASTSchemaSource> filtered = Maps.newLinkedHashMap();
+
+ for (int i = 0; i < input.size(); i++) {
+
+ final SourceIdentifier expectedSId = sourceIdentifiers.get(i);
+ final ASTSchemaSource astSchemaSource = input.get(i);
+ final SourceIdentifier realSId = astSchemaSource.getIdentifier();
+
+ if (expectedSId.equals(realSId) == false) {
+ LOG.warn("Source identifier mismatch for module \"{}\", requested as {} but actually is {}. Using actual id", expectedSId.getName(), expectedSId, realSId);
+ }
+
+ if (filtered.containsKey(realSId)) {
+ LOG.warn("Duplicate source for module {} detected in reactor", realSId);
+ }
+
+ filtered.put(realSId, astSchemaSource);
+
+ }
+ return Lists.newArrayList(filtered.values());
+ }
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.impl;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+import java.net.URI;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
+import org.opendaylight.yangtools.yang.parser.util.YangParseException;
+
+public class SameQNamesInChoiceTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void testSameQNameInChoice() throws Exception {
+ thrown.expect(YangParseException.class);
+ thrown.expectMessage("Choice has two nodes case with same qnames");
+
+ SchemaContext context;
+ File yangFile = new File(getClass().getResource("/bugs/qnameDuplicity/two-same-node-in-choice/two-same-nodes-in-choice-case.yang").toURI());
+ File dependenciesDir = new File(getClass().getResource("/bugs/qnameDuplicity/two-same-node-in-choice").toURI());
+ YangContextParser parser = new YangParserImpl();
+ context = parser.parseFile(yangFile, dependenciesDir);
+
+ Module testModule = context.findModuleByNamespace(URI.create("urn:test:two:same-nodes-in-choice-case")).iterator().next();
+ assertNotNull(testModule);
+ }
+
+
+ @Test
+ public void testAugmentedNodeIntoChoiceCase() throws Exception {
+ thrown.expect(YangParseException.class);
+ thrown.expectMessage("Choice has two nodes case with same qnames");
+
+ SchemaContext context;
+ File yangFile = new File(getClass().getResource("/bugs/qnameDuplicity/augment/two-cases.yang").toURI());
+ File dependenciesDir = new File(getClass().getResource("/bugs/qnameDuplicity/augment").toURI());
+ YangContextParser parser = new YangParserImpl();
+ context = parser.parseFile(yangFile, dependenciesDir);
+
+ Module testModule = context.findModuleByNamespace(URI.create("urn:test:two:cases")).iterator().next();
+ assertNotNull(testModule);
+ }
+}
--- /dev/null
+package org.opendaylight.yangtools.yang.parser.repo;
+
+import static org.junit.Assert.assertNotNull;
+
+import com.google.common.collect.Lists;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceFilter;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
+import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
+import org.opendaylight.yangtools.yang.parser.util.ASTSchemaSource;
+import org.opendaylight.yangtools.yang.parser.util.TextToASTTransformer;
+
+public class SharedSchemaContextFactoryTest {
+
+ private final SharedSchemaRepository repository = new SharedSchemaRepository("test");
+
+ @Mock
+ private SchemaSourceFilter filter;
+ private SourceIdentifier s1;
+ private SourceIdentifier s2;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ final ResourceYangSource source1 = new ResourceYangSource("/ietf/ietf-inet-types@2010-09-24.yang");
+ final ResourceYangSource source2 = new ResourceYangSource("/ietf/iana-timezones@2012-07-09.yang");
+ s1 = new SourceIdentifier("ietf-inet-types", "2010-09-24");
+ s2 = new SourceIdentifier("iana-timezones", "2012-07-09");
+
+ final TextToASTTransformer transformer = TextToASTTransformer.create(repository, repository);
+ repository.registerSchemaSourceListener(transformer);
+
+ repository.registerSchemaSource(new SchemaSourceProvider<YangTextSchemaSource>() {
+ @Override
+ public CheckedFuture<YangTextSchemaSource, SchemaSourceException> getSource(final SourceIdentifier sourceIdentifier) {
+ return Futures.<YangTextSchemaSource, SchemaSourceException>immediateCheckedFuture(source1);
+ }
+ }, PotentialSchemaSource.create(s1, YangTextSchemaSource.class, 1));
+
+ repository.registerSchemaSource(new SchemaSourceProvider<YangTextSchemaSource>() {
+ @Override
+ public CheckedFuture<YangTextSchemaSource, SchemaSourceException> getSource(final SourceIdentifier sourceIdentifier) {
+ return Futures.<YangTextSchemaSource, SchemaSourceException>immediateCheckedFuture(source2);
+ }
+ }, PotentialSchemaSource.create(s2, YangTextSchemaSource.class, 1));
+ }
+
+ @Test
+ public void testCreateSchemaContextWithDuplicateRequiredSources() throws Exception {
+ final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository, filter);
+ final CheckedFuture<SchemaContext, SchemaResolutionException> schemaContext = sharedSchemaContextFactory.createSchemaContext(Lists.newArrayList(s1, s1, s2));
+ assertNotNull(schemaContext.checkedGet());
+ }
+
+ @Test
+ public void testSourceRegisteredWithDifferentSI() throws Exception {
+ final ResourceYangSource source1 = new ResourceYangSource("/ietf/ietf-inet-types@2010-09-24.yang");
+ final ResourceYangSource source2 = new ResourceYangSource("/ietf/iana-timezones@2012-07-09.yang");
+ s1 = source1.getIdentifier();
+ s2 = source2.getIdentifier();
+
+ final SettableSchemaProvider<ASTSchemaSource> provider = SharedSchemaRepositoryTest.getImmediateYangSourceProviderFromResource("/no-revision/imported@2012-12-12.yang");
+ provider.setResult();
+ provider.register(repository);
+
+ // Register the same provider under source id without revision
+ final SourceIdentifier sIdWithoutRevision = new SourceIdentifier(provider.getId().getName());
+ repository.registerSchemaSource(provider, PotentialSchemaSource.create(
+ sIdWithoutRevision, ASTSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
+
+ final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository, filter);
+ final CheckedFuture<SchemaContext, SchemaResolutionException> schemaContext = sharedSchemaContextFactory.createSchemaContext(Lists.newArrayList(sIdWithoutRevision, provider.getId()));
+ assertNotNull(schemaContext.checkedGet());
+ }
+}
public class SharedSchemaRepositoryTest {
+ @Test
+ public void testSourceWithAndWithoutRevision() throws Exception {
+ final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("netconf-mounts");
+
+ final SourceIdentifier idNoRevision = loadAndRegisterSource(sharedSchemaRepository, "/no-revision/imported.yang");
+ final SourceIdentifier id2 = loadAndRegisterSource(sharedSchemaRepository, "/no-revision/imported@2012-12-12.yang");
+
+ CheckedFuture<ASTSchemaSource, SchemaSourceException> source = sharedSchemaRepository.getSchemaSource(idNoRevision, ASTSchemaSource.class);
+ assertEquals(idNoRevision, source.checkedGet().getIdentifier());
+ source = sharedSchemaRepository.getSchemaSource(id2, ASTSchemaSource.class);
+ assertEquals(id2, source.checkedGet().getIdentifier());
+ }
+
+ private SourceIdentifier loadAndRegisterSource(final SharedSchemaRepository sharedSchemaRepository, final String resourceName) throws Exception {
+ final SettableSchemaProvider<ASTSchemaSource> sourceProvider = getImmediateYangSourceProviderFromResource(resourceName);
+ sourceProvider.setResult();
+ final SourceIdentifier idNoRevision = sourceProvider.getId();
+ sourceProvider.register(sharedSchemaRepository);
+ return idNoRevision;
+ }
+
@Test
public void testSimpleSchemaContext() throws Exception {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("netconf-mounts");
assertEquals(moduleSize, schemaContext.getModules().size());
}
- private SettableSchemaProvider<ASTSchemaSource> getRemoteYangSourceProviderFromResource(final String resourceName) throws Exception {
+ static SettableSchemaProvider<ASTSchemaSource> getRemoteYangSourceProviderFromResource(final String resourceName) throws Exception {
final ResourceYangSource yangSource = new ResourceYangSource(resourceName);
final CheckedFuture<ASTSchemaSource, SchemaSourceException> aSTSchemaSource = TextToASTTransformer.TRANSFORMATION.apply(yangSource);
return SettableSchemaProvider.createRemote(aSTSchemaSource.get(), ASTSchemaSource.class);
}
- private SettableSchemaProvider<ASTSchemaSource> getImmediateYangSourceProviderFromResource(final String resourceName) throws Exception {
+ static SettableSchemaProvider<ASTSchemaSource> getImmediateYangSourceProviderFromResource(final String resourceName) throws Exception {
final ResourceYangSource yangSource = new ResourceYangSource(resourceName);
final CheckedFuture<ASTSchemaSource, SchemaSourceException> aSTSchemaSource = TextToASTTransformer.TRANSFORMATION.apply(yangSource);
return SettableSchemaProvider.createImmediate(aSTSchemaSource.get(), ASTSchemaSource.class);
--- /dev/null
+module two-cases {
+
+ namespace "urn:test:two:cases";
+ prefix "two";
+
+ organization "OPEN DAYLIGHT";
+ contact "http://www.opendaylight.org/";
+
+ revision 2013-07-09 {
+
+ }
+
+ container cont {
+ choice choice {
+ default second;
+ case first {
+ leaf leaf-case1 {
+ type int32;
+ }
+ }
+ }
+ }
+
+ augment "/cont/choice/" {
+ case forth {
+ leaf leaf-case1 {
+ type string;
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+module two-same-nodes-in-choice-case {
+
+ namespace "urn:test:two:same-nodes-in-choice-case";
+ prefix "two";
+
+ organization "OPEN DAYLIGHT";
+ contact "http://www.opendaylight.org/";
+
+ revision 2013-07-09 {
+
+ }
+
+ container cont3 {
+ choice choice3 {
+ default second;
+ case first {
+ leaf leaf-case1 {
+ type int32;
+ }
+ }
+ case second {
+ leaf leaf-case1 {
+ type int32;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
namespace "urn:simple.demo.test1";
prefix "imp";
- organization "opendaylight";
- contact "WILL-BE-DEFINED-LATER";
+ //organization "opendaylight";
+ //contact "WILL-BE-DEFINED-LATER";
}
revision 2012-12-12 {}
- organization "opendaylight";
- contact "WILL-BE-DEFINED-LATER";
+ //organization "opendaylight";
+ //contact "WILL-BE-DEFINED-LATER";
}