use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class DeviceManagementMapper method configure.
@Override
public void configure(final MapperFactory mapperFactory) {
mapperFactory.registerClassMap(mapperFactory.classMap(org.opensmartgridplatform.domain.core.entities.Device.class, org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Device.class).field("ipAddress", "networkAddress").byDefault().toClassMap());
mapperFactory.registerClassMap(mapperFactory.classMap(org.opensmartgridplatform.domain.core.entities.Event.class, org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Event.class).field("dateTime", "timestamp").byDefault().toClassMap());
mapperFactory.registerClassMap(mapperFactory.classMap(org.opensmartgridplatform.domain.core.entities.ScheduledTaskWithoutData.class, org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.ScheduledTask.class).byDefault().toClassMap());
mapperFactory.registerClassMap(mapperFactory.classMap(org.opensmartgridplatform.domain.core.entities.ScheduledTaskWithoutData.class, org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.ScheduledTask.class).byDefault().toClassMap());
final Mapper<org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdatedDevice, Ssld> updatedDeviceToSsldMapper = new UpdatedDeviceToSsldMapper();
mapperFactory.classMap(org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.UpdatedDevice.class, Ssld.class).exclude("outputSettings").exclude("gpsLatitude").exclude("gpsLongitude").byDefault().customize(updatedDeviceToSsldMapper).register();
mapperFactory.getConverterFactory().registerConverter(new XMLGregorianCalendarToDateTimeConverter());
mapperFactory.getConverterFactory().registerConverter(new XMLGregorianCalendarToInstantConverter());
mapperFactory.getConverterFactory().registerConverter(new EventTypeConverter());
mapperFactory.getConverterFactory().registerConverter(new SmartMeterConverter());
mapperFactory.getConverterFactory().registerConverter(new DeviceConverter());
mapperFactory.getConverterFactory().registerConverter(new RtuDeviceConverter());
mapperFactory.getConverterFactory().registerConverter(new LightMeasurementDeviceConverter());
mapperFactory.getConverterFactory().registerConverter(new SsldConverter(this.ssldRepository));
}
use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class SsldConverter method convertTo.
@Override
public org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Device convertTo(final Ssld source, final Type<org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Device> destinationType, final MappingContext context) {
if (source == null) {
return null;
}
final org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Device destination = this.helper.initJaxb(source);
final Ssld ssld = this.ssldRepository.findByDeviceIdentification(source.getDeviceIdentification());
if (ssld != null) {
final List<org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.DeviceOutputSetting> deviceOutputSettings = new ArrayList<>();
for (final DeviceOutputSetting deviceOutputSetting : ssld.getOutputSettings()) {
final org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.DeviceOutputSetting newDeviceOutputSetting = new org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.DeviceOutputSetting();
newDeviceOutputSetting.setExternalId(deviceOutputSetting.getExternalId());
newDeviceOutputSetting.setInternalId(deviceOutputSetting.getInternalId());
newDeviceOutputSetting.setRelayType(deviceOutputSetting.getOutputType() == null ? null : RelayType.valueOf(deviceOutputSetting.getOutputType().name()));
newDeviceOutputSetting.setAlias(deviceOutputSetting.getAlias());
deviceOutputSettings.add(newDeviceOutputSetting);
}
destination.getOutputSettings().addAll(deviceOutputSettings);
destination.setPublicKeyPresent(ssld.isPublicKeyPresent());
destination.setHasSchedule(ssld.getHasSchedule());
final List<org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Ean> eans = new ArrayList<>();
for (final org.opensmartgridplatform.domain.core.entities.Ean ean : ssld.getEans()) {
final org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Ean newEan = new org.opensmartgridplatform.adapter.ws.schema.core.devicemanagement.Ean();
newEan.setCode(ean.getCode());
newEan.setDescription(ean.getDescription());
eans.add(newEan);
}
destination.getEans().addAll(eans);
this.addRelayStatuses(destination, ssld);
}
return destination;
}
use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class WsInstallationDeviceToDeviceConverter method convertFrom.
@Override
public Device convertFrom(final org.opensmartgridplatform.domain.core.entities.Device source, final Type<Device> destinationType, final MappingContext context) {
Device destination = null;
if (source != null) {
destination = new Device();
destination.setDeviceIdentification(source.getDeviceIdentification());
destination.setAlias(source.getAlias());
destination.setContainerAddress(this.mapperFacade.map(source.getContainerAddress(), org.opensmartgridplatform.adapter.ws.schema.core.common.Address.class));
if (!Objects.isNull(source.getGpsCoordinates())) {
final GpsCoordinates gpsCoordinates = source.getGpsCoordinates();
destination.setGpsLatitude(gpsCoordinates.getLatitude());
destination.setGpsLongitude(gpsCoordinates.getLongitude());
}
destination.setActivated(source.isActivated());
final Optional<Ssld> ssld = this.ssldRepository.findById(source.getId());
if (ssld.isPresent()) {
destination.setHasSchedule(ssld.get().getHasSchedule());
}
return destination;
}
return null;
}
use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class DeviceConverterHelper method initEntity.
@SuppressWarnings("unchecked")
T initEntity(final Device source) {
T destination;
final Address containerAddress = this.mapper.map(source.getContainerAddress(), Address.class);
GpsCoordinates gpsCoordinates = null;
if (source.getGpsLatitude() != null && source.getGpsLongitude() != null) {
gpsCoordinates = new GpsCoordinates(Float.valueOf(source.getGpsLatitude()), Float.valueOf(source.getGpsLongitude()));
}
if (this.clazz.isAssignableFrom(SmartMeter.class)) {
destination = (T) new SmartMeter(source.getDeviceIdentification(), source.getAlias(), containerAddress, gpsCoordinates);
} else {
destination = (T) new Ssld(source.getDeviceIdentification(), source.getAlias(), containerAddress, gpsCoordinates, null);
}
if (source.isActivated() != null) {
destination.setActivated(source.isActivated());
}
if (source.getDeviceLifecycleStatus() != null) {
destination.setDeviceLifecycleStatus(DeviceLifecycleStatus.valueOf(source.getDeviceLifecycleStatus().name()));
}
destination.updateRegistrationData(destination.getNetworkAddress(), source.getDeviceType());
if (source.getTechnicalInstallationDate() != null) {
destination.setTechnicalInstallationDate(source.getTechnicalInstallationDate().toGregorianCalendar().getTime());
}
destination.setDeviceModel(this.mapper.map(source.getDeviceModel(), org.opensmartgridplatform.domain.core.entities.DeviceModel.class));
return destination;
}
use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class WsInstallationDeviceToSsldConverter method convert.
@Override
public Ssld convert(final Device source, final Type<? extends Ssld> destinationType, final MappingContext mappingContext) {
LOGGER.debug("Converting WS Installation Device into SSLD [{}]", source.getDeviceIdentification());
final String deviceIdentification = source.getDeviceIdentification();
final String alias = source.getAlias();
final Address containerAddress = this.mapperFacade.map(source.getContainerAddress(), Address.class);
final GpsCoordinates gpsCoordinates = new GpsCoordinates(source.getGpsLatitude(), source.getGpsLongitude());
final Ssld ssld = new Ssld(deviceIdentification, alias, containerAddress, gpsCoordinates, null);
ssld.setPublicKeyPresent(source.isPublicKeyPresent());
return ssld;
}
Aggregations