Search in sources :

Example 1 with RtuDevice

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);
}
Also used : RtuDevice(org.opensmartgridplatform.domain.core.valueobjects.RtuDevice)

Example 2 with RtuDevice

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;
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.valueobjects.DeviceModel) AddRtuDeviceAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.AddRtuDeviceAsyncResponse) RtuDevice(org.opensmartgridplatform.domain.core.valueobjects.RtuDevice) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ResponseNotFoundException(org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

RtuDevice (org.opensmartgridplatform.domain.core.valueobjects.RtuDevice)2 ResponseNotFoundException (org.opensmartgridplatform.adapter.ws.da.application.exceptionhandling.ResponseNotFoundException)1 AddRtuDeviceAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.distributionautomation.generic.AddRtuDeviceAsyncResponse)1 DeviceModel (org.opensmartgridplatform.domain.core.valueobjects.DeviceModel)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1