X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fentityownership%2FEntityOwnersModel.java;h=1b5e512c593eda9aad664ee7a71be4618eb2a583;hb=a3cecfd01d0ef8922530924e3ee9684eb03ee5d6;hp=0be765000f9c295951efb03da1078b0cd87797b7;hpb=4b2622df4d579e9b1be0b25603e002ce58db4463;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnersModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnersModel.java index 0be765000f..1b5e512c59 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnersModel.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnersModel.java @@ -8,9 +8,10 @@ package org.opendaylight.controller.cluster.datastore.entityownership; import java.util.Map.Entry; -import org.opendaylight.controller.md.sal.common.api.clustering.Entity; +import org.opendaylight.mdsal.eos.dom.api.DOMEntity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.EntityOwners; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.EntityType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.entity.type.Entity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.clustering.entity.owners.rev150804.entity.owners.entity.type.entity.Candidate; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; @@ -30,9 +31,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOr * * @author Thomas Pantelis */ -final class EntityOwnersModel { - static final QName ENTITY_QNAME = org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller. - md.sal.clustering.entity.owners.rev150804.entity.owners.entity.type.Entity.QNAME; +public final class EntityOwnersModel { + static final QName ENTITY_QNAME = Entity.QNAME; static final QName CANDIDATE_NAME_QNAME = QName.create(Candidate.QNAME, "name"); static final QName ENTITY_ID_QNAME = QName.create(ENTITY_QNAME, "id"); static final QName ENTITY_OWNER_QNAME = QName.create(ENTITY_QNAME, "owner"); @@ -50,18 +50,18 @@ final class EntityOwnersModel { YangInstanceIdentifier.of(EntityOwners.QNAME).node(EntityType.QNAME); static YangInstanceIdentifier entityPath(String entityType, YangInstanceIdentifier entityId) { - return YangInstanceIdentifier.builder(ENTITY_OWNERS_PATH).node(EntityType.QNAME). - nodeWithKey(EntityType.QNAME, ENTITY_TYPE_QNAME, entityType).node(ENTITY_QNAME). - nodeWithKey(ENTITY_QNAME, ENTITY_ID_QNAME, entityId).build(); + return YangInstanceIdentifier.builder(ENTITY_OWNERS_PATH).node(EntityType.QNAME) + .nodeWithKey(EntityType.QNAME, ENTITY_TYPE_QNAME, entityType).node(ENTITY_QNAME) + .nodeWithKey(ENTITY_QNAME, ENTITY_ID_QNAME, entityId).build(); } static YangInstanceIdentifier candidatePath(String entityType, YangInstanceIdentifier entityId, String candidateName) { - return YangInstanceIdentifier.builder(ENTITY_OWNERS_PATH).node(EntityType.QNAME). - nodeWithKey(EntityType.QNAME, ENTITY_TYPE_QNAME, entityType).node(ENTITY_QNAME). - nodeWithKey(ENTITY_QNAME, ENTITY_ID_QNAME, entityId).node(Candidate.QNAME). - nodeWithKey(Candidate.QNAME, CANDIDATE_NAME_QNAME, candidateName).build(); + return YangInstanceIdentifier.builder(ENTITY_OWNERS_PATH).node(EntityType.QNAME) + .nodeWithKey(EntityType.QNAME, ENTITY_TYPE_QNAME, entityType).node(ENTITY_QNAME) + .nodeWithKey(ENTITY_QNAME, ENTITY_ID_QNAME, entityId).node(Candidate.QNAME) + .nodeWithKey(Candidate.QNAME, CANDIDATE_NAME_QNAME, candidateName).build(); } @@ -82,8 +82,8 @@ final class EntityOwnersModel { static ContainerNode entityOwnersWithEntityTypeEntry(MapEntryNode entityTypeNode) { return ImmutableContainerNodeBuilder.create().withNodeIdentifier( - ENTITY_OWNERS_NODE_ID).addChild(ImmutableNodes.mapNodeBuilder(EntityType.QNAME). - addChild(entityTypeNode).build()).build(); + ENTITY_OWNERS_NODE_ID).addChild(ImmutableNodes.mapNodeBuilder(EntityType.QNAME) + .addChild(entityTypeNode).build()).build(); } static MapEntryNode entityTypeEntryWithEntityEntry(String entityType, MapEntryNode entityNode) { @@ -98,8 +98,8 @@ final class EntityOwnersModel { } static MapNode candidateEntry(String candidateName) { - return ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(Candidate.QNAME)). - addChild(candidateMapEntry(candidateName)).build(); + return ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(Candidate.QNAME)) + .addChild(candidateMapEntry(candidateName)).build(); } static MapEntryNode candidateMapEntry(String candidateName) { @@ -111,11 +111,12 @@ final class EntityOwnersModel { ImmutableNodes.leafNode(ENTITY_OWNER_QNAME, owner)).build(); } - static String entityTypeFromEntityPath(YangInstanceIdentifier entityPath){ + public static String entityTypeFromEntityPath(YangInstanceIdentifier entityPath) { YangInstanceIdentifier parent = entityPath; - while(!parent.isEmpty()) { - if (ENTITY_TYPE_QNAME.equals(parent.getLastPathArgument().getNodeType())) { - YangInstanceIdentifier.NodeIdentifierWithPredicates entityTypeLastPathArgument = (YangInstanceIdentifier.NodeIdentifierWithPredicates) parent.getLastPathArgument(); + while (!parent.isEmpty()) { + if (EntityType.QNAME.equals(parent.getLastPathArgument().getNodeType())) { + YangInstanceIdentifier.NodeIdentifierWithPredicates entityTypeLastPathArgument = + (YangInstanceIdentifier.NodeIdentifierWithPredicates) parent.getLastPathArgument(); return (String) entityTypeLastPathArgument.getKeyValues().get(ENTITY_TYPE_QNAME); } parent = parent.getParent(); @@ -123,21 +124,21 @@ final class EntityOwnersModel { return null; } - static Entity createEntity(YangInstanceIdentifier entityPath) { + static DOMEntity createEntity(YangInstanceIdentifier entityPath) { String entityType = null; YangInstanceIdentifier entityId = null; - for(PathArgument pathArg: entityPath.getPathArguments()) { - if(pathArg instanceof NodeIdentifierWithPredicates) { + for (PathArgument pathArg: entityPath.getPathArguments()) { + if (pathArg instanceof NodeIdentifierWithPredicates) { NodeIdentifierWithPredicates nodeKey = (NodeIdentifierWithPredicates) pathArg; Entry key = nodeKey.getKeyValues().entrySet().iterator().next(); - if(ENTITY_TYPE_QNAME.equals(key.getKey())) { + if (ENTITY_TYPE_QNAME.equals(key.getKey())) { entityType = key.getValue().toString(); - } else if(ENTITY_ID_QNAME.equals(key.getKey())) { + } else if (ENTITY_ID_QNAME.equals(key.getKey())) { entityId = (YangInstanceIdentifier) key.getValue(); } } } - return new Entity(entityType, entityId); + return new DOMEntity(entityType, entityId); } }