use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.
the class AddDeviceSteps method aRequestToTheDeviceCanBePerformedAfterActivation.
@Then("^a request to the device can be performed after activation$")
public void aRequestToTheDeviceCanBePerformedAfterActivation() throws Throwable {
final Device device = this.activateDevice();
/*
* Fire any request that causes communication to the device, and check
* that the actual response is not an error.
*/
final GetAdministrativeStatusRequest request = new GetAdministrativeStatusRequest();
request.setDeviceIdentification(device.getDeviceIdentification());
final GetAdministrativeStatusAsyncResponse getAdministrativeStatusAsyncResponse = this.smartMeteringConfigurationClient.getAdministrativeStatus(request);
final GetAdministrativeStatusAsyncRequest asyncRequest = new GetAdministrativeStatusAsyncRequest();
asyncRequest.setCorrelationUid(getAdministrativeStatusAsyncResponse.getCorrelationUid());
asyncRequest.setDeviceIdentification(device.getDeviceIdentification());
final GetAdministrativeStatusResponse getAdministrativeStatusResponse = this.smartMeteringConfigurationClient.retrieveGetAdministrativeStatusResponse(asyncRequest);
assertThat(getAdministrativeStatusResponse.getEnabled()).as("Administrative status should contain information if it is enabled").isNotNull();
}
use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.
the class AdHocManagementService method enqueueSetLightRequest.
public String enqueueSetLightRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @Size(min = 1, max = 6) @Valid final List<LightValue> lightValues, final int messagePriority) throws FunctionalException {
final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
this.domainHelperService.isAllowed(organisation, device, DeviceFunction.SET_LIGHT);
this.domainHelperService.isInMaintenance(device);
LOGGER.debug("enqueueSetLightRequest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
final LightValueMessageDataContainer lightValueMessageDataContainer = new LightValueMessageDataContainer(lightValues);
final MessageMetadata deviceMessageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.SET_LIGHT.name()).withMessagePriority(messagePriority).build();
final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(lightValueMessageDataContainer).build();
this.messageSender.send(message);
return correlationUid;
}
use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.
the class AdHocManagementService method enqueueResumeScheduleRequest.
public String enqueueResumeScheduleRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @Valid final ResumeScheduleData resumeScheduleData, final int messagePriority) throws FunctionalException {
final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
this.domainHelperService.isAllowed(organisation, device, DeviceFunction.RESUME_SCHEDULE);
this.domainHelperService.isInMaintenance(device);
LOGGER.debug("enqueueResumeScheduleRequest called with organisation {}, device {} and resumeScheduleData {} ", organisationIdentification, deviceIdentification, resumeScheduleData);
final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
final MessageMetadata deviceMessageMetadata = new Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.RESUME_SCHEDULE.name()).withMessagePriority(messagePriority).build();
final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(resumeScheduleData).build();
this.messageSender.send(message);
return correlationUid;
}
use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.
the class DeviceManagementService method setDeviceVerificationKey.
@Transactional(value = "transactionManager")
public void setDeviceVerificationKey(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final String verificationKey, final String messageType, final int messagePriority) throws FunctionalException {
LOGGER.debug("SetDeviceVerificationKey called with organisation {} and device {}", organisationIdentification, deviceIdentification);
this.findOrganisation(organisationIdentification);
final Device device = this.findActiveDevice(deviceIdentification);
if (verificationKey == null) {
LOGGER.info("Verification key is empty, skip sending a request to device");
return;
}
this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, verificationKey), messageType, messagePriority, device.getIpAddress());
}
use of org.opensmartgridplatform.domain.core.entities.Device in project open-smart-grid-platform by OSGP.
the class DeviceManagementService method setEventNotifications.
@Transactional(value = "transactionManager")
public void setEventNotifications(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final List<EventNotificationType> eventNotifications, final String messageType, final int messagePriority) throws FunctionalException {
LOGGER.debug("setEventNotifications called with organisation {} and device {}", organisationIdentification, deviceIdentification);
this.findOrganisation(organisationIdentification);
final Device device = this.findActiveDevice(deviceIdentification);
final List<org.opensmartgridplatform.dto.valueobjects.EventNotificationTypeDto> eventNotificationsDto = this.domainCoreMapper.mapAsList(eventNotifications, org.opensmartgridplatform.dto.valueobjects.EventNotificationTypeDto.class);
final EventNotificationMessageDataContainerDto eventNotificationMessageDataContainer = new EventNotificationMessageDataContainerDto(eventNotificationsDto);
this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, eventNotificationMessageDataContainer), messageType, messagePriority, device.getIpAddress());
}
Aggregations