Search in sources :

Example 1 with AdjacentCellInfo

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.AdjacentCellInfo in project open-smart-grid-platform by OSGP.

the class GetGsmDiagnosticResponseFactory method fromParameterMap.

public static GetGsmDiagnosticResponse fromParameterMap(final Map<String, String> requestParameters) {
    final String operator = getString(requestParameters, "operator");
    final ModemRegistrationStatus modemRegistrationStatus = getEnum(requestParameters, "modemRegistrationStatus", ModemRegistrationStatus.class);
    final CircuitSwitchedStatus circuitSwitchedStatus = getEnum(requestParameters, "circuitSwitchedStatus", CircuitSwitchedStatus.class);
    final PacketSwitchedStatus packetSwitchedStatus = getEnum(requestParameters, "packetSwitchedStatus", PacketSwitchedStatus.class);
    final Long cellId = getLong(requestParameters, "cellId");
    final Integer locationId = getInteger(requestParameters, "locationId");
    final SignalQuality signalQuality = getEnum(requestParameters, "signalQuality", SignalQuality.class);
    final BitErrorRate bitErrorRate = getEnum(requestParameters, "bitErrorRate", BitErrorRate.class);
    final Integer mobileCountryCode = getInteger(requestParameters, "mobileCountryCode");
    final Integer mobileNetworkCode = getInteger(requestParameters, "mobileNetworkCode");
    final Long channelNumber = getLong(requestParameters, "channelNumber");
    final CellInfo cellInfo = new CellInfo();
    cellInfo.setCellId(cellId);
    cellInfo.setLocationId(locationId);
    cellInfo.setSignalQuality(signalQuality);
    cellInfo.setBitErrorRate(bitErrorRate);
    cellInfo.setMobileCountryCode(mobileCountryCode);
    cellInfo.setMobileNetworkCode(mobileNetworkCode);
    cellInfo.setChannelNumber(channelNumber);
    final List<String> adjacentCellIds = Arrays.asList(getString(requestParameters, "adjacentCellIds").split(","));
    final List<String> adjacentCellSignalQualities = Arrays.asList(getString(requestParameters, "adjacentCellSignalQualities").split(","));
    final List<AdjacentCellInfo> adjacentCellInfos = IntStream.range(0, adjacentCellIds.size()).mapToObj(i -> {
        final AdjacentCellInfo adjacentCellInfo = new AdjacentCellInfo();
        adjacentCellInfo.setCellId(Long.parseLong(adjacentCellIds.get(i)));
        adjacentCellInfo.setSignalQuality(SignalQuality.fromValue(adjacentCellSignalQualities.get(i)));
        return adjacentCellInfo;
    }).collect(Collectors.toList());
    final GetGsmDiagnosticResponse getGsmDiagnosticResponse = new GetGsmDiagnosticResponse();
    getGsmDiagnosticResponse.setOperator(operator);
    getGsmDiagnosticResponse.setModemRegistrationStatus(modemRegistrationStatus);
    getGsmDiagnosticResponse.setCircuitSwitchedStatus(circuitSwitchedStatus);
    getGsmDiagnosticResponse.setPacketSwitchedStatus(packetSwitchedStatus);
    getGsmDiagnosticResponse.setCellInfo(cellInfo);
    getGsmDiagnosticResponse.getAdjacentCells().addAll(adjacentCellInfos);
    return getGsmDiagnosticResponse;
}
Also used : IntStream(java.util.stream.IntStream) SignalQuality(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.SignalQuality) Arrays(java.util.Arrays) AdjacentCellInfo(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.AdjacentCellInfo) ReadSettingsHelper.getEnum(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getEnum) Collectors(java.util.stream.Collectors) PacketSwitchedStatus(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.PacketSwitchedStatus) ReadSettingsHelper.getLong(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getLong) List(java.util.List) BitErrorRate(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.BitErrorRate) GetGsmDiagnosticResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetGsmDiagnosticResponse) ReadSettingsHelper.getInteger(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getInteger) Map(java.util.Map) CellInfo(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.CellInfo) ModemRegistrationStatus(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.ModemRegistrationStatus) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) CircuitSwitchedStatus(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.CircuitSwitchedStatus) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) ModemRegistrationStatus(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.ModemRegistrationStatus) BitErrorRate(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.BitErrorRate) AdjacentCellInfo(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.AdjacentCellInfo) ReadSettingsHelper.getInteger(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getInteger) PacketSwitchedStatus(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.PacketSwitchedStatus) AdjacentCellInfo(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.AdjacentCellInfo) CellInfo(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.CellInfo) SignalQuality(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.SignalQuality) ReadSettingsHelper.getLong(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getLong) GetGsmDiagnosticResponse(org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetGsmDiagnosticResponse) CircuitSwitchedStatus(org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.CircuitSwitchedStatus)

Aggregations

Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 GetGsmDiagnosticResponse (org.opensmartgridplatform.adapter.ws.schema.smartmetering.bundle.GetGsmDiagnosticResponse)1 AdjacentCellInfo (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.AdjacentCellInfo)1 BitErrorRate (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.BitErrorRate)1 CellInfo (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.CellInfo)1 CircuitSwitchedStatus (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.CircuitSwitchedStatus)1 ModemRegistrationStatus (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.ModemRegistrationStatus)1 PacketSwitchedStatus (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.PacketSwitchedStatus)1 SignalQuality (org.opensmartgridplatform.adapter.ws.schema.smartmetering.management.SignalQuality)1 ReadSettingsHelper.getEnum (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getEnum)1 ReadSettingsHelper.getInteger (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getInteger)1 ReadSettingsHelper.getLong (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getLong)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1