X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FSchemaAwareApplyOperation.java;h=7ea4d4e09fc1590557b339b65ce78a8fb54f25c6;hb=728e98d3af4276f45c848c54ae02974f2cb04b2e;hp=a5c9b7983a92f93a9a2e2049688e0d33eaed1c8b;hpb=35563cb3c795ab92d0e85c34e3b3bab5da0c73bc;p=controller.git diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java index a5c9b7983a..7ea4d4e09f 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaAwareApplyOperation.java @@ -2,6 +2,7 @@ package org.opendaylight.controller.md.sal.dom.store.impl; import static com.google.common.base.Preconditions.checkArgument; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -36,8 +37,10 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableCo import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedLeafSetNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListEntryNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.AugmentationSchemaProxy; import org.opendaylight.yangtools.yang.model.api.AugmentationSchema; import org.opendaylight.yangtools.yang.model.api.AugmentationTarget; import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; @@ -70,7 +73,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } else if (schemaNode instanceof ChoiceNode) { return new ChoiceModificationStrategy((ChoiceNode) schemaNode); } else if (schemaNode instanceof LeafListSchemaNode) { - return new LeafSetEntryModificationStrategy((LeafListSchemaNode) schemaNode); + return fromLeafListSchemaNode((LeafListSchemaNode) schemaNode); } else if (schemaNode instanceof LeafSchemaNode) { return new LeafModificationStrategy((LeafSchemaNode) schemaNode); } @@ -89,6 +92,15 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper return new UnorderedMapModificationStrategy(schemaNode); } + private static SchemaAwareApplyOperation fromLeafListSchemaNode(final LeafListSchemaNode schemaNode) { + if(schemaNode.isUserOrdered()) { + return new OrderedLeafSetModificationStrategy(schemaNode); + } else { + return new UnorderedLeafSetModificationStrategy(schemaNode); + } + } + + public static SchemaAwareApplyOperation from(final DataNodeContainer resolvedTree, final AugmentationTarget augSchemas, final AugmentationIdentifier identifier) { AugmentationSchema augSchema = null; @@ -504,7 +516,7 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper DataNodeContainerModificationStrategy { protected AugmentationModificationStrategy(final AugmentationSchema schema, final DataNodeContainer resolved) { - super(schema, AugmentationNode.class); + super(createAugmentProxy(schema,resolved), AugmentationNode.class); // FIXME: Use resolved children instead of unresolved. } @@ -563,12 +575,12 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } - public static class LeafSetModificationStrategy extends NormalizedNodeContainerModificationStrategy { + public static class UnorderedLeafSetModificationStrategy extends NormalizedNodeContainerModificationStrategy { private final Optional entryStrategy; @SuppressWarnings({ "unchecked", "rawtypes" }) - protected LeafSetModificationStrategy(final LeafListSchemaNode schema) { + protected UnorderedLeafSetModificationStrategy(final LeafListSchemaNode schema) { super((Class) LeafSetNode.class); entryStrategy = Optional. of(new LeafSetEntryModificationStrategy(schema)); } @@ -589,6 +601,32 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } + public static class OrderedLeafSetModificationStrategy extends NormalizedNodeContainerModificationStrategy { + + private final Optional entryStrategy; + + @SuppressWarnings({ "unchecked", "rawtypes" }) + protected OrderedLeafSetModificationStrategy(final LeafListSchemaNode schema) { + super((Class) LeafSetNode.class); + entryStrategy = Optional. of(new LeafSetEntryModificationStrategy(schema)); + } + + @SuppressWarnings("rawtypes") + @Override + protected NormalizedNodeContainerBuilder createBuilder(final PathArgument identifier) { + return ImmutableOrderedLeafSetNodeBuilder.create().withNodeIdentifier((NodeIdentifier) identifier); + } + + @Override + public Optional getChild(final PathArgument identifier) { + if (identifier instanceof NodeWithValue) { + return entryStrategy; + } + return Optional.absent(); + } + + } + public static class UnkeyedListModificationStrategy extends SchemaAwareApplyOperation { private final Optional entryStrategy; @@ -698,4 +736,12 @@ public abstract class SchemaAwareApplyOperation implements ModificationApplyOper } + public static AugmentationSchema createAugmentProxy(final AugmentationSchema schema, final DataNodeContainer resolved) { + Set realChildSchemas = new HashSet<>(); + for(DataSchemaNode augChild : schema.getChildNodes()) { + realChildSchemas.add(resolved.getDataChildByName(augChild.getQName())); + } + return new AugmentationSchemaProxy(schema, realChildSchemas); + } + }