feat: add measure property

This commit is contained in:
Arnaud Vergnet 2022-01-07 14:44:01 +01:00
parent 0843ac7205
commit 361464c94f
3 changed files with 16 additions and 5 deletions

View file

@ -18,9 +18,14 @@ public class DoItYourselfControl implements IControlFunctions {
@Override @Override
public void instantiateObservations(List<ObservationEntity> obsList, public void instantiateObservations(List<ObservationEntity> obsList,
String paramURI) { String paramURI) {
obsList.forEach(observationEntity -> customModel.createObs( obsList.forEach(observationEntity -> {
observationEntity.getValue().toString(), String instant = customModel.createInstant(observationEntity.getTimestamp());
paramURI, // System.out.println("Adding new observation: " + observationEntity.getValue().toString() + " " + paramURI + " " + instant);
customModel.createInstant(observationEntity.getTimestamp()))); customModel.createObs(
observationEntity.getValue().toString(),
paramURI,
instant
);
});
} }
} }

View file

@ -53,10 +53,14 @@ public class DoItYourselfModel implements IModelFunctions {
String obsInstanceURI = model.createInstance(instantURI + "_" + paramURI + "_" + value, obsClassURI); String obsInstanceURI = model.createInstance(instantURI + "_" + paramURI + "_" + value, obsClassURI);
String dataValueURI = model.getEntityURI("a pour valeur").get(0); String dataValueURI = model.getEntityURI("a pour valeur").get(0);
String datePropertyURI = model.getEntityURI("a pour date").get(0); String datePropertyURI = model.getEntityURI("a pour date").get(0);
String measurePropertyURI = model.getEntityURI("mesure").get(0);
String sensorURI = model.whichSensorDidIt(getInstantTimestamp(instantURI), paramURI); String sensorURI = model.whichSensorDidIt(getInstantTimestamp(instantURI), paramURI);
model.addObjectPropertyToIndividual(obsInstanceURI, measurePropertyURI, paramURI);
model.addDataPropertyToIndividual(obsInstanceURI, dataValueURI, value); model.addDataPropertyToIndividual(obsInstanceURI, dataValueURI, value);
model.addObjectPropertyToIndividual(obsInstanceURI, datePropertyURI, instantURI); model.addObjectPropertyToIndividual(obsInstanceURI, datePropertyURI, instantURI);
model.addObservationToSensor(obsInstanceURI, sensorURI); if (sensorURI != null) {
model.addObservationToSensor(obsInstanceURI, sensorURI);
}
return obsInstanceURI; return obsInstanceURI;
} }
} }

View file

@ -57,10 +57,12 @@ public class TestModelFunctions {
String obsClassURI = c.getModel().getEntityURI("Observation").get(0); String obsClassURI = c.getModel().getEntityURI("Observation").get(0);
String hasDataValueURI = c.getModel().getEntityURI("a pour valeur").get(0); String hasDataValueURI = c.getModel().getEntityURI("a pour valeur").get(0);
String datePropertyURI = c.getModel().getEntityURI("a pour date").get(0); String datePropertyURI = c.getModel().getEntityURI("a pour date").get(0);
String measurePropertyURI = c.getModel().getEntityURI("mesure").get(0);
String sensorURI = c.getModel().whichSensorDidIt("2014-02-13T06:20:00", paramURI); String sensorURI = c.getModel().whichSensorDidIt("2014-02-13T06:20:00", paramURI);
Assert.assertTrue("L'observation n'est pas une instance de la bonne classe", c.getModel().isOfType(obsURI, obsClassURI)); Assert.assertTrue("L'observation n'est pas une instance de la bonne classe", c.getModel().isOfType(obsURI, obsClassURI));
Assert.assertTrue("L'observation n'a pas la bonne valeur", c.getModel().hasDataPropertyValue(obsURI, hasDataValueURI, value)); Assert.assertTrue("L'observation n'a pas la bonne valeur", c.getModel().hasDataPropertyValue(obsURI, hasDataValueURI, value));
Assert.assertTrue("L'observation n'a pas la bonne date", c.getModel().hasObjectProperty(obsURI, datePropertyURI, instantURI)); Assert.assertTrue("L'observation n'a pas la bonne date", c.getModel().hasObjectProperty(obsURI, datePropertyURI, instantURI));
Assert.assertTrue("L'observation n'est pas rattachée au bon paramètre", c.getModel().hasObjectProperty(obsURI, measurePropertyURI, paramURI));
Assert.assertTrue("L'observation n'est pas rattachée au bon capteur", c.getModel().hasSensorDoneIt(obsURI, sensorURI)); Assert.assertTrue("L'observation n'est pas rattachée au bon capteur", c.getModel().hasSensorDoneIt(obsURI, sensorURI));
} }
} }