String text = jsonObject.getString("includeEvents");
if(text != null){
includeEvents = EVENT_CODES.getId(text);
if(includeEvents == -1)
throw new TranslatableJsonException("emport.error.invalid",
"includeEvents", text,
EVENT_CODES.getCodeList());
}
text = jsonObject.getString("dateRangeType");
if(text != null){
dateRangeType = DATE_RANGE_TYPES.getId(text);
if(dateRangeType == -1)
throw new TranslatableJsonException("emport.error.invalid",
"dateRangeType", text,
DATE_RANGE_TYPES.getCodeList());
}
if(dateRangeType == DATE_RANGE_TYPE_RELATIVE){
text = jsonObject.getString("relativeDateType");
if(text != null){
relativeDateType = DATE_RELATIVE_TYPES.getId(text);
if(relativeDateType == -1)
throw new TranslatableJsonException("emport.error.invalid",
"relativeDateType", text,
DATE_RELATIVE_TYPES.getCodeList());
}
if(relativeDateType == RELATIVE_DATE_TYPE_PREVIOUS ){
text = jsonObject.getString("previousPeriodType");
if(text != null){
previousPeriodType = Common.TIME_PERIOD_CODES.getId(text);
if(previousPeriodType == -1)
throw new TranslatableJsonException("emport.error.invalid",
"previousPeriodType", text,
Common.TIME_PERIOD_CODES.getCodeList());
previousPeriodCount = jsonObject.getInt("previousPeriods");
}
}else if(relativeDateType == RELATIVE_DATE_TYPE_PREVIOUS){
text = jsonObject.getString("pastPeriodType");
if(text != null){
pastPeriodType = Common.TIME_PERIOD_CODES.getId(text);
if(pastPeriodType == -1)
throw new TranslatableJsonException("emport.error.invalid",
"pastPeriodType", text,
Common.TIME_PERIOD_CODES.getCodeList());
pastPeriodCount = jsonObject.getInt("pastPeriods");
}
}
}else if(dateRangeType == DATE_RANGE_TYPE_SPECIFIC){
fromNone = jsonObject.getBoolean("fromInception");
if(!fromNone){
fromYear = jsonObject.getInt("fromYear");
fromMonth = jsonObject.getInt("fromMonth");
fromDay = jsonObject.getInt("fromDay");
fromHour = jsonObject.getInt("fromHour");
fromMinute = jsonObject.getInt("fromMinute");
}
toNone = jsonObject.getBoolean("toLatest");
if(!toNone){
toYear = jsonObject.getInt("toYear");
toMonth = jsonObject.getInt("toMonth");
toDay = jsonObject.getInt("toDay");
toHour = jsonObject.getInt("toHour");
toMinute = jsonObject.getInt("toMinute");
}
}
schedule = jsonObject.getBoolean("schedule");
if(schedule){
text = jsonObject.getString("schedulePeriod");
if(text != null){
schedulePeriod = SCHEDULE_CODES.getId(text);
if(schedulePeriod == -1)
throw new TranslatableJsonException("emport.error.invalid",
"schedulePeriod", text,
SCHEDULE_CODES.getCodeList());
if(schedulePeriod == SCHEDULE_CRON){
scheduleCron = jsonObject.getString("scheduleCron");
try {
new CronTimerTrigger(scheduleCron);
}catch (ParseException e) {
throw new TranslatableJsonException("emport.error.invalid",
"scheduleCron", scheduleCron,
"cron expressions");
}
}
}else{
throw new TranslatableJsonException("emport.error.invalid",
"schedulePeriod", "null",
SCHEDULE_CODES.getCodeList());
}
}
email = jsonObject.getBoolean("email");
if(email){
JsonArray recipientsArray = jsonObject.getJsonArray("recipients");
boolean add = true;
if(recipientsArray != null){
for(JsonValue jv : recipientsArray){
RecipientListEntryBean recipient = new RecipientListEntryBean();
reader.readInto(recipient, jv);
for(RecipientListEntryBean existing : recipients){
if(existing.equals(recipient)){
reader.readInto(existing, jv);
add = false;
break;
}
}
if(add){
recipients.add(recipient);
}else{
add = true;
}
}
}else{
throw new TranslatableJsonException("emport.error.invalid",
"recipients", "null",
"valid users, email addresses or mailing lists");
}
includeData = jsonObject.getBoolean("includeData");