@Test public void testPattern() { String pattern; pattern = "0 5 * * *|8 10 * * *|22 17 * * *"; assertTrue(pattern + "is correct", SchedulingPattern.validate(pattern)); pattern = "0 5 * * *"; assertTrue(pattern + "is correct", SchedulingPattern.validate(pattern)); }
/** * Before Save * * @param newRecord new * @return true */ @Override protected boolean beforeSave(boolean newRecord) { // Set Schedule Type & Frequencies if (SCHEDULETYPE_Frequency.equals(getScheduleType())) { if (getFrequencyType() == null) setFrequencyType(FREQUENCYTYPE_Day); if (getFrequency() < 1) setFrequency(1); setCronPattern(null); } else if (SCHEDULETYPE_CronSchedulingPattern.equals(getScheduleType())) { String pattern = getCronPattern(); if (pattern != null && pattern.trim().length() > 0) { if (!SchedulingPattern.validate(pattern)) { throw new AdempiereException("@InvalidCronPattern@"); } } } return true; } // beforeSave