use of org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Device in project open-smart-grid-platform by OSGP.
the class DeviceConverterHelper method initJaxb.
Device initJaxb(final T source) {
final org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Device destination = new org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Device();
destination.setAlias(source.getAlias());
destination.setActivated(source.isActivated());
destination.setDeviceLifecycleStatus(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.DeviceLifecycleStatus.valueOf(source.getDeviceLifecycleStatus().name()));
destination.setContainerAddress(this.mapper.map(source.getContainerAddress(), org.opensmartgridplatform.adapter.ws.schema.core.common.Address.class));
destination.setDeviceIdentification(source.getDeviceIdentification());
destination.setDeviceType(source.getDeviceType());
destination.setTechnicalInstallationDate(this.mapper.map(source.getTechnicalInstallationDate(), XMLGregorianCalendar.class));
if (!Objects.isNull(source.getGpsCoordinates())) {
final GpsCoordinates gpsCoordinates = source.getGpsCoordinates();
if (gpsCoordinates.getLatitude() != null) {
destination.setGpsLatitude(Float.toString(gpsCoordinates.getLatitude()));
}
if (gpsCoordinates.getLongitude() != null) {
destination.setGpsLongitude(Float.toString(gpsCoordinates.getLongitude()));
}
}
destination.setNetworkAddress(source.getNetworkAddress() == null ? null : source.getNetworkAddress().toString());
destination.setOwner(source.getOwner() == null ? "" : source.getOwner().getName());
destination.getOrganisations().addAll(source.getOrganisations());
destination.setInMaintenance(source.isInMaintenance());
final List<org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.DeviceAuthorization> deviceAuthorizations = new ArrayList<>();
for (final DeviceAuthorization deviceAuthorisation : source.getAuthorizations()) {
final org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.DeviceAuthorization newDeviceAuthorization = new org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.DeviceAuthorization();
newDeviceAuthorization.setFunctionGroup(deviceAuthorisation.getFunctionGroup().name());
newDeviceAuthorization.setOrganisation(deviceAuthorisation.getOrganisation().getOrganisationIdentification());
deviceAuthorizations.add(newDeviceAuthorization);
}
destination.getDeviceAuthorizations().addAll(deviceAuthorizations);
if (source.getDeviceModel() != null) {
final DeviceModel deviceModel = new DeviceModel();
deviceModel.setDescription(source.getDeviceModel().getDescription());
if (source.getDeviceModel().getManufacturer() != null) {
final Manufacturer manufacturer = new Manufacturer();
manufacturer.setManufacturerId(source.getDeviceModel().getManufacturer().getCode());
manufacturer.setName(source.getDeviceModel().getManufacturer().getName());
manufacturer.setUsePrefix(source.getDeviceModel().getManufacturer().isUsePrefix());
deviceModel.setManufacturer(manufacturer);
}
deviceModel.setModelCode(source.getDeviceModel().getModelCode());
destination.setDeviceModel(deviceModel);
}
destination.setLastCommunicationTime(this.mapper.map(source.getLastSuccessfulConnectionTimestamp(), XMLGregorianCalendar.class));
if (source instanceof LightMeasurementDevice) {
final LightMeasurementDevice sourceLmd = (LightMeasurementDevice) source;
final org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.LightMeasurementDevice destinationLmd = new org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.LightMeasurementDevice();
destinationLmd.setDescription(sourceLmd.getDescription());
destinationLmd.setCode(sourceLmd.getCode());
destinationLmd.setColor(sourceLmd.getColor());
destinationLmd.setDigitalInput(sourceLmd.getDigitalInput());
destinationLmd.setLastCommunicationTime(this.mapper.map(sourceLmd.getLastCommunicationTime(), XMLGregorianCalendar.class));
destination.setLightMeasurementDevice(destinationLmd);
}
return destination;
}
Aggregations