View Javadoc
1   package de.dlr.shepard.neo4Core.dao;
2   
3   import de.dlr.shepard.mongoDB.ShepardFile;
4   import de.dlr.shepard.util.CypherQueryHelper;
5   import jakarta.enterprise.context.RequestScoped;
6   import java.util.Map;
7   
8   @RequestScoped
9   public class ShepardFileDAO extends GenericDAO<ShepardFile> {
10  
11    /**
12     * Find a shepardFile by oid
13     *
14     * @param containerId FileContainer ID
15     * @param oid         Identifies the shepardFile
16     *
17     * @return the found shepardFile or null
18     */
19    public ShepardFile find(long containerId, String oid) {
20      var query = String.format(
21        "MATCH (c:FileContainer)-[:file_in_container]->(f:ShepardFile {oid: $oid}) WHERE ID(c)=%d %s",
22        containerId,
23        CypherQueryHelper.getReturnPart("f")
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<ShepardFile> getEntityType() {
31      return ShepardFile.class;
32    }
33  }