View Javadoc
1   package de.dlr.shepard.neo4Core.dao;
2   
3   import de.dlr.shepard.mongoDB.StructuredData;
4   import de.dlr.shepard.util.CypherQueryHelper;
5   import jakarta.enterprise.context.RequestScoped;
6   import java.util.Map;
7   
8   @RequestScoped
9   public class StructuredDataDAO extends GenericDAO<StructuredData> {
10  
11    /**
12     * Find a structuredData by oid
13     *
14     * @param containerId StructuredDataContainer ID
15     * @param oid         Identifies the structuredData
16     *
17     * @return the found structuredData or null
18     */
19    public StructuredData find(long containerId, String oid) {
20      var query = String.format(
21        "MATCH (c:StructuredDataContainer)-[:structureddata_in_container]->(s:StructuredData {oid: $oid}) WHERE ID(c)=%d %s",
22        containerId,
23        CypherQueryHelper.getReturnPart("s")
24      );
25      var results = findByQuery(query, Map.of("oid", oid));
26      return results.iterator().hasNext() ? results.iterator().next() : null;
27    }
28  
29    @Override
30    public Class<StructuredData> getEntityType() {
31      return StructuredData.class;
32    }
33  }