1 package de.dlr.shepard.neo4Core.dao;
2
3 import de.dlr.shepard.influxDB.Timeseries;
4 import de.dlr.shepard.util.CypherQueryHelper;
5 import jakarta.enterprise.context.RequestScoped;
6 import java.util.Map;
7
8 @RequestScoped
9 public class TimeseriesDAO extends GenericDAO<Timeseries> {
10
11
12
13
14
15
16
17
18
19
20
21
22 public Timeseries find(String measurement, String device, String location, String symbolicName, String field) {
23 var query = String.format(
24 "MATCH (t:Timeseries { measurement: $measurement, device: $device, location: $location, symbolicName: $symbolicName, field: $field }) %s",
25 CypherQueryHelper.getReturnPart("t")
26 );
27 Map<String, Object> params = Map.of(
28 "measurement",
29 measurement,
30 "device",
31 device,
32 "location",
33 location,
34 "symbolicName",
35 symbolicName,
36 "field",
37 field
38 );
39 var results = findByQuery(query, params);
40 return results.iterator().hasNext() ? results.iterator().next() : null;
41 }
42
43 @Override
44 public Class<Timeseries> getEntityType() {
45 return Timeseries.class;
46 }
47 }