package org.opendaylight.transportpce.pce.networkanalyzer;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
serviceFormatA = input.getServiceAEnd().getServiceFormat().getName();
serviceFormatZ = input.getServiceZEnd().getServiceFormat().getName();
serviceRate = input.getServiceAEnd().getServiceRate();
- serviceType = ServiceTypes.getServiceType(serviceFormatA, serviceRate,
- (NodeTypes.Xpdr.equals(portMapping.getNode(input.getServiceAEnd().getNodeId()).getNodeInfo().getNodeType())
- && input.getServiceAEnd().getTxDirection() != null
- && input.getServiceAEnd().getTxDirection().getPort() != null
- && input.getServiceAEnd().getTxDirection().getPort().getPortName() != null)
- ? portMapping.getMapping(input.getServiceAEnd().getNodeId(),
+ serviceType = ServiceTypes.getServiceType(
+ serviceFormatA,
+ serviceRate,
+ NodeTypes.Xpdr.equals(portMapping.getNode(input.getServiceAEnd().getNodeId()).getNodeInfo().getNodeType())
+ && checkAendInputTxPortName()
+ ? portMapping.getMapping(
+ input.getServiceAEnd().getNodeId(),
input.getServiceAEnd().getTxDirection().getPort().getPortName())
: null);
return true;
}
+ private boolean checkAendInputTxPortName() {
+ return checkAendInputTxPort()
+ && input.getServiceAEnd().getTxDirection().getPort().getPortName() != null;
+ }
+
+ private boolean checkAendInputTxPortDeviceName() {
+ return checkAendInputTxPort()
+ && input.getServiceAEnd().getTxDirection().getPort().getPortDeviceName() != null;
+ }
+
+ private boolean checkAendInputTxPort() {
+ return input.getServiceAEnd() != null
+ && input.getServiceAEnd().getTxDirection() != null
+ && input.getServiceAEnd().getTxDirection().getPort() != null;
+ }
+
+ private boolean checkZendInputTxPortDeviceName() {
+ return input.getServiceZEnd() != null
+ && input.getServiceZEnd().getTxDirection() != null
+ && input.getServiceZEnd().getTxDirection().getPort() != null
+ && input.getServiceZEnd().getTxDirection().getPort().getPortDeviceName() != null;
+ }
+
private void getAZnodeId() {
- if (input.getServiceAEnd() != null
- && input.getServiceAEnd().getTxDirection() != null
- && input.getServiceAEnd().getTxDirection().getPort() != null
- && input.getServiceAEnd().getTxDirection().getPort().getPortDeviceName() != null) {
- anodeId = input.getServiceAEnd().getTxDirection().getPort().getPortDeviceName();
- } else {
- anodeId = input.getServiceAEnd().getNodeId();
- }
- if (input.getServiceZEnd() != null
- && input.getServiceZEnd().getTxDirection() != null
- && input.getServiceZEnd().getTxDirection().getPort() != null
- && input.getServiceZEnd().getTxDirection().getPort().getPortDeviceName() != null) {
- znodeId = input.getServiceZEnd().getTxDirection().getPort().getPortDeviceName();
- } else {
- znodeId = input.getServiceZEnd().getNodeId();
- }
+ anodeId =
+ checkAendInputTxPortDeviceName()
+ ? input.getServiceAEnd().getTxDirection().getPort().getPortDeviceName()
+ : input.getServiceAEnd().getNodeId();
+ znodeId =
+ checkZendInputTxPortDeviceName()
+ ? input.getServiceZEnd().getTxDirection().getPort().getPortDeviceName()
+ : input.getServiceZEnd().getNodeId();
}
private boolean readMdSal() {
return;
}
+ @SuppressWarnings("fallthrough")
+ @SuppressFBWarnings(
+ value = "SF_SWITCH_FALLTHROUGH",
+ justification = "intentional fallthrough")
private boolean isAZendPceNode(String serviceFormat, PceOpticalNode pceNode, String azNodeId, String azEndPoint) {
switch (serviceFormat) {
case "Ethernet":
if (pceNode.getSupNetworkNodeId().equals(azNodeId)) {
return true;
}
- if ("A".equals(azEndPoint)
- && this.input.getServiceAEnd().getTxDirection() != null
- && this.input.getServiceAEnd().getTxDirection().getPort() != null
- && this.input.getServiceAEnd().getTxDirection().getPort().getPortDeviceName() != null
- && pceNode.getNodeId().getValue()
- .equals(this.input.getServiceAEnd().getTxDirection().getPort().getPortDeviceName())) {
- return true;
- }
- if ("Z".equals(azEndPoint)
- && this.input.getServiceZEnd().getTxDirection() != null
- && this.input.getServiceZEnd().getTxDirection().getPort() != null
- && this.input.getServiceZEnd().getTxDirection().getPort().getPortDeviceName() != null
- && pceNode.getNodeId().getValue()
- .equals(this.input.getServiceZEnd().getTxDirection().getPort().getPortDeviceName())) {
- return true;
- }
- return false;
+ //fallthrough
case "OTU":
- if ("A".equals(azEndPoint) && pceNode.getNodeId().getValue()
- .equals(this.input.getServiceAEnd().getTxDirection().getPort().getPortDeviceName())) {
- return true;
- }
- if ("Z".equals(azEndPoint) && pceNode.getNodeId().getValue()
- .equals(this.input.getServiceZEnd().getTxDirection().getPort().getPortDeviceName())) {
- return true;
+ switch (azEndPoint) {
+ case "A":
+ return checkAendInputTxPortDeviceName()
+ && pceNode.getNodeId().getValue()
+ .equals(this.input.getServiceAEnd().getTxDirection().getPort().getPortDeviceName());
+ case "Z":
+ return checkZendInputTxPortDeviceName()
+ && pceNode.getNodeId().getValue()
+ .equals(this.input.getServiceZEnd().getTxDirection().getPort().getPortDeviceName());
+ default:
+ return false;
}
- return false;
default:
LOG.debug("Unsupported service Format {} for node {}", serviceFormat, pceNode.getNodeId().getValue());
return false;
String moduleName = params[params.length - 1];
for (McCapabilities mcCapabitility : mcCapabilities) {
if (mcCapabitility.getMcNodeName().contains("XPDR")
- && mcCapabitility.getSlotWidthGranularity() != null) {
+ && mcCapabitility.getSlotWidthGranularity() != null) {
return mcCapabitility.getSlotWidthGranularity().getValue();
}
if (mcCapabitility.getMcNodeName().contains(moduleName)
String moduleName = params[params.length - 1];
for (McCapabilities mcCapabitility : mcCapabilities) {
if (mcCapabitility.getMcNodeName().contains("XPDR")
- && mcCapabitility.getCenterFreqGranularity() != null) {
+ && mcCapabitility.getCenterFreqGranularity() != null) {
return mcCapabitility.getCenterFreqGranularity().getValue();
}
if (mcCapabitility.getMcNodeName().contains(moduleName)
- && mcCapabitility.getCenterFreqGranularity() != null) {
+ && mcCapabitility.getCenterFreqGranularity() != null) {
return mcCapabitility.getCenterFreqGranularity().getValue();
}
}