List of usage examples for org.joda.time DateTimeZone UTC
DateTimeZone UTC
To view the source code for org.joda.time DateTimeZone UTC.
Click Source Link
From source file:com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850TotalEnergyCommand.java
License:Open Source License
@Override public MeasurementDto translate(final NodeContainer containingNode) { return new MeasurementDto(1, DataAttribute.TOTAL_ENERGY.getDescription(), QualityConverter.toShort(containingNode.getQuality(SubDataAttribute.QUALITY).getValue()), new DateTime(containingNode.getDate(SubDataAttribute.TIME), DateTimeZone.UTC), containingNode.getChild(SubDataAttribute.MAGNITUDE).getFloat(SubDataAttribute.FLOAT).getFloat()); }
From source file:com.alliander.osgp.adapter.protocol.oslp.elster.infra.networking.OslpDeviceService.java
License:Open Source License
private void buildOslpRequestGetPowerUsageHistory(final GetPowerUsageHistoryDeviceRequest deviceRequest, final Pager pager, final List<PowerUsageDataDto> powerUsageHistoryData) { final Oslp.HistoryTermType oslpHistoryTermType = this.mapper.map( deviceRequest.getPowerUsageHistoryContainer().getHistoryTermType(), Oslp.HistoryTermType.class); final Oslp.TimePeriod.Builder oslpTimePeriodBuilder = Oslp.TimePeriod.newBuilder(); final String startTime = deviceRequest.getPowerUsageHistoryContainer().getTimePeriod().getStartTime() .toDateTime(DateTimeZone.UTC).toString(DATETIME_FORMAT); final String endTime = deviceRequest.getPowerUsageHistoryContainer().getTimePeriod().getEndTime() .toDateTime(DateTimeZone.UTC).toString(DATETIME_FORMAT); final Oslp.GetPowerUsageHistoryRequest getPowerUsageHistoryRequest = Oslp.GetPowerUsageHistoryRequest .newBuilder().setTimePeriod(oslpTimePeriodBuilder.setStartTime(startTime).setEndTime(endTime)) .setTermType(oslpHistoryTermType).setPage(pager.getCurrentPage()).build(); final PowerUsageHistoryResponseMessageDataContainerDto powerUsageHistoryResponseMessageDataContainer = new PowerUsageHistoryResponseMessageDataContainerDto( powerUsageHistoryData);// w w w.java 2 s.co m final PageInfoDto pageInfo = new PageInfoDto(pager.getCurrentPage(), pager.getPageSize(), pager.getNumberOfPages()); powerUsageHistoryResponseMessageDataContainer.setPageInfo(pageInfo); powerUsageHistoryResponseMessageDataContainer .setStartTime(deviceRequest.getPowerUsageHistoryContainer().getTimePeriod().getStartTime()); powerUsageHistoryResponseMessageDataContainer .setEndTime(deviceRequest.getPowerUsageHistoryContainer().getTimePeriod().getEndTime()); powerUsageHistoryResponseMessageDataContainer .setHistoryTermType(deviceRequest.getPowerUsageHistoryContainer().getHistoryTermType()); powerUsageHistoryResponseMessageDataContainer .setRequestContainer(deviceRequest.getPowerUsageHistoryContainer()); this.buildAndSignEnvelope(deviceRequest, Oslp.Message.newBuilder().setGetPowerUsageHistoryRequest(getPowerUsageHistoryRequest).build(), powerUsageHistoryResponseMessageDataContainer); }
From source file:com.alliander.osgp.adapter.ws.core.endpoints.ConfigurationManagementEndpoint.java
License:Open Source License
@PayloadRoot(localPart = "SetConfigurationRequest", namespace = NAMESPACE) @ResponsePayload//from www . j a v a 2s .c o m public SetConfigurationAsyncResponse setConfiguration( @OrganisationIdentification final String organisationIdentification, @RequestPayload final SetConfigurationRequest request) throws OsgpException { LOGGER.info("Set Configuration Request received from organisation: {} for device: {}.", organisationIdentification, request.getDeviceIdentification(), request.getScheduledTime()); final SetConfigurationAsyncResponse response = new SetConfigurationAsyncResponse(); try { // Get the request parameters, make sure that they are in UTC. // Maybe add an adapter to the service, so that all datetime are // converted to utc automatically. final DateTime scheduleTime = request.getScheduledTime() == null ? null : new DateTime(request.getScheduledTime().toGregorianCalendar()).toDateTime(DateTimeZone.UTC); final Configuration configuration = this.configurationManagementMapper.map(request.getConfiguration(), Configuration.class); if (request.getConfiguration() != null && request.getConfiguration().isIsAutomaticSummerTimingEnabled() != null) { configuration.setAutomaticSummerTimingEnabled( request.getConfiguration().isIsAutomaticSummerTimingEnabled()); } if (request.getConfiguration() != null && request.getConfiguration().isIsDhcpEnabled() != null) { configuration.setDhcpEnabled(request.getConfiguration().isIsDhcpEnabled()); } if (request.getConfiguration() != null && request.getConfiguration().isIsTestButtonEnabled() != null) { configuration.setTestButtonEnabled(request.getConfiguration().isIsTestButtonEnabled()); } final String correlationUid = this.configurationManagementService.enqueueSetConfigurationRequest( organisationIdentification, request.getDeviceIdentification(), configuration, scheduleTime); final AsyncResponse asyncResponse = new AsyncResponse(); asyncResponse.setCorrelationUid(correlationUid); asyncResponse.setDeviceId(request.getDeviceIdentification()); response.setAsyncResponse(asyncResponse); } catch (final MethodConstraintViolationException e) { LOGGER.error("Exception: {}, StackTrace: {}", e.getMessage(), e.getStackTrace(), e); throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations())); } catch (final Exception e) { this.handleException(e); } return response; }
From source file:com.alliander.osgp.adapter.ws.core.endpoints.DeviceManagementEndpoint.java
License:Open Source License
@PayloadRoot(localPart = "FindEventsRequest", namespace = DEVICE_MANAGEMENT_NAMESPACE) @ResponsePayload/*from w w w .jav a 2 s . c om*/ public FindEventsResponse findEventsRequest(@OrganisationIdentification final String organisationIdentification, @RequestPayload final FindEventsRequest request) throws OsgpException { LOGGER.info("Find events response for organisation: {} and device: {}.", organisationIdentification, request.getDeviceIdentification()); // Create response. final FindEventsResponse response = new FindEventsResponse(); try { // Get the request parameters, make sure that they are in UTC. // Maybe add an adapter to the service, so that all datetime are // converted to utc automatically. final DateTime from = request.getFrom() == null ? null : new DateTime(request.getFrom().toGregorianCalendar()).toDateTime(DateTimeZone.UTC); final DateTime until = request.getUntil() == null ? null : new DateTime(request.getUntil().toGregorianCalendar()).toDateTime(DateTimeZone.UTC); // Get all events matching the request. final Page<com.alliander.osgp.domain.core.entities.Event> result = this.deviceManagementService .findEvents(organisationIdentification, request.getDeviceIdentification(), request.getPageSize(), request.getPage(), from, until, this.deviceManagementMapper.mapAsList(request.getEventTypes(), EventType.class)); response.getEvents().addAll(this.deviceManagementMapper.mapAsList(result.getContent(), Event.class)); response.setPage(new com.alliander.osgp.adapter.ws.schema.core.common.Page()); response.getPage().setPageSize(result.getSize()); response.getPage().setTotalPages(result.getTotalPages()); response.getPage().setCurrentPage(result.getNumber()); } catch (final MethodConstraintViolationException e) { LOGGER.error(EXCEPTION, e.getMessage(), e.getStackTrace(), e); throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations())); } catch (final Exception e) { this.handleException(e); } return response; }
From source file:com.alliander.osgp.adapter.ws.core.endpoints.FirmwareManagementEndpoint.java
License:Open Source License
@PayloadRoot(localPart = "UpdateFirmwareRequest", namespace = NAMESPACE) @ResponsePayload//from w ww .jav a 2 s . c o m public UpdateFirmwareAsyncResponse updateFirmware( @OrganisationIdentification final String organisationIdentification, @RequestPayload final UpdateFirmwareRequest request) throws OsgpException { LOGGER.info("UpdateFirmware Request received from organisation {} for device {} with firmware name {}.", organisationIdentification, request.getDeviceIdentification(), request.getFirmwareIdentification(), request.getScheduledTime()); final UpdateFirmwareAsyncResponse response = new UpdateFirmwareAsyncResponse(); try { // Get the request parameters, make sure that they are in UTC. // Maybe add an adapter to the service, so that all datetime are // converted to utc automatically. final DateTime scheduleTime = request.getScheduledTime() == null ? null : new DateTime(request.getScheduledTime().toGregorianCalendar()).toDateTime(DateTimeZone.UTC); final String correlationUid = this.firmwareManagementService.enqueueUpdateFirmwareRequest( organisationIdentification, request.getDeviceIdentification(), request.getFirmwareIdentification(), scheduleTime); final AsyncResponse asyncResponse = new AsyncResponse(); asyncResponse.setCorrelationUid(correlationUid); asyncResponse.setDeviceId(request.getDeviceIdentification()); response.setAsyncResponse(asyncResponse); } catch (final MethodConstraintViolationException e) { LOGGER.error("Exception: {}, StackTrace: {}", e.getMessage(), e.getStackTrace(), e); throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_CORE, new ValidationException(e.getConstraintViolations())); } catch (final Exception e) { this.handleException(e); } return response; }
From source file:com.alliander.osgp.adapter.ws.publiclighting.endpoints.DeviceMonitoringEndpoint.java
License:Open Source License
@PayloadRoot(localPart = "GetPowerUsageHistoryRequest", namespace = NAMESPACE) @ResponsePayload/* w w w. ja v a 2s. c o m*/ public GetPowerUsageHistoryAsyncResponse getPowerUsageHistory( @OrganisationIdentification final String organisationIdentification, @RequestPayload final GetPowerUsageHistoryRequest request) throws OsgpException { LOGGER.info("Get Power Usage History Request received from organisation: {} for device: {}.", organisationIdentification, request.getDeviceIdentification()); final GetPowerUsageHistoryAsyncResponse response = new GetPowerUsageHistoryAsyncResponse(); try { // Get the request parameters, make sure that they are in UTC. // Maybe add an adapter to the service, so that all datetime are // converted to utc automatically. final DateTime scheduleTime = request.getScheduledTime() == null ? null : new DateTime(request.getScheduledTime().toGregorianCalendar()).toDateTime(DateTimeZone.UTC); final PowerUsageHistoryMessageDataContainer powerUsageHistoryMessageDataContainer = new PowerUsageHistoryMessageDataContainer(); if (this.deviceMonitoringMapper == null) { this.deviceMonitoringMapper = new DeviceMonitoringMapper(); } powerUsageHistoryMessageDataContainer .setHistoryTermType(this.deviceMonitoringMapper.map(request.getHistoryTermType(), com.alliander.osgp.domain.core.valueobjects.HistoryTermType.class)); powerUsageHistoryMessageDataContainer.setTimePeriod(this.deviceMonitoringMapper .map(request.getTimePeriod(), com.alliander.osgp.domain.core.valueobjects.TimePeriod.class)); final String correlationUid = this.deviceMonitoringService.enqueueGetPowerUsageHistoryRequest( organisationIdentification, request.getDeviceIdentification(), powerUsageHistoryMessageDataContainer, scheduleTime); final AsyncResponse asyncResponse = new AsyncResponse(); asyncResponse.setCorrelationUid(correlationUid); asyncResponse.setDeviceId(request.getDeviceIdentification()); response.setAsyncResponse(asyncResponse); } catch (final MethodConstraintViolationException e) { LOGGER.error("Exception: {}, StackTrace: {}", e.getMessage(), e.getStackTrace(), e); throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_PUBLIC_LIGHTING, new ValidationException(e.getConstraintViolations())); } catch (final Exception e) { this.handleException(e); } return response; }
From source file:com.alliander.osgp.adapter.ws.publiclighting.endpoints.PublicLightingScheduleManagementEndpoint.java
License:Open Source License
@PayloadRoot(localPart = "SetScheduleRequest", namespace = NAMESPACE) @ResponsePayload/* w w w. ja va2s . co m*/ public SetScheduleAsyncResponse setLightSchedule( @OrganisationIdentification final String organisationIdentification, @RequestPayload final SetScheduleRequest request) throws OsgpException { LOGGER.info("Set Schedule Request received from organisation: {} for device: {}.", organisationIdentification, request.getDeviceIdentification()); final SetScheduleAsyncResponse response = new SetScheduleAsyncResponse(); try { // Get the request parameters, make sure that they are in UTC. // Maybe add an adapter to the service, so that all datetime are // converted to utc automatically. final DateTime scheduleTime = request.getScheduledTime() == null ? null : new DateTime(request.getScheduledTime().toGregorianCalendar()).toDateTime(DateTimeZone.UTC); final String correlationUid = this.scheduleManagementService.enqueueSetLightSchedule( organisationIdentification, request.getDeviceIdentification(), this.scheduleManagementMapper.mapAsList(request.getSchedules(), com.alliander.osgp.domain.core.valueobjects.Schedule.class), scheduleTime); final AsyncResponse asyncResponse = new AsyncResponse(); asyncResponse.setCorrelationUid(correlationUid); asyncResponse.setDeviceId(request.getDeviceIdentification()); response.setAsyncResponse(asyncResponse); } catch (final MethodConstraintViolationException e) { LOGGER.error("Exception: {}, StackTrace: {}", e.getMessage(), e.getStackTrace(), e); throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_PUBLIC_LIGHTING, new ValidationException(e.getConstraintViolations())); } catch (final Exception e) { this.handleException(e); } return response; }
From source file:com.alliander.osgp.adapter.ws.tariffswitching.endpoints.TariffSwitchingScheduleManagementEndpoint.java
License:Open Source License
@PayloadRoot(localPart = "SetScheduleRequest", namespace = NAMESPACE) @ResponsePayload// w ww. ja v a 2 s . co m public SetScheduleAsyncResponse setSchedule(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetScheduleRequest request) throws OsgpException { LOGGER.info("Set Tariff Schedule Request received from organisation: {} for device: {}.", organisationIdentification, request.getDeviceIdentification()); // Get the request parameters, make sure that they are in UTC. // Maybe add an adapter to the service, so that all datetime are // converted to utc automatically. final DateTime scheduleTime = request.getScheduledTime() == null ? null : new DateTime(request.getScheduledTime().toGregorianCalendar()).toDateTime(DateTimeZone.UTC); final SetScheduleAsyncResponse response = new SetScheduleAsyncResponse(); try { final String correlationUid = this.scheduleManagementService.enqueueSetTariffSchedule( organisationIdentification, request.getDeviceIdentification(), this.scheduleManagementMapper.mapAsList(request.getSchedules(), com.alliander.osgp.domain.core.valueobjects.Schedule.class), scheduleTime); final AsyncResponse asyncResponse = new AsyncResponse(); asyncResponse.setCorrelationUid(correlationUid); asyncResponse.setDeviceId(request.getDeviceIdentification()); response.setAsyncResponse(asyncResponse); } catch (final MethodConstraintViolationException e) { LOGGER.error("Exception: {}, StackTrace: {}", e.getMessage(), e.getStackTrace(), e); throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_TARIFF_SWITCHING, new ValidationException(e.getConstraintViolations())); } catch (final Exception e) { this.handleException(e); } return response; }
From source file:com.alliander.osgp.domain.core.validation.joda.FutureValidator.java
License:Open Source License
@Override public boolean isValid(final ReadableInstant value, final ConstraintValidatorContext context) { if (value == null) { return true; }/*from w ww . ja v a 2 s. co m*/ final DateTime checkDate = new DateMidnight(DateTimeZone.UTC).toDateTime(); return value.isEqual(checkDate) || value.isAfter(checkDate); }
From source file:com.alliander.osgp.domain.core.validation.joda.PastValidator.java
License:Open Source License
@Override public boolean isValid(final ReadableInstant value, final ConstraintValidatorContext context) { if (value == null) { return true; }/*w ww .j a va 2 s.co m*/ final DateMidnight checkDate = new DateMidnight(DateTimeZone.UTC); return value.isEqual(checkDate) || value.isBefore(checkDate); }