View Javadoc
1   package de.dlr.shepard.neo4Core.dao;
2   
3   import java.util.Collections;
4   import java.util.List;
5   import java.util.stream.StreamSupport;
6   
7   import de.dlr.shepard.neo4Core.entities.TimeseriesReference;
8   import de.dlr.shepard.util.CypherQueryHelper;
9   
10  public class TimeseriesReferenceDAO extends GenericDAO<TimeseriesReference> {
11  
12  	/**
13  	 * Searches the database for references.
14  	 *
15  	 * @param dataObjectId identifies the dataObject
16  	 * @return a List of references
17  	 */
18  	public List<TimeseriesReference> findByDataObject(long dataObjectId) {
19  		String query = String.format("MATCH (d:DataObject)-[hr:has_reference]->%s WHERE ID(d)=%d ",
20  				CypherQueryHelper.getObjectPart("r", "TimeseriesReference", false), dataObjectId)
21  				+ CypherQueryHelper.getReturnPart("r");
22  
23  		var queryResult = findByQuery(query, Collections.emptyMap());
24  
25  		List<TimeseriesReference> result = StreamSupport.stream(queryResult.spliterator(), false)
26  				.filter(r -> r.getDataObject() != null).filter(r -> r.getDataObject().getId().equals(dataObjectId))
27  				.toList();
28  
29  		return result;
30  	}
31  
32  	@Override
33  	public Class<TimeseriesReference> getEntityType() {
34  		return TimeseriesReference.class;
35  	}
36  
37  }