private void prepareBranchTree(final TreeNode branchTreeNode) { // For each of building block type which can be coupled to branch. for (final BuildingBlockConstant buildingBlockType : BuildingBlockConstant.getAllSortedBuildingBlocksForBranchAssemblies()) { Collection<BuildingBlock> branchBuildBlocksByType = null; try { branchBuildBlocksByType = this.buildingBlockService.findBuildingBlocksbyBranchIdAndBuildingBlockType( getBranch().getId(), buildingBlockType); } catch (final ApplicationException ex) { log.info(ex.getMessage()); ViewExceptionHandler.handle(ex); } if ((branchBuildBlocksByType != null) && !branchBuildBlocksByType.isEmpty()) { final TreeNode buildingBlockTypeNode = new DefaultTreeNode(buildingBlockType.getLabel(), branchTreeNode); buildingBlockTypeNode.setExpanded(true); buildingBlockTypeNode.setSelectable(false); final List<BuildingBlock> sortedBuildingBlocks = new ArrayList<BuildingBlock>(branchBuildBlocksByType); Collections.sort( sortedBuildingBlocks, new BuildingBlockComparator(BuildingBlockComparator.NAME)); for (final BuildingBlock buildingBlock : sortedBuildingBlocks) { final BuildingBlockTreeNode buildingBlockTreeNode = new BuildingBlockTreeNode( buildingBlock.getName(), buildingBlock, buildingBlockTypeNode); buildingBlockTreeNode.setSelectable(false); } } } }
/** * This method is called on selection of node in branch tree. * * @param event node select event. */ public void onNodeSelect(final NodeSelectEvent event) { try { // Recursive check of selected. updateNodeForSelected(this.branchNameNode, event.getTreeNode()); if ((event.getTreeNode() != null) && (event.getTreeNode() instanceof BuildingBlockTreeNode)) { final BuildingBlockTreeNode treeNode = (BuildingBlockTreeNode) event.getTreeNode(); if (treeNode.getBuildingBlock() != null) { final BuildingBlock selectedBuildingBlock = treeNode.getBuildingBlock(); if (BuildingBlockConstant.FEE_TYPE.equals(selectedBuildingBlock.getType())) { final BranchAssembly branchAssembly = this.branchAssemblyService.findBranchAssemblyByBuildingBlockIdAndBranch( selectedBuildingBlock, getBranch()); this.branchFeeBean.setBranchAssembly(branchAssembly); this.branchFeeBean.setBuildingBlock(selectedBuildingBlock); this.branchFeeBean.setLoadBranchFeeTypesFromDB(true); this.branchFeeBean.setDisplayNewBranchFeeType(false); // NavigationHandler navigationHandler = // ViewUtil.getFacesContext().getApplication() // .getNavigationHandler(); // navigationHandler.handleNavigation(ViewUtil.getFacesContext(), // null, // ViewPathConstants.ORGANIZATION_BRANCH_FEE_TYPE_PERIODICAS); } else if (BuildingBlockConstant.EXPENSE_TYPE.equals(selectedBuildingBlock.getType())) { final BranchAssembly branchAssembly = this.branchAssemblyService.findBranchAssemblyByBuildingBlockIdAndBranch( selectedBuildingBlock, getBranch()); this.branchExpenseBean.setBranchAssembly(branchAssembly); this.branchExpenseBean.setBuildingBlock(selectedBuildingBlock); this.branchExpenseBean.setLoadBranchExpenseTypesFromDB(true); // NavigationHandler navigationHandler = // ViewUtil.getFacesContext().getApplication() // .getNavigationHandler(); // navigationHandler.handleNavigation(ViewUtil.getFacesContext(), // null, // ViewPathConstants.ORGANIZATION_BRANCH_EXPENSE_TYPE_PERIODICALS); } else if (BuildingBlockConstant.DEPARTMENT.equals(selectedBuildingBlock.getType())) { final BranchAssembly branchAssembly = this.branchAssemblyService.findBranchAssemblyByBuildingBlockIdAndBranch( selectedBuildingBlock, getBranch()); this.branchDepartmentBean.setBranchAssembly(branchAssembly); this.branchDepartmentBean.setBuildingBlock(selectedBuildingBlock); this.branchDepartmentBean.setLoadBranchFeeTypesFromDB(true); // NavigationHandler navigationHandler = // ViewUtil.getFacesContext().getApplication() // .getNavigationHandler(); // navigationHandler.handleNavigation(ViewUtil.getFacesContext(), // null, // ViewPathConstants.ORGANIZATION_BRANCH_DEPARTMENTS); } } } else { this.branchBean.setActiveTabIndex(0); this.viewContentHandlerBean.setCurrentViewContent( ViewContentConstant.ORGANIZATION_BRANCHES); this.branchBean.setViewOrNewAction(true); } } catch (final ApplicationException exception) { log.info(exception.getMessage()); ViewExceptionHandler.handle(exception); } }