Merge pull request #1287 from MithunKashyap/MIFOSX-1737_New

MIFOSX-1737 : Bug fix for center staff assignment history
This commit is contained in:
Vishwas Babu A J
2015-03-04 23:11:57 +05:30
2 changed files with 11 additions and 2 deletions
@@ -217,6 +217,10 @@ public final class Group extends AbstractPersistable<Long> {
final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
activate(currentUser, activationLocalDate, dataValidationErrors); activate(currentUser, activationLocalDate, dataValidationErrors);
if (this.isCenter() && this.hasStaff()) {
Staff staff = this.getStaff();
this.reassignStaff(staff, activationLocalDate);
}
throwExceptionIfErrors(dataValidationErrors); throwExceptionIfErrors(dataValidationErrors);
} }
@@ -492,6 +496,11 @@ public final class Group extends AbstractPersistable<Long> {
return this.groupMembers.contains(group); return this.groupMembers.contains(group);
} }
public boolean hasStaff() {
if (this.staff != null) { return true; }
return false;
}
public List<String> associateGroups(final Set<Group> groupMembersSet) { public List<String> associateGroups(final Set<Group> groupMembersSet) {
final List<String> differences = new ArrayList<>(); final List<String> differences = new ArrayList<>();
@@ -635,7 +644,7 @@ public final class Group extends AbstractPersistable<Long> {
} }
// StaffAssignmentHistory[during center creation] // StaffAssignmentHistory[during center creation]
public void caputreStaffHistoryDuringCenterCreation(final Staff newStaff, final LocalDate assignmentDate) { public void captureStaffHistoryDuringCenterCreation(final Staff newStaff, final LocalDate assignmentDate) {
if (this.isCenter() && this.isActive() && staff != null) { if (this.isCenter() && this.isActive() && staff != null) {
this.staff = newStaff; this.staff = newStaff;
final StaffAssignmentHistory staffAssignmentHistory = StaffAssignmentHistory.createNew(this, this.staff, assignmentDate); final StaffAssignmentHistory staffAssignmentHistory = StaffAssignmentHistory.createNew(this, this.staff, assignmentDate);
@@ -189,7 +189,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
newGroup.generateHierarchy(); newGroup.generateHierarchy();
this.groupRepository.saveAndFlush(newGroup); this.groupRepository.saveAndFlush(newGroup);
newGroup.caputreStaffHistoryDuringCenterCreation(staff, activationDate); newGroup.captureStaffHistoryDuringCenterCreation(staff, activationDate);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
.withOfficeId(groupOffice.getId()) // .withOfficeId(groupOffice.getId()) //