question: public boolean isReferenceBudget ( final Budget budget ) { boolean isReference = false ; if ( budget == null ) { isReference = false ; return isReference ; } final String mPath = budget . getMaterializedPath ( ) ; if ( LOGGER . isInfoEnabled ( ) ) LOGGER . info ( "meterialized path for the Budget" + mPath ) ; if ( mPath == null || mPath . isEmpty ( ) ) throw new ApplicationRuntimeException ( "Materialized path is not set for the Budget " + budget . getName ( ) ) ; else if ( budget . getIsPrimaryBudget ( ) && budget . getIsActiveBudget ( ) ) { isReference = false ; return isReference ; } else { final int start = mPath . indexOf ( '.' ) ; if ( start != - 1 ) { final String rootPath = mPath . substring ( 0 , start ) ; if ( LOGGER . isInfoEnabled ( ) ) LOGGER . info ( "meterialized path for root the Budget" + "   " + rootPath ) ; final Budget rootBudget = budgetService . find ( "from Budget where materializedPath=?" , rootPath ) ; if ( rootBudget == null ) throw new ApplicationRuntimeException ( "Materialized path is incorrect please verify for " + rootPath ) ; else if ( rootBudget . getIsPrimaryBudget ( ) && rootBudget . getIsActiveBudget ( ) ) isReference = false ; else isReference = true ; } else isReference = true ; } return isReference ; }
target:  reference Budget is one which exists in the system but wont be having active and primary budget as parent it is used for reference . These should be filtered for approval life cycle