Search in sources :

Example 1 with DeviceFilter

use of org.opensmartgridplatform.domain.core.valueobjects.DeviceFilter in project open-smart-grid-platform by OSGP.

the class DeviceManagementService method findDevices.

private Page<Device> findDevices(final String organisationIdentification, final DeviceFilter deviceFilter, final Organisation organisation, final PageRequest request) {
    final Page<Device> devices;
    try {
        if (!this.netManagementOrganisation.equals(organisationIdentification)) {
            // Municipality organization.
            if (deviceFilter == null) {
                final DeviceFilter df = new DeviceFilter();
                df.setOrganisationIdentification(organisationIdentification);
                df.setDeviceExternalManaged(DeviceExternalManagedFilterType.BOTH);
                df.setDeviceActivated(DeviceActivatedFilterType.BOTH);
                df.setDeviceInMaintenance(DeviceInMaintenanceFilterType.BOTH);
                df.setHasTechnicalInstallation(false);
                df.setExactMatch(false);
                devices = this.applyFilter(df, organisation, request);
            } else {
                deviceFilter.setOrganisationIdentification(organisationIdentification);
                devices = this.applyFilter(deviceFilter, organisation, request);
            }
        } else {
            // Net management organization.
            devices = this.applyFilter(deviceFilter, organisation, request);
        }
    } catch (final ArgumentNullOrEmptyException e) {
        /*
       * The implementation of applyFilter should check everything passed
       * on to DeviceSpecifications for not being empty, thus avoiding
       * ArgumentNullOrEmptyException. If something is missed (which
       * should not occur) pass it on as IllegalArgumentException to avoid
       * multiple checked exceptions being thrown.
       */
        throw new IllegalArgumentException("Null or empty input provided to DeviceSpecifications", e);
    }
    return devices;
}
Also used : DeviceFilter(org.opensmartgridplatform.domain.core.valueobjects.DeviceFilter) Device(org.opensmartgridplatform.domain.core.entities.Device) ArgumentNullOrEmptyException(org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException)

Aggregations

Device (org.opensmartgridplatform.domain.core.entities.Device)1 ArgumentNullOrEmptyException (org.opensmartgridplatform.domain.core.exceptions.ArgumentNullOrEmptyException)1 DeviceFilter (org.opensmartgridplatform.domain.core.valueobjects.DeviceFilter)1