protected List<String> getChartCodes(Collection<Chart> charts) { List<String> chartCodes = new ArrayList<String>(charts.size()); for (Chart chart : charts) { chartCodes.add(chart.getChartOfAccountsCode()); } return chartCodes; }
/** @see org.kuali.module.chart.service.getReportsToHierarchy() */ @Override @Cacheable(value = Chart.CACHE_NAME, key = "'ReportsToHierarchy'") public Map<String, String> getReportsToHierarchy() { Map<String, String> reportsToHierarchy = new HashMap<String, String>(); for (String chartCode : getAllChartCodes()) { Chart chart = businessObjectService.findBySinglePrimaryKey(Chart.class, chartCode); if (LOG.isDebugEnabled()) { LOG.debug( "adding " + chart.getChartOfAccountsCode() + "-->" + chart.getReportsToChartOfAccountsCode()); } reportsToHierarchy.put( chart.getChartOfAccountsCode(), chart.getReportsToChartOfAccountsCode()); } return reportsToHierarchy; }
@Override @Cacheable(value = Chart.CACHE_NAME, key = "'{isParentChart?}'+#p0+'-->'+#p1") public boolean isParentChart(String potentialChildChartCode, String potentialParentChartCode) { if ((potentialChildChartCode == null) || (potentialParentChartCode == null)) { throw new IllegalArgumentException( "The isParentChartCode method requires a non-null potentialChildChartCode and potentialParentChartCode"); } Chart thisChart = getByPrimaryId(potentialChildChartCode); if ((thisChart == null) || StringUtils.isBlank(thisChart.getChartOfAccountsCode())) { throw new IllegalArgumentException( "The isParentChartCode method requires a valid potentialChildChartCode"); } if (thisChart.getCode().equals(thisChart.getReportsToChartOfAccountsCode())) { return false; } else if (potentialParentChartCode.equals(thisChart.getReportsToChartOfAccountsCode())) { return true; } else { return isParentChart(thisChart.getReportsToChartOfAccountsCode(), potentialParentChartCode); } }