Merge pull request #1297 from chandrikamohith/1808
MIFOSX-1808 Group hierarchy updation issue corrected.Center summary is n...
This commit is contained in:
@@ -348,16 +348,24 @@ public final class Group extends AbstractPersistable<Long> {
|
||||
return this.clientMembers.contains(client);
|
||||
}
|
||||
|
||||
public void generateHierarchy() {
|
||||
if (this.parent != null) {
|
||||
this.hierarchy = this.parent.hierarchyOf(getId());
|
||||
} else {
|
||||
this.hierarchy = "." + getId() + ".";
|
||||
}
|
||||
}
|
||||
public void generateHierarchy() {
|
||||
if (this.parent != null) {
|
||||
this.hierarchy = this.parent.hierarchyOf(getId());
|
||||
} else {
|
||||
this.hierarchy = "." + getId() + ".";
|
||||
for (Group group : this.groupMembers) {
|
||||
group.setParent(this);
|
||||
group.generateHierarchy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetHierarchy() {
|
||||
this.hierarchy = "." + this.getId();
|
||||
}
|
||||
|
||||
private String hierarchyOf(final Long id) {
|
||||
return this.hierarchy + id.toString() + ".";
|
||||
return this.hierarchy + id.toString() + ".";
|
||||
}
|
||||
|
||||
public boolean isOfficeIdentifiedBy(final Long officeId) {
|
||||
@@ -522,6 +530,8 @@ public final class Group extends AbstractPersistable<Long> {
|
||||
|
||||
this.groupMembers.add(group);
|
||||
differences.add(group.getId().toString());
|
||||
group.setParent(this);
|
||||
group.generateHierarchy();
|
||||
}
|
||||
|
||||
return differences;
|
||||
@@ -534,6 +544,7 @@ public final class Group extends AbstractPersistable<Long> {
|
||||
if (hasGroupAsMember(group)) {
|
||||
this.groupMembers.remove(group);
|
||||
differences.add(group.getId().toString());
|
||||
group.resetHierarchy();
|
||||
} else {
|
||||
throw new GroupNotExistsInCenterException(group.getId(), getId());
|
||||
}
|
||||
|
||||
+4
-3
@@ -184,9 +184,10 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
|
||||
}
|
||||
|
||||
// pre-save to generate id for use in group hierarchy
|
||||
this.groupRepository.save(newGroup);
|
||||
this.groupRepository.save(newGroup);
|
||||
|
||||
newGroup.generateHierarchy();
|
||||
/* Generate hierarchy for a new center/group and all the child groups if they exist */
|
||||
newGroup.generateHierarchy();
|
||||
|
||||
this.groupRepository.saveAndFlush(newGroup);
|
||||
newGroup.captureStaffHistoryDuringCenterCreation(staff, activationDate);
|
||||
@@ -756,12 +757,12 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
|
||||
public CommandProcessingResult associateGroupsToCenter(final Long centerId, final JsonCommand command) {
|
||||
|
||||
this.fromApiJsonDeserializer.validateForAssociateGroups(command.json());
|
||||
|
||||
final Group centerForUpdate = this.groupRepository.findOneWithNotFoundDetection(centerId);
|
||||
final Set<Group> groupMembers = assembleSetOfChildGroups(centerForUpdate.officeId(), command);
|
||||
checkGroupMembersMeetingSyncWithCenterMeeting(centerId, groupMembers);
|
||||
|
||||
final Map<String, Object> actualChanges = new HashMap<>();
|
||||
|
||||
final List<String> changes = centerForUpdate.associateGroups(groupMembers);
|
||||
if (!changes.isEmpty()) {
|
||||
actualChanges.put(GroupingTypesApiConstants.groupMembersParamName, changes);
|
||||
|
||||
Reference in New Issue
Block a user