blob: 88cb4800001cc8735da9d9fed32f2426bbb22881 [file] [log] [blame]
hirokiec18d3a2018-05-16 15:27:37 -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
hirokid8fd7862018-10-09 15:24:24 +090019import org.onosproject.yang.gen.v1.tapicommon.rev20181016.tapicommon.DefaultContext;
20import org.onosproject.yang.gen.v1.tapicommon.rev20181016.tapicommon.Uuid;
21import org.onosproject.yang.gen.v1.tapitopology.rev20181016.tapitopology.context.augmentedtapicommoncontext.DefaultTopologyContext;
22import org.onosproject.yang.gen.v1.tapitopology.rev20181016.tapitopology.link.DefaultNodeEdgePoint;
23import org.onosproject.yang.gen.v1.tapitopology.rev20181016.tapitopology.topology.DefaultLink;
24import org.onosproject.yang.gen.v1.tapitopology.rev20181016.tapitopology.topologycontext.DefaultTopology;
25import org.onosproject.yang.gen.v1.tapitopology.rev20181016.tapitopology.topologycontext.TopologyKeys;
hirokiec18d3a2018-05-16 15:27:37 -070026import org.onosproject.yang.model.ModelObjectId;
27
hirokif4ed5212018-05-26 22:39:38 -070028import static com.google.common.base.Preconditions.checkNotNull;
29import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.getUuid;
hirokiec18d3a2018-05-16 15:27:37 -070030import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
31
32/**
hirokif4ed5212018-05-26 22:39:38 -070033 * Utility class to deal with TAPI Link with DCS.
hirokiec18d3a2018-05-16 15:27:37 -070034 */
hirokif4ed5212018-05-26 22:39:38 -070035public final class TapiLinkHandler extends TapiObjectHandler<DefaultLink> {
hirokiec18d3a2018-05-16 15:27:37 -070036
37 private Uuid topologyUuid;
hirokiec18d3a2018-05-16 15:27:37 -070038
hirokif4ed5212018-05-26 22:39:38 -070039 private TapiLinkHandler() {
40 obj = new DefaultLink();
41 setId();
hirokiec18d3a2018-05-16 15:27:37 -070042 }
43
hirokif4ed5212018-05-26 22:39:38 -070044 public static TapiLinkHandler create() {
45 return new TapiLinkHandler();
hirokiec18d3a2018-05-16 15:27:37 -070046 }
47
48 @Override
hirokif4ed5212018-05-26 22:39:38 -070049 protected Uuid getIdDetail() {
50 return getUuid(obj);
51 }
52
53 @Override
54 protected void setIdDetail(Uuid uuid) {
55 setUuid(obj, uuid);
56 }
57
58 @Override
59 public ModelObjectId getParentModelObjectId() {
60 checkNotNull(topologyUuid);
hirokiec18d3a2018-05-16 15:27:37 -070061
62 TopologyKeys topologyKey = new TopologyKeys();
63 topologyKey.uuid(topologyUuid);
hiroki684aa2f2018-05-19 20:48:49 -070064 return ModelObjectId.builder()
hirokiec18d3a2018-05-16 15:27:37 -070065 .addChild(DefaultContext.class)
hirokid8fd7862018-10-09 15:24:24 +090066 .addChild(DefaultTopologyContext.class)
hirokiec18d3a2018-05-16 15:27:37 -070067 .addChild(DefaultTopology.class, topologyKey)
68 .build();
hirokiec18d3a2018-05-16 15:27:37 -070069 }
70
hirokif4ed5212018-05-26 22:39:38 -070071 public TapiLinkHandler setTopologyUuid(Uuid topologyUuid) {
72 this.topologyUuid = topologyUuid;
73 return this;
hirokiec18d3a2018-05-16 15:27:37 -070074 }
75
hirokif4ed5212018-05-26 22:39:38 -070076 public TapiLinkHandler addNep(TapiNepRef nepRef) {
77 DefaultNodeEdgePoint nep = new DefaultNodeEdgePoint();
hirokid8fd7862018-10-09 15:24:24 +090078 nep.topologyUuid(nepRef.getTopologyId());
79 nep.nodeUuid(nepRef.getNodeId());
80 nep.nodeEdgePointUuid(nepRef.getNepId());
hirokif4ed5212018-05-26 22:39:38 -070081 obj.addToNodeEdgePoint(nep);
82 return this;
hirokiec18d3a2018-05-16 15:27:37 -070083 }
84
85}