Search in sources :

Example 1 with ScheduledTaskWithoutData

use of org.opensmartgridplatform.domain.core.entities.ScheduledTaskWithoutData in project open-smart-grid-platform by OSGP.

the class DeviceManagementEndpoint method findScheduledTasks.

@PayloadRoot(localPart = "FindScheduledTasksRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE)
@ResponsePayload
public FindScheduledTasksResponse findScheduledTasks(@OrganisationIdentification final String organisationIdentification, @RequestPayload final FindScheduledTasksRequest request) throws OsgpException {
    LOGGER.info("Finding scheduled tasks for organisation: {}.", organisationIdentification);
    final FindScheduledTasksResponse response = new FindScheduledTasksResponse();
    try {
        final List<ScheduledTaskWithoutData> scheduledTasks;
        if (request.getDeviceIdentification() == null) {
            scheduledTasks = this.deviceManagementService.findScheduledTasks(organisationIdentification);
        } else {
            scheduledTasks = this.deviceManagementService.findScheduledTasks(organisationIdentification, request.getDeviceIdentification());
        }
        response.getScheduledTask().addAll(this.deviceManagementMapper.mapAsList(scheduledTasks, org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.ScheduledTask.class));
    } catch (final ConstraintViolationException e) {
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations()));
    } catch (final Exception e) {
        this.handleException(e);
    }
    return response;
}
Also used : FindScheduledTasksResponse(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindScheduledTasksResponse) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) ScheduledTaskWithoutData(org.opensmartgridplatform.domain.core.entities.ScheduledTaskWithoutData) ConstraintViolationException(javax.validation.ConstraintViolationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

ConstraintViolationException (javax.validation.ConstraintViolationException)1 FindScheduledTasksResponse (org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.FindScheduledTasksResponse)1 ScheduledTaskWithoutData (org.opensmartgridplatform.domain.core.entities.ScheduledTaskWithoutData)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)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