blob: dbda3735517fd8c57962c45093ce747eb106b475 [file] [log] [blame]
hirokif4ed5212018-05-26 22:39:38 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.odtn.utils.tapi;
18
hiroki96ab3c22018-12-11 14:10:52 -080019import org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.DefaultContext;
20import org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.Uuid;
21import org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.ceplist.DefaultConnectionEndPoint;
22import org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectionendpoint.DefaultParentNodeEdgePoint;
23import org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.context.augmentedtapicommoncontext.DefaultTopologyContext;
24import org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.node.DefaultOwnedNodeEdgePoint;
25import org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.node.OwnedNodeEdgePointKeys;
26import org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topology.DefaultNode;
27import org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topology.NodeKeys;
28import org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topologycontext.DefaultTopology;
29import org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topologycontext.TopologyKeys;
hirokif4ed5212018-05-26 22:39:38 -070030import org.onosproject.yang.model.ModelObjectId;
31
32import static com.google.common.base.Preconditions.checkNotNull;
33import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.getUuid;
34import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
35
36/**
37 * Utility class to deal with TAPI CEP with DCS.
38 */
39public final class TapiCepHandler extends TapiObjectHandler<DefaultConnectionEndPoint> {
40
41 private Uuid topologyUuid;
42 private Uuid nodeUuid;
43 private Uuid nepUuid;
44
45 private TapiCepHandler() {
46 obj = new DefaultConnectionEndPoint();
47 setId();
48 }
49
50 public static TapiCepHandler create() {
51 return new TapiCepHandler();
52 }
53
54 @Override
55 protected Uuid getIdDetail() {
56 return getUuid(obj);
57 }
58
59 @Override
60 protected void setIdDetail(Uuid uuid) {
61 setUuid(obj, uuid);
62 }
63
64 @Override
65 public ModelObjectId getParentModelObjectId() {
66 checkNotNull(topologyUuid);
67 checkNotNull(nodeUuid);
68 checkNotNull(nodeUuid);
69
70 TopologyKeys topologyKey = new TopologyKeys();
71 topologyKey.uuid(topologyUuid);
72
73 NodeKeys nodeKey = new NodeKeys();
74 nodeKey.uuid(nodeUuid);
75
76 OwnedNodeEdgePointKeys nepKey = new OwnedNodeEdgePointKeys();
77 nepKey.uuid(nepUuid);
78
79 return ModelObjectId.builder()
80 .addChild(DefaultContext.class)
hirokid8fd7862018-10-09 15:24:24 +090081 .addChild(DefaultTopologyContext.class)
hirokif4ed5212018-05-26 22:39:38 -070082 .addChild(DefaultTopology.class, topologyKey)
83 .addChild(DefaultNode.class, nodeKey)
84 .addChild(DefaultOwnedNodeEdgePoint.class, nepKey)
85 .build();
86 }
87
88 public TapiCepHandler setTopologyUuid(Uuid topologyUuid) {
89 this.topologyUuid = topologyUuid;
90 return this;
91 }
92
93 public TapiCepHandler setNodeUuid(Uuid nodeUuid) {
94 this.nodeUuid = nodeUuid;
95 return this;
96 }
97
98 public TapiCepHandler setNepUuid(Uuid nepUuid) {
99 this.nepUuid = nepUuid;
100 return this;
101 }
102
103 public TapiCepHandler setParentNep() {
104 checkNotNull(topologyUuid);
105 checkNotNull(nodeUuid);
106 checkNotNull(nepUuid);
107
108 DefaultParentNodeEdgePoint parentNep = new DefaultParentNodeEdgePoint();
hirokid8fd7862018-10-09 15:24:24 +0900109 parentNep.topologyUuid(topologyUuid);
110 parentNep.nodeUuid(nodeUuid);
111 parentNep.nodeEdgePointUuid(nepUuid);
112 obj.parentNodeEdgePoint(parentNep);
hirokif4ed5212018-05-26 22:39:38 -0700113
114 return this;
115 }
116
117 public TapiCepHandler setParentNep(TapiNepRef nepRef) {
118 topologyUuid = Uuid.fromString(nepRef.getTopologyId());
119 nodeUuid = Uuid.fromString(nepRef.getNodeId());
120 nepUuid = Uuid.fromString(nepRef.getNepId());
121
122 setParentNep();
123 return this;
124 }
125}