Search in sources :

Example 16 with Manufacturer

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);
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.entities.DeviceModel) DeviceModelBuilder(org.opensmartgridplatform.cucumber.platform.core.builders.DeviceModelBuilder) Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer)

Example 17 with Manufacturer

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;
}
Also used : Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer)

Example 18 with 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;
}
Also used : Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer)

Example 19 with 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);
    }
}
Also used : DeviceModel(org.opensmartgridplatform.domain.core.entities.DeviceModel) LightMeasurementDevice(org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice) Device(org.opensmartgridplatform.domain.core.entities.Device) Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer)

Example 20 with Manufacturer

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;
}
Also used : Manufacturer(org.opensmartgridplatform.domain.core.entities.Manufacturer) ConstraintViolationException(javax.validation.ConstraintViolationException) ChangeManufacturerResponse(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.ChangeManufacturerResponse) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

Manufacturer (org.opensmartgridplatform.domain.core.entities.Manufacturer)30 DeviceModel (org.opensmartgridplatform.domain.core.entities.DeviceModel)18 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)13 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)10 Transactional (org.springframework.transaction.annotation.Transactional)10 DeviceFirmwareFile (org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile)7 FirmwareFile (org.opensmartgridplatform.domain.core.entities.FirmwareFile)6 ExistingEntityException (org.opensmartgridplatform.domain.core.exceptions.ExistingEntityException)6 Device (org.opensmartgridplatform.domain.core.entities.Device)5 Then (io.cucumber.java.en.Then)4 ArrayList (java.util.ArrayList)3 ConstraintViolationException (javax.validation.ConstraintViolationException)3 UnknownEntityException (org.opensmartgridplatform.domain.core.exceptions.UnknownEntityException)3 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)3 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)3 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)3 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)2 FirmwareModule (org.opensmartgridplatform.domain.core.entities.FirmwareModule)2 Given (io.cucumber.java.en.Given)1 Date (java.util.Date)1