use of com.alliander.osgp.dto.valueobjects.PageInfoDto in project Protocol-Adapter-OSLP by OSGP.
the class OslpDeviceService method doGetPowerUsageHistory.
@Override
public void doGetPowerUsageHistory(final OslpEnvelope oslpRequest, final PowerUsageHistoryResponseMessageDataContainerDto powerUsageHistoryResponseMessageDataContainer, final GetPowerUsageHistoryDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler, final String ipAddress, final String domain, final String domainVersion, final String messageType, final int retryCount, final boolean isScheduled) throws IOException {
LOGGER.info("doGetPowerUsageHistory() for device: {}.", deviceRequest.getDeviceIdentification());
this.saveOslpRequestLogEntry(deviceRequest, oslpRequest);
final List<PowerUsageDataDto> powerUsageHistoryData = powerUsageHistoryResponseMessageDataContainer.getPowerUsageData();
final PageInfoDto pageInfo = powerUsageHistoryResponseMessageDataContainer.getPageInfo();
final Pager pager = new Pager(pageInfo.getTotalPages(), pageInfo.getPageSize(), pageInfo.getCurrentPage());
final OslpResponseHandler oslpResponseHandler = new OslpResponseHandler() {
@Override
public void handleResponse(final OslpEnvelope oslpResponse) {
OslpDeviceService.this.handleOslpResponseGetPowerUsageHistory(deviceRequest, oslpResponse, pager, powerUsageHistoryData, deviceResponseHandler, ipAddress, domain, domainVersion, messageType, retryCount, isScheduled);
}
@Override
public void handleException(final Throwable t) {
OslpDeviceService.this.handleException(t, deviceRequest, deviceResponseHandler);
}
};
this.sendMessage(ipAddress, oslpRequest, oslpResponseHandler, deviceRequest);
}
use of com.alliander.osgp.dto.valueobjects.PageInfoDto in project Protocol-Adapter-OSLP by OSGP.
the class OslpDeviceService method buildOslpRequestGetPowerUsageHistory.
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);
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);
}
use of com.alliander.osgp.dto.valueobjects.PageInfoDto in project Protocol-Adapter-OSLP by OSGP.
the class OslpDeviceService method buildOslpRequestSetSchedulePaged.
private void buildOslpRequestSetSchedulePaged(final SetScheduleDeviceRequest deviceRequest, final Pager pager) {
final List<Oslp.Schedule> oslpSchedules = this.convertToOslpSchedules(deviceRequest.getScheduleMessageDataContainer().getScheduleList().subList(pager.getIndexFrom(), pager.getIndexTo()));
final Oslp.SetScheduleRequest.Builder oslpRequestBuilder = SetScheduleRequest.newBuilder().addAllSchedules(oslpSchedules).setScheduleType(this.mapper.map(deviceRequest.getRelayType(), com.alliander.osgp.oslp.Oslp.RelayType.class)).setPageInfo(Oslp.PageInfo.newBuilder().setCurrentPage(pager.getCurrentPage()).setPageSize(pager.getPageSize()).setTotalPages(pager.getNumberOfPages()));
final PageInfoDto pageInfo = new PageInfoDto(pager.getCurrentPage(), pager.getPageSize(), pager.getNumberOfPages());
final ScheduleMessageDataContainerDto scheduleMessageDataContainer = new ScheduleMessageDataContainerDto(deviceRequest.getScheduleMessageDataContainer().getScheduleList());
scheduleMessageDataContainer.setPageInfo(pageInfo);
this.buildAndSignEnvelope(deviceRequest, Oslp.Message.newBuilder().setSetScheduleRequest(oslpRequestBuilder.build()).build(), scheduleMessageDataContainer);
}
Aggregations