AnalyticsUtils { public static boolean periodIsOutsideApprovalMaxYears( Integer year, Integer maxYears ) { if ( maxYears == 0 ) { return false; } int currentYear = new DateTime().getYear(); return ( currentYear - year ) >= maxYears; }  static String getDebugDataSql( DataQueryParams params ); static List<DimensionalItemObject> getByDataDimensionItemType( DataDimensionItemType itemType, List<DimensionalItemObject> dataDimensionOptions ); static Number getRoundedValue( DataQueryParams params, Integer decimals, Double value ); static Object getRoundedValueObject( DataQueryParams params, Object value ); static ColumnDataType getColumnType( ValueType valueType, boolean spatialSupport ); static Map<String, T> convertDxToOperand( Map<String, T> valueMap, TotalType totalType ); static Map<String, Double> getDoubleMap( Map<String, Object> map ); static Map<String, Object> getAggregatedDataValueMapping( Grid grid ); static DataValueSet getDataValueSetFromGrid( DataQueryParams params, Grid grid ); static void handleGridForDataValueSet( DataQueryParams params, Grid grid ); static Object getIntegerOrValue( Object value, DimensionalItemObject item ); static Map<String, DimensionalItemObject> getDimensionalItemObjectMap( DataQueryParams params ); static Map<String, String> getDimensionItemNameMap( DataQueryParams params ); static Map<String, MetadataItem> getDimensionMetadataItemMap( DataQueryParams params ); static Map<String, String> getCocNameMap( DataQueryParams params ); static Map<String, String> getUidDisplayPropertyMap( List<QueryItem> queryItems, DisplayProperty displayProperty ); static Map<String, String> getUidDisplayPropertyMap( List<DimensionalObject> dimensions, boolean hierarchyMeta, DisplayProperty displayProperty ); static boolean periodIsOutsideApprovalMaxYears( Integer year, Integer maxYears ); static int getLevelFromOrgUnitDimensionName( String dimensionName ); static boolean isTableLayout( List<String> columns, List<String> rows ); static Double calculateYearlyWeightedAverage( Double year1Value, Double year2Value, Double factor ); static Double getBaseMonth( PeriodType periodType ); static void throwIllegalQueryEx( ErrorCode errorCode, Object... args ); static boolean isPeriodInPeriods( String period, List<DimensionalItemObject> periods ); static List<DimensionalItemObject> findDimensionalItems( String dimensionIdentifier,
        List<DimensionalItemObject> items ); static boolean hasPeriod( List<Object> row, int periodIndex ); static final String ERR_MSG_TABLE_NOT_EXISTING; }
@Test public void testIsPeriodOverApprovalThreshold() { java.util.Calendar calendar = java.util.Calendar.getInstance(); int currentYear = calendar.get( Calendar.YEAR ); Integer thisYear = currentYear; Integer oneYearAgo = currentYear - 1; Integer twoYearsAgo = currentYear - 2; Integer threeYearsAgo = currentYear - 3; assertTrue( !AnalyticsUtils.periodIsOutsideApprovalMaxYears( thisYear, 0 ) ); assertTrue( !AnalyticsUtils.periodIsOutsideApprovalMaxYears( oneYearAgo, 0 ) ); assertTrue( !AnalyticsUtils.periodIsOutsideApprovalMaxYears( twoYearsAgo, 0 ) ); assertTrue( !AnalyticsUtils.periodIsOutsideApprovalMaxYears( threeYearsAgo, 0 ) ); assertTrue( !AnalyticsUtils.periodIsOutsideApprovalMaxYears( thisYear, 1 ) ); assertTrue( AnalyticsUtils.periodIsOutsideApprovalMaxYears( oneYearAgo, 1 ) ); assertTrue( AnalyticsUtils.periodIsOutsideApprovalMaxYears( twoYearsAgo, 1 ) ); assertTrue( AnalyticsUtils.periodIsOutsideApprovalMaxYears( threeYearsAgo, 1 ) ); assertTrue( !AnalyticsUtils.periodIsOutsideApprovalMaxYears( thisYear, 5 ) ); assertTrue( !AnalyticsUtils.periodIsOutsideApprovalMaxYears( oneYearAgo, 5 ) ); assertTrue( !AnalyticsUtils.periodIsOutsideApprovalMaxYears( twoYearsAgo, 5 ) ); assertTrue( !AnalyticsUtils.periodIsOutsideApprovalMaxYears( threeYearsAgo, 5 ) ); }