FolderServerGroup findGroupByName(String groupName) {
   String cypher = CypherQueryBuilder.getGroupByName();
   Map<String, Object> params = CypherParamBuilder.getGroupByName(groupName);
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode groupNode = jsonNode.at("/results/0/data/0/row/0");
   return buildGroup(groupNode);
 }
 @RequestMapping(value = "/findExternalIdForStudy/{studyTitle}", method = RequestMethod.GET)
 @ResponseBody
 public CypherQuery findExternalIdForStudyNew(
     HttpServletRequest request, @PathVariable("studyTitle") final String studyTitle)
     throws IOException {
   CypherQuery cypherQuery = CypherQueryBuilder.externalIdForStudy(studyTitle);
   return CypherQueryBuilder.createPagedQuery(request, cypherQuery);
 }
 @RequestMapping(value = "/findExternalIdForTaxon/{taxonName}", method = RequestMethod.GET)
 @ResponseBody
 public CypherQuery findExternalIdForTaxonNew(
     HttpServletRequest request, @PathVariable("taxonName") final String taxonName)
     throws IOException {
   CypherQuery cypherQuery = CypherQueryBuilder.externalIdForTaxon(taxonName);
   return CypherQueryBuilder.createPagedQuery(request, cypherQuery);
 }
 @RequestMapping(
     value = "/shortestPathsBetweenTaxon/{startTaxon}/andTaxon/{endTaxon}",
     method = RequestMethod.GET)
 @ResponseBody
 public CypherQuery findShortestPathsNew(
     HttpServletRequest request,
     @PathVariable("startTaxon") final String startTaxon,
     @PathVariable("endTaxon") final String endTaxon)
     throws IOException {
   CypherQuery cypherQuery = CypherQueryBuilder.shortestPathQuery(startTaxon, endTaxon);
   return CypherQueryBuilder.createPagedQuery(request, cypherQuery);
 }
 FolderServerGroup updateGroupById(
     String groupId, Map<String, String> updateFields, String updatedBy) {
   String cypher = CypherQueryBuilder.updateGroupById(updateFields);
   Map<String, Object> params =
       CypherParamBuilder.updateGroupById(groupId, updateFields, updatedBy);
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode updatedNode = jsonNode.at("/results/0/data/0/row/0");
   return buildGroup(updatedNode);
 }
 boolean deleteGroupById(String groupURL) {
   String cypher = CypherQueryBuilder.deleteGroupById();
   Map<String, Object> params = CypherParamBuilder.deleteGroupById(groupURL);
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode errorsNode = jsonNode.at("/errors");
   if (errorsNode.size() != 0) {
     JsonNode error = errorsNode.path(0);
     log.warn("Error while deleting group:", error);
   }
   return errorsNode.size() == 0;
 }
 boolean removeRelation(FolderServerUser user, FolderServerGroup group, RelationLabel relation) {
   String cypher = CypherQueryBuilder.removeRelation(NodeLabel.USER, NodeLabel.GROUP, relation);
   Map<String, Object> params =
       CypherParamBuilder.matchFromNodeToNode(user.getId(), group.getId());
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode errorsNode = jsonNode.at("/errors");
   if (errorsNode.size() != 0) {
     JsonNode error = errorsNode.path(0);
     log.warn("Error while removing relation:", error);
   }
   return errorsNode.size() == 0;
 }
 FolderServerGroup createGroup(
     String groupURL,
     String name,
     String displayName,
     String description,
     String ownerURL,
     Map<String, Object> extraProperties) {
   String cypher = CypherQueryBuilder.createGroup(extraProperties);
   Map<String, Object> params =
       CypherParamBuilder.createGroup(
           groupURL, name, displayName, description, ownerURL, extraProperties);
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode groupNode = jsonNode.at("/results/0/data/0/row/0");
   return buildGroup(groupNode);
 }
 List<FolderServerGroup> findGroups() {
   List<FolderServerGroup> groupList = new ArrayList<>();
   String cypher = CypherQueryBuilder.findGroups();
   CypherQuery q = new CypherQueryLiteral(cypher);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode userListJsonNode = jsonNode.at("/results/0/data");
   if (userListJsonNode != null && !userListJsonNode.isMissingNode()) {
     userListJsonNode.forEach(
         f -> {
           JsonNode groupNode = f.at("/row/0");
           if (groupNode != null && !groupNode.isMissingNode()) {
             FolderServerGroup cg = buildGroup(groupNode);
             groupList.add(cg);
           }
         });
   }
   return groupList;
 }
 @RequestMapping(value = "/locations", method = RequestMethod.GET)
 @ResponseBody
 public CypherQuery locationsNew(HttpServletRequest request) throws IOException {
   return CypherQueryBuilder.locations(request == null ? null : request.getParameterMap());
 }
 List<FolderServerUser> findGroupMembers(String groupURL) {
   List<FolderServerUser> memberList = new ArrayList<>();
   String cypher = CypherQueryBuilder.getGroupUsersWithRelation(RelationLabel.MEMBEROF);
   Map<String, Object> params = CypherParamBuilder.matchGroupId(groupURL);
   CypherQuery q = new CypherQueryWithParameters(cypher, params);
   JsonNode jsonNode = executeCypherQueryAndCommit(q);
   JsonNode userListJsonNode = jsonNode.at("/results/0/data");
   if (userListJsonNode != null && !userListJsonNode.isMissingNode()) {
     userListJsonNode.forEach(
         f -> {
           JsonNode userNode = f.at("/row/0");
           if (userNode != null && !userNode.isMissingNode()) {
             FolderServerUser u = buildUser(userNode);
             memberList.add(u);
           }
         });
   }
   return memberList;
 }