use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AsyncResponse in project open-smart-grid-platform by OSGP.
the class SmartMeteringInstallationEndpoint method addDevice.
@PayloadRoot(localPart = "AddDeviceRequest", namespace = SMARTMETER_INSTALLATION_NAMESPACE)
@ResponsePayload
public AddDeviceAsyncResponse addDevice(@OrganisationIdentification final String organisationIdentification, @RequestPayload final AddDeviceRequest request, @MessagePriority final String messagePriority, @ScheduleTime final String scheduleTime, @ResponseUrl final String responseUrl, @BypassRetry final String bypassRetry) throws OsgpException {
log.info("Incoming AddDeviceRequest for meter: {}.", request.getDevice().getDeviceIdentification());
AsyncResponse asyncResponse = null;
try {
final SmartMeteringDevice device = this.installationMapper.map(request.getDevice(), SmartMeteringDevice.class);
final DeviceModel deviceModel = new DeviceModel(request.getDeviceModel().getManufacturer(), request.getDeviceModel().getModelCode(), "");
final AddSmartMeterRequest addSmartMeterRequest = new AddSmartMeterRequest(device, deviceModel);
final RequestMessageMetadata requestMessageMetadata = RequestMessageMetadata.newBuilder().withOrganisationIdentification(organisationIdentification).withDeviceIdentification(device.getDeviceIdentification()).withDeviceFunction(null).withMessageType(MessageType.ADD_METER).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).withBypassRetry(bypassRetry).build();
asyncResponse = this.requestService.enqueueAndSendRequest(requestMessageMetadata, addSmartMeterRequest);
this.saveResponseUrlIfNeeded(asyncResponse.getCorrelationUid(), responseUrl);
} catch (final ConstraintViolationException e) {
log.error("Exception: {} while adding device: {} for organisation {}.", e.getMessage(), request.getDevice().getDeviceIdentification(), organisationIdentification, e);
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
} catch (final Exception e) {
log.error("Exception: {} while adding device: {} for organisation {}.", e.getMessage(), request.getDevice().getDeviceIdentification(), organisationIdentification, e);
this.handleException(e);
}
return this.installationMapper.map(asyncResponse, AddDeviceAsyncResponse.class);
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AsyncResponse in project open-smart-grid-platform by OSGP.
the class SmartMeteringInstallationEndpoint method coupleMbusDeviceByChannel.
/**
* @param organisationIdentification the organization requesting the coupling of devices
* @param request the CoupleMbusDeviceByChannelRequest containing the gatewayDeviceIdentification
* and channel
* @param messagePriority the priority of the message
* @param scheduleTime the time the request is scheduled for
* @return a response containing a correlationUid and the deviceIdentification
* @throws OsgpException
*/
@PayloadRoot(localPart = "CoupleMbusDeviceByChannelRequest", namespace = SMARTMETER_INSTALLATION_NAMESPACE)
@ResponsePayload
public CoupleMbusDeviceByChannelAsyncResponse coupleMbusDeviceByChannel(@OrganisationIdentification final String organisationIdentification, @RequestPayload final CoupleMbusDeviceByChannelRequest request, @MessagePriority final String messagePriority, @ScheduleTime final String scheduleTime, @ResponseUrl final String responseUrl, @BypassRetry final String bypassRetry) throws OsgpException {
final CoupleMbusDeviceByChannelRequestData requestData = new CoupleMbusDeviceByChannelRequestData(request.getCoupleMbusDeviceByChannelRequestData().getChannel());
final RequestMessageMetadata requestMessageMetadata = RequestMessageMetadata.newBuilder().withOrganisationIdentification(organisationIdentification).withDeviceIdentification(request.getDeviceIdentification()).withDeviceFunction(DeviceFunction.COUPLE_MBUS_DEVICE_BY_CHANNEL).withMessageType(MessageType.COUPLE_MBUS_DEVICE_BY_CHANNEL).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).withBypassRetry(bypassRetry).build();
final AsyncResponse asyncResponse = this.requestService.enqueueAndSendRequest(requestMessageMetadata, requestData);
this.saveResponseUrlIfNeeded(asyncResponse.getCorrelationUid(), responseUrl);
return this.installationMapper.map(asyncResponse, CoupleMbusDeviceByChannelAsyncResponse.class);
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AsyncResponse in project open-smart-grid-platform by OSGP.
the class SmartMeteringInstallationEndpoint method coupleMbusDevice.
/**
* @param organisationIdentification the organisation requesting the coupling of devices
* @param request the CoupleMbusDeviceRequest containing the deviceIdentification,
* mbusDeviceIdentification and channel
* @param messagePriority the priority of the message
* @param scheduleTime the time the request is scheduled for
* @return a response containing a correlationUid and the deviceIdentification
* @throws OsgpException
*/
@PayloadRoot(localPart = "CoupleMbusDeviceRequest", namespace = SMARTMETER_INSTALLATION_NAMESPACE)
@ResponsePayload
public CoupleMbusDeviceAsyncResponse coupleMbusDevice(@OrganisationIdentification final String organisationIdentification, @RequestPayload final CoupleMbusDeviceRequest request, @MessagePriority final String messagePriority, @ScheduleTime final String scheduleTime, @ResponseUrl final String responseUrl, @BypassRetry final String bypassRetry) throws OsgpException {
final CoupleMbusDeviceRequestData requestData = new CoupleMbusDeviceRequestData(request.getMbusDeviceIdentification());
final RequestMessageMetadata requestMessageMetadata = RequestMessageMetadata.newBuilder().withOrganisationIdentification(organisationIdentification).withDeviceIdentification(request.getDeviceIdentification()).withDeviceFunction(DeviceFunction.COUPLE_MBUS_DEVICE).withMessageType(MessageType.COUPLE_MBUS_DEVICE).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).withBypassRetry(bypassRetry).build();
final AsyncResponse asyncResponse = this.requestService.enqueueAndSendRequest(requestMessageMetadata, requestData);
this.saveResponseUrlIfNeeded(asyncResponse.getCorrelationUid(), responseUrl);
return this.installationMapper.map(asyncResponse, CoupleMbusDeviceAsyncResponse.class);
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AsyncResponse in project open-smart-grid-platform by OSGP.
the class SmartMeteringInstallationEndpoint method decoupleMbusDevice.
/**
* @param organisationIdentification the organisation requesting the coupling of devices
* @param request the DecoupleMbusDeviceRequest containing the deviceIdentification,
* mbusDeviceIdentification and channel
* @param messagePriority the priority of the message
* @param scheduleTime the time the request is scheduled for
* @return a response containing a correlationUid and the deviceIdentification
* @throws OsgpException
*/
@PayloadRoot(localPart = "DecoupleMbusDeviceRequest", namespace = SMARTMETER_INSTALLATION_NAMESPACE)
@ResponsePayload
public DecoupleMbusDeviceAsyncResponse decoupleMbusDevice(@OrganisationIdentification final String organisationIdentification, @RequestPayload final DecoupleMbusDeviceRequest request, @MessagePriority final String messagePriority, @ScheduleTime final String scheduleTime, @ResponseUrl final String responseUrl, @BypassRetry final String bypassRetry) throws OsgpException {
final DecoupleMbusDeviceRequestData requestData = new DecoupleMbusDeviceRequestData(request.getMbusDeviceIdentification());
final RequestMessageMetadata requestMessageMetadata = RequestMessageMetadata.newBuilder().withOrganisationIdentification(organisationIdentification).withDeviceIdentification(request.getDeviceIdentification()).withDeviceFunction(DeviceFunction.DECOUPLE_MBUS_DEVICE).withMessageType(MessageType.DECOUPLE_MBUS_DEVICE).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).withBypassRetry(bypassRetry).build();
final AsyncResponse asyncResponse = this.requestService.enqueueAndSendRequest(requestMessageMetadata, requestData);
this.saveResponseUrlIfNeeded(asyncResponse.getCorrelationUid(), responseUrl);
return this.installationMapper.map(asyncResponse, DecoupleMbusDeviceAsyncResponse.class);
}
use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.common.AsyncResponse in project open-smart-grid-platform by OSGP.
the class SmartMeteringMonitoringEndpoint method clearAlarmRegister.
@PayloadRoot(localPart = "ClearAlarmRegisterRequest", namespace = SMARTMETER_MONITORING_NAMESPACE)
@ResponsePayload
public ClearAlarmRegisterAsyncResponse clearAlarmRegister(@OrganisationIdentification final String organisationIdentification, @RequestPayload final ClearAlarmRegisterRequest request, @MessagePriority final String messagePriority, @ScheduleTime final String scheduleTime, @ResponseUrl final String responseUrl, @BypassRetry final String bypassRetry) throws OsgpException {
final org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClearAlarmRegisterRequest requestData = this.monitoringMapper.map(request, org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ClearAlarmRegisterRequest.class);
final RequestMessageMetadata requestMessageMetadata = RequestMessageMetadata.newBuilder().withOrganisationIdentification(organisationIdentification).withDeviceIdentification(request.getDeviceIdentification()).withDeviceFunction(DeviceFunction.CLEAR_ALARM_REGISTER).withMessageType(MessageType.CLEAR_ALARM_REGISTER).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).withBypassRetry(bypassRetry).build();
final AsyncResponse asyncResponse = this.requestService.enqueueAndSendRequest(requestMessageMetadata, requestData);
this.saveResponseUrlIfNeeded(asyncResponse.getCorrelationUid(), responseUrl);
return this.monitoringMapper.map(asyncResponse, ClearAlarmRegisterAsyncResponse.class);
}
Aggregations