1 package de.dlr.shepard.neo4Core.dao; 2 3 import java.util.ArrayList; 4 import java.util.HashMap; 5 import java.util.List; 6 import java.util.Map; 7 8 import de.dlr.shepard.neo4Core.entities.UserGroup; 9 import de.dlr.shepard.util.CypherQueryHelper; 10 import de.dlr.shepard.util.QueryParamHelper; 11 12 public class UserGroupDAO extends GenericDAO<UserGroup> { 13 14 @Override 15 public Class<UserGroup> getEntityType() { 16 return UserGroup.class; 17 } 18 19 public List<UserGroup> findAllUserGroups(QueryParamHelper params, String username) { 20 Map<String, Object> paramsMap = new HashMap<>(); 21 if (params.hasPagination()) { 22 paramsMap.put("offset", params.getPagination().getOffset()); 23 paramsMap.put("size", params.getPagination().getSize()); 24 } 25 var query = String.format("MATCH %s WHERE %s WITH ug", 26 CypherQueryHelper.getObjectPart("ug", "UserGroup", false), 27 CypherQueryHelper.getReadableByQuery("ug", username)); 28 if (params.hasOrderByAttribute()) { 29 query += " " + CypherQueryHelper.getOrderByPart("ug", params.getOrderByAttribute(), params.getOrderDesc()); 30 } 31 if (params.hasPagination()) { 32 query += " " + CypherQueryHelper.getPaginationPart(); 33 } 34 query += " " + CypherQueryHelper.getReturnPart("ug"); 35 var result = new ArrayList<UserGroup>(); 36 for (var userGroup : findByQuery(query, paramsMap)) { 37 result.add(userGroup); 38 } 39 return result; 40 } 41 42 }