use of org.opensmartgridplatform.domain.core.entities.Manufacturer in project open-smart-grid-platform by OSGP.
the class DeviceModelSteps method insertDeviceModel.
/**
* This inserts a default DeviceModel
*/
public DeviceModel insertDeviceModel(final Map<String, String> settings) {
final Manufacturer manufacturer = this.manufacturerRepository.findByName(getString(settings, PlatformKeys.MANUFACTURER_NAME, PlatformDefaults.DEFAULT_MANUFACTURER_NAME));
final DeviceModel deviceModel = new DeviceModelBuilder().withSettings(settings).withManufacturer(manufacturer).build();
return this.deviceModelRepository.save(deviceModel);
}
use of org.opensmartgridplatform.domain.core.entities.Manufacturer in project open-smart-grid-platform by OSGP.
the class ManufacturerBuilder method build.
@Override
public Manufacturer build() {
final Manufacturer manufacturer = new Manufacturer();
manufacturer.setCode(this.code);
manufacturer.setName(this.name);
manufacturer.setUsePrefix(this.usePrefix);
return manufacturer;
}
use of org.opensmartgridplatform.domain.core.entities.Manufacturer in project open-smart-grid-platform by OSGP.
the class BaseTask method findManufacturer.
/**
* Try to find a manufacturer by name (case sensitive).
*/
protected Manufacturer findManufacturer(final String name) {
LOGGER.info("Trying to find manufacturer for name: {}", name);
final Manufacturer manufacturer = this.manufacturerRepository.findByName(name);
if (manufacturer == null) {
LOGGER.warn("No manufacturer found for name: {}", name);
} else {
LOGGER.info("Manufacturer found for name: {}", name);
}
return manufacturer;
}
use of org.opensmartgridplatform.domain.core.entities.Manufacturer in project open-smart-grid-platform by OSGP.
the class DeviceConnectionScheduledTask method run.
@Override
public void run() {
LOGGER.info("Ensuring active connections with LMD devices of manufacturer '{}'", this.deviceConnectionScheduledTaskManufacturerName);
try {
final Manufacturer manufacturer = this.findManufacturer(this.deviceConnectionScheduledTaskManufacturerName);
if (manufacturer == null) {
return;
}
final List<DeviceModel> deviceModels = this.findDeviceModels(manufacturer);
if (deviceModels == null || deviceModels.isEmpty()) {
return;
}
final List<Device> devices = this.findDevices(deviceModels, LightMeasurementDevice.LMD_TYPE);
if (devices.isEmpty()) {
return;
}
final List<Device> devicesToContact = this.findDevicesToContact(devices, this.deviceConnectionScheduledTaskMaximumAllowedAge);
if (devicesToContact == null || devicesToContact.isEmpty()) {
return;
}
this.contactDevices(devicesToContact, DeviceFunction.GET_LIGHT_SENSOR_STATUS);
} catch (final Exception e) {
LOGGER.error("Exception caught during DeviceConnectionScheduledTask.run()", e);
}
}
use of org.opensmartgridplatform.domain.core.entities.Manufacturer in project open-smart-grid-platform by OSGP.
the class FirmwareManagementEndpoint method changeManufacturer.
@PayloadRoot(localPart = "ChangeManufacturerRequest", namespace = NAMESPACE)
@ResponsePayload
public ChangeManufacturerResponse changeManufacturer(@OrganisationIdentification final String organisationIdentification, @RequestPayload final ChangeManufacturerRequest request) throws OsgpException {
LOGGER.info("Changing manufacturer:{}.", request.getManufacturer().getName());
try {
this.firmwareManagementService.changeManufacturer(organisationIdentification, new Manufacturer(request.getManufacturer().getCode(), request.getManufacturer().getName(), request.getManufacturer().isUsePrefix()));
} catch (final ConstraintViolationException e) {
LOGGER.error("Exception Changing manufacturer", e);
this.handleException(e);
} catch (final Exception e) {
LOGGER.error("Exception: {} while Changing manufacturer: {} for organisation {}", e.getMessage(), request.getManufacturer().getCode(), organisationIdentification, e);
this.handleException(e);
}
final ChangeManufacturerResponse changeManufacturerResponse = new ChangeManufacturerResponse();
changeManufacturerResponse.setResult(OsgpResultType.OK);
return changeManufacturerResponse;
}
Aggregations