Skip to content

Commit

Permalink
Modified JSON Shallow Copier to return residency and membership
Browse files Browse the repository at this point in the history
information for an individual. This was missing and made census
individual appear to not be saving the information. Fixes #12
  • Loading branch information
littlefieldnick committed Sep 6, 2018
1 parent 580bc20 commit b34fc40
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions domain/src/main/java/org/openhds/domain/util/JsonShallowCopier.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public static Location copyLocation(Location loc) {
copy.setLocationName(loc.getLocationName());
copy.setLocationType(loc.getLocationType());
copy.setInsertDate(loc.getInsertDate());
// copy.setServerInsertTime(loc.getServerInsertTime());
// copy.setServerUpdateTime(loc.getServerUpdateTime());
copy.setServerInsertTime(loc.getServerInsertTime());
copy.setServerUpdateTime(loc.getServerUpdateTime());
FieldWorker fw = new FieldWorker();
fw.setExtId(loc.getCollectedBy().getExtId());
copy.setCollectedBy(fw);
Expand All @@ -59,29 +59,27 @@ public static Individual shallowCopyIndividual(Individual individual) {
Individual mother = shallowCopyIndividual(individual.getMother());
copy.setMother(mother);

// Leave commented out until memberships and residencies are implemented on Client Side
//
//
//
// if (individual.getCurrentMembership() != null /*&& individual.getCurrentMembership().getEndDate()==null*/) {
// Membership memCopy = new Membership();
// SocialGroup sgCopy = new SocialGroup();
// sgCopy.setExtId(individual.getCurrentMembership().getSocialGroup().getExtId());
//
// memCopy.setSocialGroup(sgCopy);
// memCopy.setbIsToA(individual.getCurrentMembership().getbIsToA());
// copy.getAllMemberships().add(memCopy);
// }
//
// if (individual.getCurrentResidency() != null) {
// Residency resCopy = new Residency();
// resCopy.setEndType(individual.getCurrentResidency().getEndType());
// Location locCopy = new Location();
// locCopy.setLocationLevel(null);
// locCopy.setExtId(individual.getCurrentResidency().getLocation().getExtId());
// resCopy.setLocation(locCopy);
// copy.getAllResidencies().add(resCopy);
// }


if (individual.getCurrentMembership() != null /*&& individual.getCurrentMembership().getEndDate()==null*/) {
Membership memCopy = new Membership();
SocialGroup sgCopy = new SocialGroup();
sgCopy.setExtId(individual.getCurrentMembership().getSocialGroup().getExtId());

memCopy.setSocialGroup(sgCopy);
memCopy.setbIsToA(individual.getCurrentMembership().getbIsToA());
copy.getAllMemberships().add(memCopy);
}

if (individual.getCurrentResidency() != null) {
Residency resCopy = new Residency();
resCopy.setEndType(individual.getCurrentResidency().getEndType());
Location locCopy = new Location();
locCopy.setLocationLevel(null);
locCopy.setExtId(individual.getCurrentResidency().getLocation().getExtId());
resCopy.setLocation(locCopy);
copy.getAllResidencies().add(resCopy);
}
} catch (Exception e) {
System.out.println(copy.getExtId());
}
Expand Down

0 comments on commit b34fc40

Please sign in to comment.