fix some javadoc warnings
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / MapUtils.java
1 /*
2  * Copyright © 2017 AT&T, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.pce;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.link.rev181130.span.attributes.LinkConcatenation;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.Link1;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev181130.networks.network.link.oms.attributes.Span;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev181130.OpenroadmLinkType;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.Link;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 public final class MapUtils {
23     /* Logging. */
24     private static final Logger LOG = LoggerFactory.getLogger(MapUtils.class);
25
26     private MapUtils() {
27     }
28
29     public static String getCLLI(Node node) {
30         // TODO STUB retrieve CLLI from node. for now it is supporting node ID of the first supp node
31         return node.getSupportingNode().get(0).getNodeRef().getValue();
32     }
33
34     public static List<Long> getSRLG(Link link) {
35         List<Long> srlgList = new ArrayList<Long>();
36         Span span = getOmsAttributesSpan(link);
37         if (span != null) {
38             List<LinkConcatenation> linkList = span.getLinkConcatenation();
39             for (LinkConcatenation lc : linkList) {
40                 srlgList.add(lc.getSRLGId());
41             }
42         } else {
43             LOG.error("MapUtils: No LinkConcatenation for link : {}", link);
44         }
45         return srlgList;
46     }
47
48     public static String getSupNode(Node node) {
49         // TODO: supporting IDs exist as a List. this code takes just the first element
50         return node.getSupportingNode().get(0).getNodeRef().getValue();
51     }
52
53     public static OpenroadmLinkType calcType(Link link) {
54         Link1 link1 = null;
55         OpenroadmLinkType tmplType = null;
56
57         link1 = link.augmentation(Link1.class);
58         if (link1 == null) {
59             LOG.error("MapUtils: No Link augmentation available. {}", link.getLinkId().getValue());
60             return null;
61         }
62
63         tmplType = link1.getLinkType();
64         if (tmplType == null) {
65             LOG.error("MapUtils: No Link type available. {}", link.getLinkId().getValue());
66             return null;
67         }
68         return tmplType;
69     }
70
71     public static Span getOmsAttributesSpan(Link link) {
72         Link1 link1 = null;
73         Span tempSpan = null;
74         link1 = link.augmentation(Link1.class);
75         if (link1 == null) {
76             LOG.error("MapUtils: No Link augmentation available. {}", link.getLinkId().getValue());
77             return null;
78         }
79         try {
80             tempSpan = link1.getOMSAttributes().getSpan();
81             if (tempSpan == null) {
82                 LOG.error("MapUtils: No Link getOMSAttributes available. {}", link.getLinkId().getValue());
83                 return null;
84             }
85         } catch (NullPointerException e) {
86             LOG.error("MapUtils: No Link getOMSAttributes available. {}", link.getLinkId().getValue());
87             return null;
88         }
89         return tempSpan;
90     }
91
92 }