use of org.openkilda.model.PortDiscrepancy in project open-kilda by telstra.
the class StatsService method processInventoryPorts.
private void processInventoryPorts(final List<PortInfo> portStats, final List<Port> inventoryPorts) {
if (!CollectionUtil.isEmpty(inventoryPorts)) {
List<PortInfo> discrepancyPorts = new ArrayList<PortInfo>();
for (Port port : inventoryPorts) {
int index = -1;
for (PortInfo portInfo : portStats) {
if (port.getPortNumber() == Integer.parseInt(portInfo.getPortNumber())) {
index = portStats.indexOf(portInfo);
break;
}
}
if (index >= 0) {
PortInfo portInfo = portStats.get(index);
portConverter.appendInventoryInfo(portInfo, port);
PortDiscrepancy portDiscrepancy = new PortDiscrepancy();
portDiscrepancy.setControllerDiscrepancy(false);
if (!portInfo.getAssignmenttype().equalsIgnoreCase(port.getAssignmentType())) {
portDiscrepancy.setAssignmentType(true);
portDiscrepancy.setControllerAssignmentType(portInfo.getAssignmenttype());
portDiscrepancy.setInventoryAssignmentType(port.getAssignmentType());
}
portInfo.setDiscrepancy(portDiscrepancy);
} else {
PortInfo portInfoObj = new PortInfo();
portConverter.toPortInfo(portInfoObj, port);
discrepancyPorts.add(portInfoObj);
}
}
for (PortInfo portInfo : portStats) {
boolean flag = false;
for (Port port : inventoryPorts) {
if (port.getPortNumber() == Integer.parseInt(portInfo.getPortNumber())) {
flag = true;
break;
}
}
if (!flag) {
PortDiscrepancy discrepancy = new PortDiscrepancy();
discrepancy.setInventoryDiscrepancy(true);
discrepancy.setControllerDiscrepancy(false);
discrepancy.setAssignmentType(true);
discrepancy.setControllerAssignmentType(portInfo.getAssignmenttype());
discrepancy.setInventoryAssignmentType(null);
portInfo.setDiscrepancy(discrepancy);
}
}
portStats.addAll(discrepancyPorts);
}
}
use of org.openkilda.model.PortDiscrepancy in project open-kilda by telstra.
the class PortConverter method toPortInfo.
/**
* To port info.
*
* @param portInfo the port info
* @param port the inventory port
* @return the port info
*/
public PortInfo toPortInfo(final PortInfo portInfo, final Port port) {
PortDiscrepancy discrepancy = new PortDiscrepancy();
discrepancy.setControllerDiscrepancy(true);
discrepancy.setInventoryDiscrepancy(false);
discrepancy.setAssignmentType(true);
discrepancy.setControllerAssignmentType(null);
discrepancy.setInventoryAssignmentType(port.getAssignmentType());
portInfo.setDiscrepancy(discrepancy);
appendInventoryInfo(portInfo, port);
portInfo.setCustomeruuid(port.getCustomer().getCustomerUuid());
portInfo.setPortNumber(String.valueOf(port.getPortNumber()));
portInfo.setStatus(port.getStatus());
return portInfo;
}
Aggregations