Search in sources :

Example 1 with STAInvalidQueryException

use of org.n52.shetland.ogc.sta.exception.STAInvalidQueryException in project sensorweb-server-sta by 52North.

the class ObservedPropertyService method fetchExpandEntities.

@Override
protected ObservablePropertyEntity fetchExpandEntities(PhenomenonEntity entity, ExpandFilter expandOption) throws STACRUDException, STAInvalidQueryException {
    for (ExpandItem expandItem : expandOption.getItems()) {
        String expandProperty = expandItem.getPath();
        if (ObservedPropertyEntityDefinition.NAVIGATION_PROPERTIES.contains(expandProperty)) {
            Page<DatastreamEntity> obsP = getDatastreamService().getEntityCollectionByRelatedEntityRaw(entity.getStaIdentifier(), STAEntityDefinition.OBSERVED_PROPERTIES, expandItem.getQueryOptions());
            ObservablePropertyEntity obsProp = new ObservablePropertyEntity(entity);
            return obsProp.setDatastreams(obsP.get().collect(Collectors.toSet()));
        } else {
            throw new STAInvalidQueryException("Invalid expandOption supplied. Cannot find " + expandProperty + " on Entity of type 'ObservableProperty'");
        }
    }
    return new ObservablePropertyEntity(entity);
}
Also used : STAInvalidQueryException(org.n52.shetland.ogc.sta.exception.STAInvalidQueryException) ExpandItem(org.n52.shetland.filter.ExpandItem) DatastreamEntity(org.n52.series.db.beans.sta.DatastreamEntity) ObservablePropertyEntity(org.n52.series.db.beans.sta.ObservablePropertyEntity)

Example 2 with STAInvalidQueryException

use of org.n52.shetland.ogc.sta.exception.STAInvalidQueryException in project sensorweb-server-sta by 52North.

the class SensorService method fetchExpandEntities.

@Override
protected SensorEntity fetchExpandEntities(ProcedureEntity entity, ExpandFilter expandOption) throws STACRUDException, STAInvalidQueryException {
    for (ExpandItem expandItem : expandOption.getItems()) {
        String expandProperty = expandItem.getPath();
        if (SensorEntityDefinition.NAVIGATION_PROPERTIES.contains(expandProperty)) {
            Page<DatastreamEntity> observedProps = getDatastreamService().getEntityCollectionByRelatedEntityRaw(entity.getStaIdentifier(), STAEntityDefinition.SENSORS, expandItem.getQueryOptions());
            SensorEntity sensor = new SensorEntity(entity);
            return sensor.setDatastreams(observedProps.get().collect(Collectors.toSet()));
        } else {
            throw new STAInvalidQueryException("Invalid expandOption supplied. Cannot find " + expandProperty + " on Entity of type 'Sensor'");
        }
    }
    return new SensorEntity(entity);
}
Also used : STAInvalidQueryException(org.n52.shetland.ogc.sta.exception.STAInvalidQueryException) ExpandItem(org.n52.shetland.filter.ExpandItem) SensorEntity(org.n52.series.db.beans.sta.SensorEntity) DatastreamEntity(org.n52.series.db.beans.sta.DatastreamEntity)

Example 3 with STAInvalidQueryException

use of org.n52.shetland.ogc.sta.exception.STAInvalidQueryException in project sensorweb-server-sta by 52North.

the class HistoricalLocationService method fetchExpandEntities.

@Override
protected HistoricalLocationEntity fetchExpandEntities(HistoricalLocationEntity entity, ExpandFilter expandOption) throws STACRUDException, STAInvalidQueryException {
    for (ExpandItem expandItem : expandOption.getItems()) {
        String expandProperty = expandItem.getPath();
        if (HistoricalLocationEntityDefinition.NAVIGATION_PROPERTIES.contains(expandProperty)) {
            switch(expandProperty) {
                case STAEntityDefinition.LOCATIONS:
                    Page<LocationEntity> locations = getLocationService().getEntityCollectionByRelatedEntityRaw(entity.getStaIdentifier(), STAEntityDefinition.HISTORICAL_LOCATIONS, expandItem.getQueryOptions());
                    entity.setLocations(locations.get().collect(Collectors.toSet()));
                    break;
                case STAEntityDefinition.THING:
                    PlatformEntity things = getThingService().getEntityByRelatedEntityRaw(entity.getStaIdentifier(), STAEntityDefinition.HISTORICAL_LOCATIONS, null, expandItem.getQueryOptions());
                    entity.setThing(things);
                    break;
                default:
                    throw new RuntimeException("This can never happen!");
            }
        } else {
            throw new STAInvalidQueryException("Invalid expandOption supplied. Cannot find " + expandProperty + " on Entity of type 'HistoricalLocation'");
        }
    }
    return entity;
}
Also used : STAInvalidQueryException(org.n52.shetland.ogc.sta.exception.STAInvalidQueryException) PlatformEntity(org.n52.series.db.beans.PlatformEntity) ExpandItem(org.n52.shetland.filter.ExpandItem) HistoricalLocationEntity(org.n52.series.db.beans.sta.HistoricalLocationEntity) LocationEntity(org.n52.series.db.beans.sta.LocationEntity)

Example 4 with STAInvalidQueryException

use of org.n52.shetland.ogc.sta.exception.STAInvalidQueryException in project sensorweb-server-sta by 52North.

the class DatastreamService method fetchExpandEntities.

@Override
protected DatastreamEntity fetchExpandEntities(DatastreamEntity entity, ExpandFilter expandOption) throws STACRUDException, STAInvalidQueryException {
    for (ExpandItem expandItem : expandOption.getItems()) {
        String expandProperty = expandItem.getPath();
        if (DatastreamEntityDefinition.NAVIGATION_PROPERTIES.contains(expandProperty)) {
            switch(expandProperty) {
                case STAEntityDefinition.SENSOR:
                    ProcedureEntity sensor = getSensorService().getEntityByRelatedEntityRaw(entity.getStaIdentifier(), STAEntityDefinition.DATASTREAMS, null, expandItem.getQueryOptions());
                    entity.setProcedure(sensor);
                    break;
                case STAEntityDefinition.THING:
                    PlatformEntity thing = getThingService().getEntityByRelatedEntityRaw(entity.getStaIdentifier(), STAEntityDefinition.DATASTREAMS, null, expandItem.getQueryOptions());
                    entity.setThing(thing);
                    break;
                case STAEntityDefinition.OBSERVED_PROPERTY:
                    PhenomenonEntity obsProp = getObservedPropertyService().getEntityByRelatedEntityRaw(entity.getStaIdentifier(), STAEntityDefinition.DATASTREAMS, null, expandItem.getQueryOptions());
                    entity.setObservableProperty(obsProp);
                    break;
                case STAEntityDefinition.OBSERVATIONS:
                    Page<ObservationEntity<?>> observations = getObservationService().getEntityCollectionByRelatedEntityRaw(entity.getStaIdentifier(), STAEntityDefinition.DATASTREAMS, expandItem.getQueryOptions());
                    entity.setObservations(observations.get().collect(Collectors.toSet()));
                    break;
                default:
                    logger.error("Trying to expand unrelated Entity!");
                    throw new RuntimeException("This can never happen!");
            }
        } else {
            throw new STAInvalidQueryException("Invalid expandOption supplied. Cannot find " + expandProperty + " on Entity of type 'Datastream'");
        }
    }
    return entity;
}
Also used : ProcedureEntity(org.n52.series.db.beans.ProcedureEntity) STAInvalidQueryException(org.n52.shetland.ogc.sta.exception.STAInvalidQueryException) PlatformEntity(org.n52.series.db.beans.PlatformEntity) ExpandItem(org.n52.shetland.filter.ExpandItem) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity) AbstractObservationEntity(org.n52.series.db.beans.sta.AbstractObservationEntity) ObservationEntity(org.n52.series.db.beans.sta.ObservationEntity)

Example 5 with STAInvalidQueryException

use of org.n52.shetland.ogc.sta.exception.STAInvalidQueryException in project sensorweb-server-sta by 52North.

the class LocationService method fetchExpandEntities.

@Override
protected LocationEntity fetchExpandEntities(LocationEntity entity, ExpandFilter expandOption) throws STACRUDException, STAInvalidQueryException {
    for (ExpandItem expandItem : expandOption.getItems()) {
        String expandProperty = expandItem.getPath();
        if (LocationEntityDefinition.NAVIGATION_PROPERTIES.contains(expandProperty)) {
            switch(expandProperty) {
                case STAEntityDefinition.HISTORICAL_LOCATIONS:
                    Page<HistoricalLocationEntity> hLocs = getHistoricalLocationService().getEntityCollectionByRelatedEntityRaw(entity.getStaIdentifier(), STAEntityDefinition.LOCATIONS, expandItem.getQueryOptions());
                    entity.setHistoricalLocations(hLocs.get().collect(Collectors.toSet()));
                    break;
                case STAEntityDefinition.THINGS:
                    Page<PlatformEntity> things = getThingService().getEntityCollectionByRelatedEntityRaw(entity.getStaIdentifier(), STAEntityDefinition.LOCATIONS, expandItem.getQueryOptions());
                    entity.setThings(things.get().collect(Collectors.toSet()));
                    break;
                default:
                    throw new RuntimeException("This can never happen!");
            }
        } else {
            throw new STAInvalidQueryException("Invalid expandOption supplied. Cannot find " + expandProperty + " on Entity of type 'Location'");
        }
    }
    return entity;
}
Also used : STAInvalidQueryException(org.n52.shetland.ogc.sta.exception.STAInvalidQueryException) PlatformEntity(org.n52.series.db.beans.PlatformEntity) ExpandItem(org.n52.shetland.filter.ExpandItem) HistoricalLocationEntity(org.n52.series.db.beans.sta.HistoricalLocationEntity)

Aggregations

ExpandItem (org.n52.shetland.filter.ExpandItem)7 STAInvalidQueryException (org.n52.shetland.ogc.sta.exception.STAInvalidQueryException)7 DatastreamEntity (org.n52.series.db.beans.sta.DatastreamEntity)4 PlatformEntity (org.n52.series.db.beans.PlatformEntity)3 HistoricalLocationEntity (org.n52.series.db.beans.sta.HistoricalLocationEntity)3 LocationEntity (org.n52.series.db.beans.sta.LocationEntity)2 PhenomenonEntity (org.n52.series.db.beans.PhenomenonEntity)1 ProcedureEntity (org.n52.series.db.beans.ProcedureEntity)1 AbstractObservationEntity (org.n52.series.db.beans.sta.AbstractObservationEntity)1 ObservablePropertyEntity (org.n52.series.db.beans.sta.ObservablePropertyEntity)1 ObservationEntity (org.n52.series.db.beans.sta.ObservationEntity)1 SensorEntity (org.n52.series.db.beans.sta.SensorEntity)1