X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fdom%2Fserializer%2Fimpl%2FInstanceIdentifierCodecImpl.xtend;h=150d0f199f83f5615a9a5a8b7bda07347e6be309;hb=cf339c57da794c0a3f6f6010736c169b81c792f5;hp=270660980643cfa6e58a1bcc5fc7aeff856fc584;hpb=24feaa3333de6eadfc99a63cce0f95479e3b5f96;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/InstanceIdentifierCodecImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/InstanceIdentifierCodecImpl.xtend index 2706609806..150d0f199f 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/InstanceIdentifierCodecImpl.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/InstanceIdentifierCodecImpl.xtend @@ -22,6 +22,10 @@ import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl import org.opendaylight.yangtools.yang.data.api.Node import org.opendaylight.yangtools.yang.data.impl.SimpleNodeTOImpl import org.opendaylight.yangtools.yang.data.api.CompositeNode +import org.opendaylight.yangtools.yang.binding.Augmentable +import com.google.common.collect.ImmutableList +import org.opendaylight.yangtools.yang.binding.Augmentation +import java.util.concurrent.ConcurrentHashMap class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec { @@ -29,7 +33,7 @@ class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec { val CodecRegistry codecRegistry; val Map,QName> classToQName = new WeakHashMap; - + val Map, Map, Class>> classToPreviousAugment = new WeakHashMap; public new(CodecRegistry registry) { codecRegistry = registry; @@ -44,8 +48,15 @@ class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec { for(biArg : biArgs) { scannedPath.add(biArg.nodeType); val baArg = deserializePathArgument(biArg,scannedPath) - baArgs.add(baArg) baType = baArg?.type + val injectAugment = classToPreviousAugment.get(baType); + if(injectAugment != null) { + val augment = injectAugment.get(scannedPath) as Class; + if(augment != null) { + baArgs.add(new Item(augment)); + } + } + baArgs.add(baArg) } val ret = new InstanceIdentifier(baArgs,baType as Class); return ret; @@ -74,18 +85,41 @@ class InstanceIdentifierCodecImpl implements InstanceIdentifierCodec { } override serialize(InstanceIdentifier input) { + var Class previousAugmentation = null val pathArgs = input.path as List var QName previousQName = null; val components = new ArrayList(pathArgs.size); + val qnamePath = new ArrayList(pathArgs.size); for(baArg : pathArgs) { - codecRegistry.bindingClassEncountered(baArg.type); - val biArg = serializePathArgument(baArg,previousQName); - previousQName = biArg.nodeType; - components.add(biArg); + + if(!Augmentation.isAssignableFrom(baArg.type)) { + + val biArg = serializePathArgument(baArg,previousQName); + previousQName = biArg.nodeType; + components.add(biArg); + qnamePath.add(biArg.nodeType); + val immutableList = ImmutableList.copyOf(qnamePath); + codecRegistry.putPathToClass(immutableList,baArg.type); + if(previousAugmentation !== null) { + updateAugmentationInjection(baArg.type,immutableList,previousAugmentation) + } + + previousAugmentation = null; + } else { + previousQName = resolveQname(baArg.type); + previousAugmentation = baArg.type; + } } return new org.opendaylight.yangtools.yang.data.api.InstanceIdentifier(components); } + def updateAugmentationInjection(Class class1, ImmutableList list, Class augmentation) { + if(classToPreviousAugment.get(class1) == null) { + classToPreviousAugment.put(class1,new ConcurrentHashMap()); + } + classToPreviousAugment.get(class1).put(list,augmentation); + } + private def dispatch PathArgument serializePathArgument(Item argument, QName previousQname) { val type = argument.type; val qname = resolveQname(type);