wip:MIFOSX-244 Adding Calendar RecurringRule
This commit is contained in:
@@ -155,6 +155,7 @@ dependencies {
|
||||
|
||||
[group: 'com.lowagie', name: 'itext', version: '2.1.7'],
|
||||
[group: 'com.lowagie', name: 'itext-rtf', version: '2.1.7'],
|
||||
[group: 'org.mnode.ical4j', name: 'ical4j', version: '1.0.4'],
|
||||
)
|
||||
|
||||
testCompile 'junit:junit:4.10',
|
||||
|
||||
+22
@@ -6,8 +6,12 @@
|
||||
package org.mifosplatform.infrastructure.core.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
import net.fortuna.ical4j.model.ValidationException;
|
||||
import net.fortuna.ical4j.model.property.RRule;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -360,4 +364,22 @@ public class DataValidatorBuilder {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataValidatorBuilder isValidateRecurringRule(final String recurringRule){
|
||||
if(StringUtils.isNotBlank(recurringRule)){
|
||||
try {
|
||||
RRule rRule = new RRule(recurringRule);
|
||||
rRule.validate();
|
||||
} catch (ValidationException e) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.recurring.rule", "The Recurring Rule value: " + recurringRule + " is not valid.", parameter, recurringRule );
|
||||
dataValidationErrors.add(error);
|
||||
return this;
|
||||
} catch (ParseException e) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.recurring.rule", "The Recurring Rule value: " + recurringRule + " is not valid.", parameter, recurringRule );
|
||||
dataValidationErrors.add(error);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -82,9 +82,12 @@ public class CalendarsApiResource {
|
||||
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
final Integer entityTypeId = CalendarEntityType.valueOf(entityType.toUpperCase()).getValue();
|
||||
final CalendarData calendar = this.readPlatformService.retrieveCalendar(calendarId, entityId, entityTypeId);
|
||||
CalendarData calendar = this.readPlatformService.retrieveCalendar(calendarId, entityId, entityTypeId);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
if(settings.isTemplate()){
|
||||
calendar = handleTemplate(calendar);
|
||||
}
|
||||
return this.toApiJsonSerializer.serialize(settings, calendar, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
|
||||
+13
-10
@@ -138,12 +138,14 @@ public class CalendarCommandFromApiJsonDeserializer extends AbstractFromApiJsonD
|
||||
final boolean repeating = this.fromApiJsonHelper.extractBooleanNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue(),
|
||||
element);
|
||||
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue()).value(repeating).notNull();
|
||||
|
||||
if(repeating){
|
||||
final String recurrence = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.RECURRENCE.getValue(), element);
|
||||
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.RECURRENCE.getValue()).value(recurrence).notNull()
|
||||
.notExceedingLengthOf(100).isValidateRecurringRule(recurrence);
|
||||
}
|
||||
}
|
||||
|
||||
final String recurrence = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.RECURRENCE.getValue(), element);
|
||||
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.RECURRENCE.getValue()).value(recurrence).notNull()
|
||||
.notExceedingLengthOf(100);
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue(), element)) {
|
||||
final Integer remindById = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
||||
CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue(), element);
|
||||
@@ -229,13 +231,14 @@ public class CalendarCommandFromApiJsonDeserializer extends AbstractFromApiJsonD
|
||||
final boolean repeating = this.fromApiJsonHelper.extractBooleanNamed(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue(),
|
||||
element);
|
||||
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.REPEATING.getValue()).value(repeating).notNull();
|
||||
|
||||
if(repeating){
|
||||
final String recurrence = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.RECURRENCE.getValue(), element);
|
||||
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.RECURRENCE.getValue()).value(recurrence).notNull()
|
||||
.notExceedingLengthOf(100).isValidateRecurringRule(recurrence);
|
||||
}
|
||||
}
|
||||
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.RECURRENCE.getValue(), element)) {
|
||||
final String recurrence = this.fromApiJsonHelper.extractStringNamed(CALENDAR_SUPPORTED_PARAMETERS.RECURRENCE.getValue(),
|
||||
element);
|
||||
baseDataValidator.reset().parameter(CALENDAR_SUPPORTED_PARAMETERS.RECURRENCE.getValue()).value(recurrence).notNull()
|
||||
.notExceedingLengthOf(100);
|
||||
}
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue(), element)) {
|
||||
final Integer remindById = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
||||
CALENDAR_SUPPORTED_PARAMETERS.REMIND_BY_ID.getValue(), element);
|
||||
|
||||
+2
-1
@@ -60,7 +60,8 @@ public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformServ
|
||||
final boolean repeating = rs.getBoolean("repeating");
|
||||
final String recurrence = rs.getString("recurrence");
|
||||
final Integer remindById = rs.getInt("remindById");
|
||||
final EnumOptionData remindBy = CalendarEnumerations.calendarRemindBy(remindById);
|
||||
EnumOptionData remindBy = null;
|
||||
if(remindById != null) remindBy = CalendarEnumerations.calendarRemindBy(remindById);
|
||||
final Integer firstReminder = rs.getInt("firstReminder");
|
||||
final Integer secondReminder = rs.getInt("secondReminder");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user