use of org.opensmartgridplatform.domain.core.valueobjects.Address in project open-smart-grid-platform by OSGP.
the class SmartMeterSteps method aSmartMeter.
/**
* Given a smart meter exists.
*/
@Given("^a smart meter$")
@Transactional("txMgrCore")
public Device aSmartMeter(final Map<String, String> settings) {
final String deviceIdentification = getString(settings, KEY_DEVICE_IDENTIFICATION, DEFAULT_DEVICE_IDENTIFICATION);
final SmartMeter smartMeter = new SmartMeter(deviceIdentification, getString(settings, KEY_ALIAS, DEFAULT_ALIAS), new Address(getString(settings, KEY_CONTAINER_CITY, DEFAULT_CONTAINER_CITY), getString(settings, KEY_CONTAINER_POSTALCODE, DEFAULT_CONTAINER_POSTALCODE), getString(settings, KEY_CONTAINER_STREET, DEFAULT_CONTAINER_STREET), getInteger(settings, KEY_CONTAINER_NUMBER, DEFAULT_CONTAINER_NUMBER), getString(settings, KEY_CONTAINER_NUMBER_ADDITION, DEFAULT_CONTAINER_NUMBER_ADDITION), getString(settings, KEY_CONTAINER_MUNICIPALITY, DEFAULT_CONTAINER_MUNICIPALITY)), new GpsCoordinates(getFloat(settings, KEY_GPS_LATITUDE, DEFAULT_LATITUDE), getFloat(settings, KEY_GPS_LONGITUDE, DEFAULT_LONGITUDE)));
smartMeter.setSupplier(getString(settings, KEY_SUPPLIER, DEFAULT_SUPPLIER));
if (settings.containsKey(KEY_GATEWAY_DEVICE_ID)) {
smartMeter.setChannel(getShort(settings, KEY_CHANNEL, DEFAULT_CHANNEL));
final Device smartEMeter = this.deviceRepository.findByDeviceIdentification(settings.get(KEY_GATEWAY_DEVICE_ID));
smartMeter.updateGatewayDevice(smartEMeter);
}
this.smartMeterRepository.save(smartMeter);
return this.updateDevice(deviceIdentification, settings);
}
use of org.opensmartgridplatform.domain.core.valueobjects.Address in project open-smart-grid-platform by OSGP.
the class DeviceBuilder method build.
@Override
public Device build() {
final Device device = new Device(this.deviceIdentification, this.alias, new Address(this.containerCity, this.containerPostalCode, this.containerStreet, this.containerNumber, this.containerNumberAddition, this.containerMunicipality), new GpsCoordinates(this.gpsLatitude, this.gpsLongitude), null);
device.updateProtocol(this.protocolInfo);
device.updateInMaintenance(this.inMaintenance);
if (this.gatewayDeviceIdentification != null) {
device.updateGatewayDevice(this.deviceRepository.findByDeviceIdentification(this.gatewayDeviceIdentification));
}
device.setVersion(this.version);
device.setDeviceModel(this.deviceModel);
device.setTechnicalInstallationDate(this.technicalInstallationDate);
// updateRegistrationData sets the status to IN_USE, so setting of any
// other status has to be done after that.
device.updateRegistrationData(this.networkAddress, this.deviceType);
device.setDeviceLifecycleStatus(this.deviceLifeCycleStatus);
return device;
}
use of org.opensmartgridplatform.domain.core.valueobjects.Address in project open-smart-grid-platform by OSGP.
the class SmartMeterBuilder method build.
@Override
public SmartMeter build() {
final SmartMeter device = new SmartMeter(this.deviceIdentification, this.alias, new Address(this.containerCity, this.containerPostalCode, this.containerStreet, this.containerNumber, this.containerNumberAddition, this.containerMunicipality), new GpsCoordinates(this.gpsLatitude, this.gpsLongitude));
device.setActivated(this.isActivated);
device.updateRegistrationData(this.networkAddress, this.deviceType);
device.setBtsId(this.baseTransceiverStationId);
device.setCellId(this.cellId);
// After updateRegistrationData because that sets deviceLifecyleStatus
// to IN_USE again.
device.setDeviceLifecycleStatus(this.deviceLifeCycleStatus);
device.updateProtocol(this.protocolInfo);
device.updateInMaintenance(this.inMaintenance);
device.setVersion(this.version);
device.setDeviceModel(this.deviceModel);
device.setTechnicalInstallationDate(this.technicalInstallationDate);
device.setSupplier(this.supplier);
device.setChannel(this.channel);
device.setMbusIdentificationNumber(this.mbusIdentificationNumber);
device.setMbusManufacturerIdentification(this.mbusManufacturerIdentification);
device.setMbusVersion(this.mbusVersion);
device.setMbusDeviceTypeIdentification(this.mbusDeviceTypeIdentification);
device.setMbusPrimaryAddress(this.mbusPrimaryAddress);
return device;
}
use of org.opensmartgridplatform.domain.core.valueobjects.Address in project open-smart-grid-platform by OSGP.
the class WsInstallationDeviceToDeviceConverter method convertTo.
@Override
public org.opensmartgridplatform.domain.core.entities.Device convertTo(final Device source, final Type<org.opensmartgridplatform.domain.core.entities.Device> destinationType, final MappingContext context) {
org.opensmartgridplatform.domain.core.entities.Device destination = null;
if (source != null) {
final Address address = this.mapperFacade.map(source.getContainerAddress(), Address.class);
destination = new org.opensmartgridplatform.domain.core.entities.Device(source.getDeviceIdentification(), source.getAlias(), address, new GpsCoordinates(source.getGpsLatitude(), source.getGpsLongitude()), null);
final DeviceModel deviceModel = this.writableDeviceModelRepository.findByManufacturerCodeAndModelCode(source.getDeviceModel().getManufacturer(), source.getDeviceModel().getModelCode());
if (deviceModel == null) {
throw new AssertionError("Model code \"" + source.getDeviceModel().getModelCode() + "\" and Manufacturer \"" + source.getDeviceModel().getManufacturer() + "\" do not identify an existing device model.");
} else {
destination.setDeviceModel(deviceModel);
}
return destination;
}
return null;
}
use of org.opensmartgridplatform.domain.core.valueobjects.Address 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;
}
Aggregations