@@ -72,34 +72,36 @@ public static void loadConfig(String yamlPath){
7272 Yaml yaml = new Yaml ();
7373 HOLDER .scheduleConfig = yaml .loadAs (inputStream , ScheduleConfig .class );
7474
75- //BitSet setup for times we want to compress into
76- EnumSet <Days > MTWRF = EnumSet .allOf (Days .class );
77- DateTimeFormatter formatter = DateTimeFormatter .ofPattern ("h:mma" );
78- LocalTime startTime = LocalTime .parse (HOLDER .scheduleConfig .compressStart , formatter );
79- LocalTime endTime = LocalTime .parse (HOLDER .scheduleConfig .compressEnd , formatter );
80- //normalize times
81- startTime = roundToNearestHalfHour (startTime );
82- endTime = roundToNearestHalfHour (endTime );
83- if (startTime .isAfter (endTime )){
84- LOGGER .error ("The start time for the compressed start is after the end time; Exiting program" );
85- System .exit (1 );
75+ if (HOLDER .scheduleConfig .compressStart != null && HOLDER .scheduleConfig .compressEnd != null ) {//BitSet setup for times we want to compress into
76+ EnumSet <Days > MTWRF = EnumSet .allOf (Days .class );
77+ DateTimeFormatter formatter = DateTimeFormatter .ofPattern ("h:mma" );
78+ LocalTime startTime = LocalTime .parse (HOLDER .scheduleConfig .compressStart , formatter );
79+ LocalTime endTime = LocalTime .parse (HOLDER .scheduleConfig .compressEnd , formatter );
80+ //normalize times
81+ startTime = roundToNearestHalfHour (startTime );
82+ endTime = roundToNearestHalfHour (endTime );
83+ if (startTime .isAfter (endTime )) {
84+ LOGGER .error ("The start time for the compressed start is after the end time; Exiting program" );
85+ System .exit (1 );
86+ }
87+ //get number of 30 minute blocks
88+ long numBlcks = Duration .between (startTime , endTime ).toMinutes () / 30 ;
89+ final int bsSizeRep = 150 ;
90+ BitSet buildCmprsIn = new BitSet (bsSizeRep );
91+ buildCmprsIn .or (BitSetHelper .timeSlotBitSet (startTime , (int ) numBlcks , MTWRF ));
92+ BitSet buildCmprsOut = (BitSet ) buildCmprsIn .clone ();
93+ buildCmprsOut .flip (0 , bsSizeRep );
94+
95+ HOLDER .scheduleConfig .cpmrsInBs = buildCmprsIn ;
96+ HOLDER .scheduleConfig .cmprsOutBs = buildCmprsOut ;
8697 }
87- //get number of 30 minute blocks
88- long numBlcks = Duration .between (startTime ,endTime ).toMinutes () / 30 ;
89- final int bsSizeRep = 150 ;
90- BitSet buildCmprsIn = new BitSet (bsSizeRep );
91- buildCmprsIn .or (BitSetHelper .timeSlotBitSet (startTime , (int ) numBlcks , MTWRF ));
92- BitSet buildCmprsOut = (BitSet ) buildCmprsIn .clone ();
93- buildCmprsOut .flip (0 , bsSizeRep );
94-
95- HOLDER .scheduleConfig .cpmrsInBs = buildCmprsIn ;
96- HOLDER .scheduleConfig .cmprsOutBs = buildCmprsOut ;
9798 } catch (Exception e ){
9899 final int PROGRAM_FAILURE = 1 ;
99100 LOGGER .error ("Program is terminating. Couldn't read the yaml file" );
100101 LOGGER .error (String .format ("Program assumes yaml file is located at '%s' int the resources directory" ,
101102 yamlPath ));
102103 LOGGER .error (String .format ("Related error: %s" , e .getMessage ()));
104+ e .printStackTrace ();
103105 System .exit (PROGRAM_FAILURE );
104106 }
105107 }
0 commit comments