blob: 89ac48eaf48beaeda4fd7b3744d6124e54770703 [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
19import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext;
20import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid;
21import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.ConnectivityServiceKeys;
22import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivitycontext.DefaultConnectivityService;
23import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivityservice.DefaultConnection;
24import org.onosproject.yang.gen.v1.tapiconnectivity.rev20180307.tapiconnectivity.connectivityservice.EndPoint;
25import org.onosproject.yang.model.DefaultModelObjectData;
26import org.onosproject.yang.model.ModelObjectData;
27import org.onosproject.yang.model.ModelObjectId;
28
29import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.getUuid;
30import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid;
31
32/**
33 * Utility class to deal with TAPI ConnectivityService with DCS.
34 */
35public final class TapiConnectivityServiceHandler extends TapiObjectHandler<DefaultConnectivityService> {
36
37 private TapiConnectivityServiceHandler() {
38 obj = new DefaultConnectivityService();
39 setId();
40 }
41
42 public static TapiConnectivityServiceHandler create() {
43 return new TapiConnectivityServiceHandler();
44 }
45
46 @Override
47 protected Uuid getIdDetail() {
48 return getUuid(obj);
49 }
50
51 @Override
52 protected void setIdDetail(Uuid uuid) {
53 setUuid(obj, uuid);
54 }
55
56 @Override
57 public ModelObjectId getParentModelObjectId() {
58 return ModelObjectId.builder().addChild(DefaultContext.class).build();
59 }
60
61 @Override
62 public ModelObjectData getChildModelObjectData() {
63
64 ConnectivityServiceKeys key = new ConnectivityServiceKeys();
65 key.uuid(getId());
66
67 DefaultConnection mObj = new DefaultConnection();
68
69 ModelObjectId mId = ModelObjectId.builder()
70 .addChild(DefaultContext.class)
71 .addChild(DefaultConnectivityService.class, key)
72 .build();
73
74 return DefaultModelObjectData.builder()
75 .addModelObject(mObj)
76 .identifier(mId)
77 .build();
78 }
79
80 public TapiConnectivityServiceHandler addSep(EndPoint sep) {
81 obj.addToEndPoint(sep);
82 return this;
83 }
84
85 public TapiConnectivityServiceHandler addConnection(Uuid connectionUuid) {
86 DefaultConnection connection = new DefaultConnection();
87 connection.connectionId(connectionUuid.toString());
88 obj.addToConnection(connection);
89 return this;
90 }
91}