fix javadocs warnings
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / openroadminterface / OpenRoadmInterfaceFactory.java
1 /*
2  * Copyright © 2017 AT&T 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
9 package org.opendaylight.transportpce.renderer.openroadminterface;
10
11 import java.util.List;
12
13 import org.opendaylight.transportpce.common.StringConstants;
14 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
15 import org.opendaylight.transportpce.common.mapping.MappingUtils;
16 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
17 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev170228.network.nodes.Mapping;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.OchAttributes;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev161014.RateIdentity;
20
21 public class OpenRoadmInterfaceFactory {
22
23     private final MappingUtils mappingUtils;
24     private final OpenRoadmInterface121 openRoadmInterface121;
25     private final OpenRoadmInterface221 openRoadmInterface221;
26
27
28     public OpenRoadmInterfaceFactory(MappingUtils mappingUtils, OpenRoadmInterface121 openRoadmInterface121,
29         OpenRoadmInterface221 openRoadmInterface221) {
30         this.mappingUtils = mappingUtils;
31         this.openRoadmInterface121 = openRoadmInterface121;
32         this.openRoadmInterface221 = openRoadmInterface221;
33     }
34
35     public String createOpenRoadmEthInterface(String nodeId,
36                                               String logicalConnPoint) throws OpenRoadmInterfaceException {
37
38         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
39             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
40                 return openRoadmInterface121.createOpenRoadmEthInterface(nodeId, logicalConnPoint);
41             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
42                 return openRoadmInterface221.createOpenRoadmEthInterface(nodeId, logicalConnPoint);
43             default:
44                 return null;
45         }
46     }
47
48
49     /**
50      * This methods creates an OCH interface on the given termination point on
51      * Roadm.
52      *
53      * @param nodeId node ID
54      * @param logicalConnPoint logical connection point
55      * @param waveNumber wavelength number of the OCH interface.
56      * @throws OpenRoadmInterfaceException OpenRoadm interface exception
57      *
58      * @return Name of the interface if successful, otherwise return null.
59      */
60
61     public List<String> createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber)
62         throws OpenRoadmInterfaceException {
63
64         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
65             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
66                 return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint,waveNumber);
67             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
68                 return openRoadmInterface221.createFlexOCH(nodeId, logicalConnPoint,waveNumber);
69             default:
70                 return null;
71         }
72     }
73
74
75     public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint, Long waveNumber,
76         Class<? extends RateIdentity> rate, OchAttributes.ModulationFormat format) throws OpenRoadmInterfaceException {
77         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
78             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
79                 return openRoadmInterface121.createOpenRoadmOchInterface(nodeId, logicalConnPoint, waveNumber,
80                     rate, format);
81             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
82                 return openRoadmInterface221.createOpenRoadmOchInterface(nodeId,logicalConnPoint,waveNumber);
83             default:
84                 return null;
85         }
86     }
87
88     /**
89      * This methods creates an ODU interface on the given termination point.
90      *
91      * @param nodeId node ID
92      * @param logicalConnPoint logical connection point
93      * @param supportingOtuInterface supporting OTU interface
94      * @throws OpenRoadmInterfaceException OpenRoadm interface exception
95      *
96      * @return Name of the interface if successful, otherwise return null.
97      */
98
99     public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint, String supportingOtuInterface)
100             throws OpenRoadmInterfaceException {
101         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
102             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
103                 return openRoadmInterface121.createOpenRoadmOdu4Interface(nodeId, logicalConnPoint,
104                     supportingOtuInterface);
105             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
106                 return openRoadmInterface221.createOpenRoadmOdu4Interface(nodeId, logicalConnPoint,
107                     supportingOtuInterface);
108             default:
109                 return null;
110         }
111     }
112
113     /**
114      * This methods creates an OTU interface on the given termination point.
115      *
116      * @param nodeId node ID
117      * @param logicalConnPoint logical connection point
118      * @param supportOchInterface supporting OCH interface
119      * @throws OpenRoadmInterfaceException OpenRoadm interface exception
120      *
121      * @return Name of the interface if successful, otherwise return null.
122      */
123
124     public String createOpenRoadmOtu4Interface(String nodeId, String logicalConnPoint, String supportOchInterface)
125             throws OpenRoadmInterfaceException {
126         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
127             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
128                 return openRoadmInterface121.createOpenRoadmOtu4Interface(nodeId,
129                     logicalConnPoint,supportOchInterface);
130             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
131                 return openRoadmInterface221.createOpenRoadmOtu4Interface(nodeId,logicalConnPoint, supportOchInterface);
132             default:
133                 return null;
134         }
135     }
136
137     public String createOpenRoadmOchInterfaceName(String logicalConnectionPoint, Long waveNumber) {
138         return logicalConnectionPoint + "-" + waveNumber;
139     }
140
141     public String createOpenRoadmOmsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException {
142         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
143             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
144                 return openRoadmInterface121.createOpenRoadmOmsInterface(nodeId,mapping);
145             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
146                 return openRoadmInterface221.createOpenRoadmOmsInterface(nodeId,mapping);
147             default:
148                 return null;
149         }
150     }
151
152     public String createOpenRoadmOtsInterface(String nodeId, Mapping mapping) throws OpenRoadmInterfaceException {
153         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
154             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
155                 return openRoadmInterface121.createOpenRoadmOtsInterface(nodeId,mapping);
156             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
157                 return openRoadmInterface221.createOpenRoadmOtsInterface(nodeId,mapping);
158             default:
159                 return null;
160         }
161     }
162
163     public boolean isUsedbyXc(String nodeId, String interfaceName, String xc,
164         DeviceTransactionManager deviceTransactionManager) {
165         switch (mappingUtils.getOpenRoadmVersion(nodeId)) {
166             case StringConstants.OPENROADM_DEVICE_VERSION_1_2_1:
167                 return openRoadmInterface121.isUsedByXc(nodeId, interfaceName, xc, deviceTransactionManager);
168             case StringConstants.OPENROADM_DEVICE_VERSION_2_2_1:
169                 return openRoadmInterface221.isUsedByXc(nodeId, interfaceName, xc, deviceTransactionManager);
170             default:
171                 return false;
172         }
173     }
174
175
176 }