use of org.opensmartgridplatform.dto.valueobjects.smartmetering.OutageDto in project open-smart-grid-platform by OSGP.
the class DataObjectToOutageListConverter method convert.
public List<OutageDto> convert(final DataObject source) throws ProtocolAdapterException {
final List<OutageDto> eventList = new ArrayList<>();
if (source == null) {
throw new ProtocolAdapterException("DataObject should not be null");
}
final List<DataObject> dataObjects = source.getValue();
for (final DataObject dataObject : dataObjects) {
eventList.add(this.getOutageDto(dataObject));
}
return eventList;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.OutageDto in project open-smart-grid-platform by OSGP.
the class DataObjectToOutageListConverter method getOutageDto.
private OutageDto getOutageDto(final DataObject outageDataObject) throws ProtocolAdapterException {
final List<DataObject> outageData = outageDataObject.getValue();
if (outageData == null) {
throw new ProtocolAdapterException("outageData DataObject should not be null");
}
if (outageData.size() != NUMBER_OF_ELEMENTS) {
throw new ProtocolAdapterException("outageData size should be " + NUMBER_OF_ELEMENTS);
}
final DateTime endTime = this.extractDateTime(outageData);
final Long duration = this.extractEventDuration(outageData);
final OutageDto outage = new OutageDto(endTime, duration);
log.info("Converted dataObject to outage: {}", outage);
return outage;
}
Aggregations