use of org.n52.shetland.filter.ExpandFilter 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);
}
use of org.n52.shetland.filter.ExpandFilter 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);
}
use of org.n52.shetland.filter.ExpandFilter 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;
}
use of org.n52.shetland.filter.ExpandFilter 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;
}
use of org.n52.shetland.filter.ExpandFilter in project arctic-sea by 52North.
the class STAQueryOptionVisitor method handleSlashRewrite.
// Rewrite slash to normal expand systemQueryOption
private ExpandItem handleSlashRewrite(STAQueryOptionsGrammar.ExpandItemContext ctx, QueryOptions baseref) {
QueryOptions base = baseref;
if (!ctx.memberExpr().SLASH().isEmpty()) {
for (int i = ctx.memberExpr().ALPHAPLUS().size() - 1; i >= 1; i--) {
ExpandItem expandItem = new ExpandItem(ctx.memberExpr().ALPHAPLUS(i).getText(), base);
ExpandFilter expandFilter = new ExpandFilter(expandItem);
base = new QueryOptions("", Collections.singleton(expandFilter));
}
}
return new ExpandItem(ctx.memberExpr().ALPHAPLUS(0).getText(), base);
}
Aggregations