Search in sources :

Example 1 with Datastream

use of de.fraunhofer.iosb.ilt.sta.model.Datastream in project FROST-Server by FraunhoferIOSB.

the class DeleteFilterTests method createEntities.

private static void createEntities() throws ServiceFailureException, URISyntaxException {
    Thing thing = new Thing("Thing 1", "The first thing.");
    THINGS.add(thing);
    Location location = new Location("Location 1.0", "Location of Thing 1.", "application/vnd.geo+json", new Point(8, 51));
    thing.getLocations().add(location);
    service.create(thing);
    Sensor sensor = new Sensor("Sensor 1", "The first sensor.", "text", "Some metadata.");
    ObservedProperty obsProp = new ObservedProperty("Temperature", new URI("http://ucom.org/temperature"), "The temperature of the thing.");
    {
        Datastream datastream = new Datastream("Datastream 1", "The temperature of thing 1, sensor 1.", "someType", new UnitOfMeasurement("degree celcius", "°C", "ucum:T"));
        datastream.setThing(thing);
        datastream.setSensor(sensor);
        datastream.setObservedProperty(obsProp);
        service.create(datastream);
        DATASTREAMS.add(datastream);
    }
    {
        Datastream datastream = new Datastream("Datastream 2", "The alternate temperature of thing 1, sensor 1.", "someType", new UnitOfMeasurement("degree celcius", "°C", "ucum:T"));
        datastream.setThing(thing);
        datastream.setSensor(sensor);
        datastream.setObservedProperty(obsProp);
        service.create(datastream);
        DATASTREAMS.add(datastream);
    }
}
Also used : Datastream(de.fraunhofer.iosb.ilt.sta.model.Datastream) UnitOfMeasurement(de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement) ObservedProperty(de.fraunhofer.iosb.ilt.sta.model.ObservedProperty) Point(org.geojson.Point) URI(java.net.URI) Thing(de.fraunhofer.iosb.ilt.sta.model.Thing) Location(de.fraunhofer.iosb.ilt.sta.model.Location) Sensor(de.fraunhofer.iosb.ilt.sta.model.Sensor)

Example 2 with Datastream

use of de.fraunhofer.iosb.ilt.sta.model.Datastream in project FROST-Server by FraunhoferIOSB.

the class ResultTypesTests method createEntities.

private static void createEntities() throws ServiceFailureException, URISyntaxException {
    Thing thing = new Thing("Thing 1", "The first thing.");
    THINGS.add(thing);
    Location location = new Location("Location 1.0", "Location of Thing 1.", "application/vnd.geo+json", new Point(8, 51));
    thing.getLocations().add(location);
    service.create(thing);
    Sensor sensor = new Sensor("Sensor 1", "The first sensor.", "text", "Some metadata.");
    ObservedProperty obsProp = new ObservedProperty("Temperature", new URI("http://ucom.org/temperature"), "The temperature of the thing.");
    Datastream datastream = new Datastream("Datastream 1", "The temperature of thing 1, sensor 1.", "someType", new UnitOfMeasurement("degree celcius", "°C", "ucum:T"));
    datastream.setThing(thing);
    datastream.setSensor(sensor);
    datastream.setObservedProperty(obsProp);
    service.create(datastream);
    DATASTREAMS.add(datastream);
}
Also used : Datastream(de.fraunhofer.iosb.ilt.sta.model.Datastream) UnitOfMeasurement(de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement) ObservedProperty(de.fraunhofer.iosb.ilt.sta.model.ObservedProperty) Point(org.geojson.Point) URI(java.net.URI) Thing(de.fraunhofer.iosb.ilt.sta.model.Thing) Location(de.fraunhofer.iosb.ilt.sta.model.Location) Sensor(de.fraunhofer.iosb.ilt.sta.model.Sensor)

Example 3 with Datastream

use of de.fraunhofer.iosb.ilt.sta.model.Datastream in project FROST-Server by FraunhoferIOSB.

the class AdditionalTests method testRecreateAutomaticFoi.

@Test
public void testRecreateAutomaticFoi() throws ServiceFailureException {
    LOGGER.info("  testRecreateAutomaticFoi");
    EntityUtils.deleteAll(service);
    // Create two things
    Location location1 = new Location("LocationThing1", "Location of Thing 1", "application/geo+json", new Point(8, 50));
    service.create(location1);
    Thing thing1 = new Thing("Thing 1", "The first thing.");
    thing1.getLocations().add(location1.withOnlyId());
    service.create(thing1);
    Sensor sensor1 = new Sensor("Test Thermometre", "Test Sensor", "None", "-");
    service.create(sensor1);
    ObservedProperty obsProp1 = new ObservedProperty("Temperature", "http://example.org", "-");
    service.create(obsProp1);
    Datastream datastream1 = new Datastream("Ds 1, Thing 1", "The datastream of Thing 1", "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement", new UnitOfMeasurement("Degrees Celcius", "°C", "http://qudt.org/vocab/unit#DegreeCelsius"));
    datastream1.setThing(thing1);
    datastream1.setSensor(sensor1);
    datastream1.setObservedProperty(obsProp1);
    service.create(datastream1);
    Observation obs1 = new Observation(1.0, datastream1);
    service.create(obs1);
    FeatureOfInterest foiGenerated1 = service.observations().find(obs1.getId()).getFeatureOfInterest();
    Assert.assertNotNull(foiGenerated1);
    service.delete(foiGenerated1);
    Observation obs2 = new Observation(1.0, datastream1);
    service.create(obs2);
    FeatureOfInterest foiGenerated2 = service.observations().find(obs2.getId()).getFeatureOfInterest();
    Assert.assertNotNull(foiGenerated2);
    Assert.assertNotEquals(foiGenerated1, foiGenerated2);
}
Also used : Datastream(de.fraunhofer.iosb.ilt.sta.model.Datastream) UnitOfMeasurement(de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement) ObservedProperty(de.fraunhofer.iosb.ilt.sta.model.ObservedProperty) FeatureOfInterest(de.fraunhofer.iosb.ilt.sta.model.FeatureOfInterest) Observation(de.fraunhofer.iosb.ilt.sta.model.Observation) Point(org.geojson.Point) Thing(de.fraunhofer.iosb.ilt.sta.model.Thing) HistoricalLocation(de.fraunhofer.iosb.ilt.sta.model.HistoricalLocation) Location(de.fraunhofer.iosb.ilt.sta.model.Location) Sensor(de.fraunhofer.iosb.ilt.sta.model.Sensor) Test(org.junit.Test)

Example 4 with Datastream

use of de.fraunhofer.iosb.ilt.sta.model.Datastream in project FROST-Server by FraunhoferIOSB.

the class AdditionalTests method testMultipleLocations.

/**
 * Check the creation of a FoI on Observation creation, for Things that have
 * multiple Locations, only one of which is a geoJson location.
 *
 * @throws ServiceFailureException If the service doesn't respond.
 */
@Test
public void testMultipleLocations() throws ServiceFailureException {
    LOGGER.info("  testMultipleLocations");
    EntityUtils.deleteAll(service);
    Thing thing = new Thing("Thing 1", "The first thing.");
    Location location1 = new Location("Location 1.0, Address", "The address of Thing 1.", "text/plain", "");
    thing.getLocations().add(location1);
    Location location2 = new Location("Location 1.0", "Location of Thing 1.", "application/geo+json", new Point(8, 51));
    thing.getLocations().add(location2);
    Location location3 = new Location("Location 1.0, Directions", "How to find Thing 1 in human language.", "text/plain", "");
    thing.getLocations().add(location3);
    service.create(thing);
    THINGS.add(thing);
    Sensor sensor = new Sensor("Sensor 1", "The first sensor.", "text", "Some metadata.");
    ObservedProperty obsProp = new ObservedProperty("Temperature", "http://ucom.org/temperature", "The temperature of the thing.");
    Datastream datastream = new Datastream("Datastream 1", "The temperature of thing 1, sensor 1.", "someType", new UnitOfMeasurement("degree celcius", "°C", "ucum:T"));
    datastream.setSensor(sensor);
    datastream.setObservedProperty(obsProp);
    datastream.setThing(thing);
    service.create(datastream);
    DATASTREAMS.add(datastream);
    ObservationDao doa = service.observations();
    Observation observation = new Observation(1.0, DATASTREAMS.get(0));
    doa.create(observation);
    OBSERVATIONS.add(observation);
    Observation found;
    found = doa.find(observation.getId());
    FeatureOfInterest featureOfInterest = found.getFeatureOfInterest();
    Assert.assertNotNull("A FeatureOfInterest should have been generated, but got NULL.", featureOfInterest);
}
Also used : Datastream(de.fraunhofer.iosb.ilt.sta.model.Datastream) UnitOfMeasurement(de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement) ObservedProperty(de.fraunhofer.iosb.ilt.sta.model.ObservedProperty) FeatureOfInterest(de.fraunhofer.iosb.ilt.sta.model.FeatureOfInterest) ObservationDao(de.fraunhofer.iosb.ilt.sta.dao.ObservationDao) Observation(de.fraunhofer.iosb.ilt.sta.model.Observation) Point(org.geojson.Point) Thing(de.fraunhofer.iosb.ilt.sta.model.Thing) HistoricalLocation(de.fraunhofer.iosb.ilt.sta.model.HistoricalLocation) Location(de.fraunhofer.iosb.ilt.sta.model.Location) Sensor(de.fraunhofer.iosb.ilt.sta.model.Sensor) Test(org.junit.Test)

Example 5 with Datastream

use of de.fraunhofer.iosb.ilt.sta.model.Datastream in project FROST-Server by FraunhoferIOSB.

the class AdditionalTests method testPostInvalidPath.

/**
 * Tests requests on paths like Things(x)/Datastreams(y)/Observations, where
 * Datastream(y) exists, but is not part of the, also existing, Things(x).
 *
 * @throws ServiceFailureException If the service doesn't respond.
 */
@Test
public void testPostInvalidPath() throws ServiceFailureException {
    LOGGER.info("  testPostInvalidPath");
    EntityUtils.deleteAll(service);
    // Create two things
    Location location1 = new Location("LocationThing1", "Location of Thing 1", "application/geo+json", new Point(8, 50));
    service.create(location1);
    Thing thing1 = new Thing("Thing 1", "The first thing.");
    thing1.getLocations().add(location1.withOnlyId());
    service.create(thing1);
    Thing thing2 = new Thing("Thing 2", "The second thing.");
    thing2.getLocations().add(location1.withOnlyId());
    service.create(thing2);
    Sensor sensor1 = new Sensor("Test Thermometre", "Test Sensor", "None", "-");
    service.create(sensor1);
    ObservedProperty obsProp1 = new ObservedProperty("Temperature", "http://example.org", "-");
    service.create(obsProp1);
    Datastream datastream1 = new Datastream("Ds 1, Thing 1", "The datastream of Thing 1", "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement", new UnitOfMeasurement("Degrees Celcius", "°C", "http://qudt.org/vocab/unit#DegreeCelsius"));
    datastream1.setThing(thing1);
    datastream1.setSensor(sensor1);
    datastream1.setObservedProperty(obsProp1);
    service.create(datastream1);
    Observation obs1 = new Observation(1.0, datastream1);
    service.create(obs1);
    testGet(thing1, datastream1, thing2);
    // PUT tests
    String urlObsGood = serverSettings.getServiceUrl(version) + "/Things(" + thing1.getId().getUrl() + ")" + "/Datastreams(" + datastream1.getId().getUrl() + ")" + "/Observations(" + obs1.getId().getUrl() + ")";
    String urlObsBad = serverSettings.getServiceUrl(version) + "/Things(" + thing2.getId().getUrl() + ")" + "/Datastreams(" + datastream1.getId().getUrl() + ")" + "/Observations(" + obs1.getId().getUrl() + ")";
    testPut(urlObsGood, urlObsBad);
    testPatch(urlObsGood, urlObsBad);
    testDelete(urlObsBad, urlObsGood);
}
Also used : Datastream(de.fraunhofer.iosb.ilt.sta.model.Datastream) UnitOfMeasurement(de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement) ObservedProperty(de.fraunhofer.iosb.ilt.sta.model.ObservedProperty) Observation(de.fraunhofer.iosb.ilt.sta.model.Observation) Point(org.geojson.Point) Thing(de.fraunhofer.iosb.ilt.sta.model.Thing) HistoricalLocation(de.fraunhofer.iosb.ilt.sta.model.HistoricalLocation) Location(de.fraunhofer.iosb.ilt.sta.model.Location) Sensor(de.fraunhofer.iosb.ilt.sta.model.Sensor) Test(org.junit.Test)

Aggregations

Datastream (de.fraunhofer.iosb.ilt.sta.model.Datastream)33 MultiDatastream (de.fraunhofer.iosb.ilt.sta.model.MultiDatastream)18 Observation (de.fraunhofer.iosb.ilt.sta.model.Observation)14 ObservedProperty (de.fraunhofer.iosb.ilt.sta.model.ObservedProperty)14 Point (org.geojson.Point)13 Sensor (de.fraunhofer.iosb.ilt.sta.model.Sensor)12 Thing (de.fraunhofer.iosb.ilt.sta.model.Thing)12 UnitOfMeasurement (de.fraunhofer.iosb.ilt.sta.model.ext.UnitOfMeasurement)12 Test (org.junit.Test)12 Location (de.fraunhofer.iosb.ilt.sta.model.Location)11 ServiceFailureException (de.fraunhofer.iosb.ilt.sta.ServiceFailureException)7 FeatureOfInterest (de.fraunhofer.iosb.ilt.sta.model.FeatureOfInterest)7 URI (java.net.URI)7 ArrayList (java.util.ArrayList)5 HistoricalLocation (de.fraunhofer.iosb.ilt.sta.model.HistoricalLocation)4 HashMap (java.util.HashMap)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 IdString (de.fraunhofer.iosb.ilt.sta.model.IdString)3 TimeObject (de.fraunhofer.iosb.ilt.sta.model.TimeObject)3