use of org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData in project open-smart-grid-platform by OSGP.
the class WsCoreResponseDataSteps method assertResponseDataHasNotificationsAndMessageType.
private void assertResponseDataHasNotificationsAndMessageType(final String correlationUid, final Short expectedNumberOfNotificationsSent, final String expectedMessageType) {
final ResponseData responseData = this.responseDataRepository.findByCorrelationUid(correlationUid);
assertThat(responseData.getNumberOfNotificationsSent()).as(PlatformKeys.KEY_NUMBER_OF_NOTIFICATIONS_SENT).isEqualTo(expectedNumberOfNotificationsSent);
assertThat(responseData.getMessageType()).as(PlatformKeys.KEY_MESSAGE_TYPE).isEqualTo(expectedMessageType);
}
use of org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData in project open-smart-grid-platform by OSGP.
the class WsCoreResponseDataSteps method theResponseDataRecordShouldNotBeDeleted.
@Then("^the response data record with correlation uid \\\"(.*)\\\" should not be deleted in ws-core$")
public void theResponseDataRecordShouldNotBeDeleted(final String correlationUid) {
final ResponseData responseData = this.responseDataRepository.findByCorrelationUid(correlationUid);
assertThat(responseData).as("Response data should not be deleted in ws-core").isNotNull();
}
use of org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData in project open-smart-grid-platform by OSGP.
the class SmartMeteringAdhocEndpoint method getAssociationLnObjectsResponse.
@PayloadRoot(localPart = "GetAssociationLnObjectsAsyncRequest", namespace = SMARTMETER_ADHOC_NAMESPACE)
@ResponsePayload
public GetAssociationLnObjectsResponse getAssociationLnObjectsResponse(@RequestPayload final GetAssociationLnObjectsAsyncRequest request) throws OsgpException {
GetAssociationLnObjectsResponse response = null;
try {
response = new GetAssociationLnObjectsResponse();
final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
if (responseData.getMessageData() instanceof AssociationLnListType) {
response.setAssociationLnList(this.adhocMapper.map(responseData.getMessageData(), org.opensmartgridplatform.adapter.ws.schema.smartmetering.adhoc.AssociationLnListType.class));
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData in project open-smart-grid-platform by OSGP.
the class SmartMeteringAdhocEndpoint method getScanMbusChannelsResponse.
@PayloadRoot(localPart = "ScanMbusChannelsAsyncRequest", namespace = SMARTMETER_ADHOC_NAMESPACE)
@ResponsePayload
public ScanMbusChannelsResponse getScanMbusChannelsResponse(@RequestPayload final ScanMbusChannelsAsyncRequest request) throws OsgpException {
ScanMbusChannelsResponse response = null;
try {
response = new ScanMbusChannelsResponse();
final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
this.throwExceptionIfResultNotOk(responseData, "retrieving the scan m-bus channels response");
response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
final ScanMbusChannelsResponseData scanMbusChannelsResponse = (ScanMbusChannelsResponseData) responseData.getMessageData();
if (ResponseMessageResultType.OK == responseData.getResultType()) {
final List<MbusChannelShortEquipmentIdentifier> channelShortIds = response.getChannelShortIds();
channelShortIds.addAll(this.adhocMapper.mapAsList(scanMbusChannelsResponse.getChannelShortIds(), MbusChannelShortEquipmentIdentifier.class));
} else if (responseData.getMessageData() instanceof OsgpException) {
throw (OsgpException) responseData.getMessageData();
} else if (responseData.getMessageData() instanceof Exception) {
throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred: Scan M-Bus Channels", (Exception) responseData.getMessageData());
} else {
throw new TechnicalException(ComponentType.WS_SMART_METERING, "An exception occurred: Scan M-Bus Channels", null);
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
use of org.opensmartgridplatform.adapter.ws.domain.entities.ResponseData in project open-smart-grid-platform by OSGP.
the class SmartMeteringConfigurationEndpoint method getPushNotificationAlarm.
@PayloadRoot(localPart = "GetPushNotificationAlarmAsyncRequest", namespace = SMARTMETER_CONFIGURATION_NAMESPACE)
@ResponsePayload
public GetPushNotificationAlarmResponse getPushNotificationAlarm(@OrganisationIdentification final String organisationIdentification, @RequestPayload final GetPushNotificationAlarmAsyncRequest request) throws OsgpException {
log.info("GetPushNotificationAlarmRequest Request received from organisation {} for device: {}.", organisationIdentification, request.getDeviceIdentification());
final GetPushNotificationAlarmResponse response = new GetPushNotificationAlarmResponse();
try {
final ResponseData responseData = this.responseDataService.get(request.getCorrelationUid(), ComponentType.WS_SMART_METERING);
response.setResult(OsgpResultType.fromValue(responseData.getResultType().getValue()));
if (responseData != null) {
final PushNotificationAlarm p = (PushNotificationAlarm) responseData.getMessageData();
response.setDecodedMessage(p.toString());
response.setEncodedMessage(p.getAlarmBytes());
response.getAlarm().addAll(this.configurationMapper.mapAsList(p.getAlarms(), org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AlarmType.class));
}
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
Aggregations