public static ArrayList < ArrayList < HashMap < String , String > > > getAutoEventDate ( Map data ) { ArrayList < ArrayList < HashMap < String , String > > > results = new ArrayList < ArrayList < HashMap < String , String > > > ( ) ; // Get Experiment duration int expDur ; try { expDur = Integer . parseInt ( getValueOr ( data , "exp_dur" , "1" ) ) ; } catch ( Exception e ) { expDur = 1 ; } // If no more planting event is required if ( expDur <= 1 ) { LOG . warn ( "Experiment duration is not more than 1, AUTO_REPLICATE_EVENTS won't be applied." ) ; return results ; } // Get Event date ArrayList < HashMap < String , String > > events = MapUtil . getBucket ( data , "management" ) . getDataList ( ) ; while ( results . size ( ) < expDur ) { results . add ( new ArrayList ( ) ) ; } for ( HashMap < String , String > event : events ) { String date = getValueOr ( event , "date" , "" ) ; if ( date . equals ( "" ) ) { String eventType = getValueOr ( event , "event" , "unknown" ) ; LOG . warn ( "Original {} event has an invalid date: [{}]." , eventType , date ) ; } String edate = getValueOr ( event , "edate" , "" ) ; for ( int j = 0 ; j < expDur ; j ++ ) { HashMap < String , String > newEvent = new HashMap ( ) ; newEvent . putAll ( event ) ; if ( ! date . equals ( "" ) ) { newEvent . put ( "date" , yearOffset ( date , j + "" ) ) ; } if ( ! edate . equals ( "" ) ) { newEvent . put ( "edate" , yearOffset ( edate , j + "" ) ) ; } results . get ( j ) . add ( newEvent ) ; } } return results ; }
This function will clone the original management events for each year in the experiment duration . Only the date of each event will be increased year by year . If experiment duration is no longer than 1 year no generation will be executed .