/** * @see FolderRepositoryCustom#getProcessModelVersionByFolderUserRecursive(Integer, String) * {@inheritDoc} */ @Override public List<ProcessModelVersion> getProcessModelVersionByFolderUserRecursive( Integer parentFolderId, String userId) { List<ProcessModelVersion> processes = new ArrayList<>(); processes.addAll( getProcessModelVersions( groupProcessRepository.findAllProcessesInFolderForUser(parentFolderId, userId))); for (GroupFolder folder : groupFolderRepository.findByParentFolderAndUser(parentFolderId, userId)) { processes.addAll( getProcessModelVersionByFolderUserRecursive(folder.getFolder().getId(), userId)); } return processes; }
/** @see FolderRepositoryCustom#getFolderTreeByUser(int, String) {@inheritDoc} */ @Override public List<FolderTreeNode> getFolderTreeByUser(int parentFolderId, String userId) { List<GroupFolder> folders = groupFolderRepository.findByParentFolderAndUser(parentFolderId, userId); Map<Integer, FolderTreeNode> map = new HashMap<>(); List<FolderTreeNode> treeNodes = new ArrayList<>(); for (GroupFolder folder : folders) { if (map.containsKey(folder.getFolder().getId())) { // This is not the first group granting folder access to the user, so just merge in // additional permissions FolderTreeNode treeNode = map.get(folder.getFolder().getId()); treeNode.setHasRead(treeNode.getHasRead() || folder.isHasRead()); treeNode.setHasWrite(treeNode.getHasWrite() || folder.isHasWrite()); treeNode.setHasOwnership(treeNode.getHasOwnership() || folder.isHasOwnership()); } else { // This is the first group granting folder access to the user, so add the folder to the tree FolderTreeNode treeNode = new FolderTreeNode(); map.put(folder.getFolder().getId(), treeNode); treeNode.setId(folder.getFolder().getId()); treeNode.setName(folder.getFolder().getName()); treeNode.setHasRead(folder.isHasRead()); treeNode.setHasWrite(folder.isHasWrite()); treeNode.setHasOwnership(folder.isHasOwnership()); treeNode.setSubFolders(this.getFolderTreeByUser(folder.getFolder().getId(), userId)); for (FolderTreeNode subFolders : treeNode.getSubFolders()) { subFolders.setParent(treeNode); } treeNodes.add(treeNode); } } return treeNodes; }