use of org.opensmartgridplatform.domain.core.valueobjects.RtuDevice in project open-smart-grid-platform by OSGP.
the class RtuDeviceService method storeRtuDevice.
public void storeRtuDevice(final String organisationIdentification, final AddRtuDeviceRequest addRtuDeviceRequest) throws FunctionalException {
this.throwExceptionOnExistingDevice(addRtuDeviceRequest);
final RtuDevice rtuDevice = addRtuDeviceRequest.getRtuDevice();
org.opensmartgridplatform.domain.core.entities.RtuDevice rtuDeviceEntity = new org.opensmartgridplatform.domain.core.entities.RtuDevice(rtuDevice.getDeviceIdentification());
rtuDeviceEntity.setDomainInfo(this.domainInfoRepository.findByDomainAndDomainVersion("DISTRIBUTION_AUTOMATION", "1.0"));
this.addProtocolInfo(rtuDevice, rtuDeviceEntity);
this.addRegistrationData(rtuDevice, rtuDeviceEntity);
this.addDeviceModel(addRtuDeviceRequest.getDeviceModel(), rtuDeviceEntity);
rtuDeviceEntity = this.rtuDeviceRepository.save(rtuDeviceEntity);
this.storeAuthorization(organisationIdentification, rtuDeviceEntity);
}
use of org.opensmartgridplatform.domain.core.valueobjects.RtuDevice in project open-smart-grid-platform by OSGP.
the class DeviceManagementEndpoint method addRtuDevice.
@PayloadRoot(localPart = "AddRtuDeviceRequest", namespace = NAMESPACE)
@ResponsePayload
public AddRtuDeviceAsyncResponse addRtuDevice(@OrganisationIdentification final String organisationIdentification, @RequestPayload final AddRtuDeviceRequest request) throws OsgpException {
LOGGER.info("Incoming AddRtuDeviceRequest for device: {}.", request.getRtuDevice().getDeviceIdentification());
AddRtuDeviceAsyncResponse response = null;
try {
response = new AddRtuDeviceAsyncResponse();
final RtuDevice rtuDevice = this.mapper.map(request.getRtuDevice(), RtuDevice.class);
final DeviceModel deviceModel = new DeviceModel(request.getDeviceModel().getManufacturer(), request.getDeviceModel().getModelCode(), "");
final String correlationUid = this.service.enqueueAddRtuDeviceRequest(organisationIdentification, rtuDevice.getDeviceIdentification(), new org.opensmartgridplatform.domain.core.valueobjects.AddRtuDeviceRequest(rtuDevice, deviceModel));
response.setCorrelationUid(correlationUid);
response.setDeviceId(request.getRtuDevice().getDeviceIdentification());
} catch (final Exception e) {
this.handleException(LOGGER, e);
}
return response;
}
Aggregations