MIFOSX-1775 Adding validation to not allow edit meeting date at group level,if meeting is created by center.
This commit is contained in:
+1
@@ -1336,6 +1336,7 @@ public class CommandWrapperBuilder {
|
|||||||
this.actionName = "UPDATE";
|
this.actionName = "UPDATE";
|
||||||
this.entityName = "CALENDAR";
|
this.entityName = "CALENDAR";
|
||||||
this.entityId = calendarId;
|
this.entityId = calendarId;
|
||||||
|
this.groupId = supportedEntityId;
|
||||||
this.href = "/" + supportedEntityType + "/" + supportedEntityId + "/calendars/" + calendarId;
|
this.href = "/" + supportedEntityType + "/" + supportedEntityId + "/calendars/" + calendarId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
+42
-1
@@ -153,13 +153,54 @@ public class CalendarWritePlatformServiceJpaRepositoryImpl implements CalendarWr
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void validateIsEditMeetingAllowed(Long groupId) {
|
||||||
|
|
||||||
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||||
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(
|
||||||
|
dataValidationErrors).resource("calendar");
|
||||||
|
Group centerOrGroup = null;
|
||||||
|
|
||||||
|
if (groupId != null) {
|
||||||
|
centerOrGroup = this.groupRepository
|
||||||
|
.findOneWithNotFoundDetection(groupId);
|
||||||
|
final Group parent = centerOrGroup.getParent();
|
||||||
|
/* Check if it is a Group and belongs to a center */
|
||||||
|
if (centerOrGroup.isGroup() && parent != null) {
|
||||||
|
|
||||||
|
Integer centerEntityTypeId = CalendarEntityType.CENTERS
|
||||||
|
.getValue();
|
||||||
|
/* Check if calendar is created at center */
|
||||||
|
final CalendarInstance collectionCalendarInstance = this.calendarInstanceRepository
|
||||||
|
.findByEntityIdAndEntityTypeIdAndCalendarTypeId(
|
||||||
|
parent.getId(), centerEntityTypeId,
|
||||||
|
CalendarType.COLLECTION.getValue());
|
||||||
|
/* If calendar is created by parent group, then it cannot be edited by the child group */
|
||||||
|
if (collectionCalendarInstance != null) {
|
||||||
|
final String errorMessage = "meeting.created.at.center.cannot.be.edited.at.group.level";
|
||||||
|
baseDataValidator.reset()
|
||||||
|
.failWithCodeNoParameterAddedToErrorCode(
|
||||||
|
errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!dataValidationErrors.isEmpty()) {
|
||||||
|
throw new PlatformApiDataValidationException(
|
||||||
|
"validation.msg.validation.errors.exist",
|
||||||
|
"Validation errors exist.", dataValidationErrors);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult updateCalendar(final JsonCommand command) {
|
public CommandProcessingResult updateCalendar(final JsonCommand command) {
|
||||||
|
|
||||||
|
/** Validate to check if Edit is Allowed **/
|
||||||
|
this.validateIsEditMeetingAllowed(command.getGroupId());
|
||||||
/*
|
/*
|
||||||
* Validate all the data for updating the calendar
|
* Validate all the data for updating the calendar
|
||||||
*/
|
*/
|
||||||
|
|
||||||
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
||||||
|
|
||||||
Boolean areActiveEntitiesSynced = false;
|
Boolean areActiveEntitiesSynced = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user