/** Helper method to cascade person to health profile */ private static Person cascadeHealthProfile(Person p) { // Get current timestamp java.util.Date date = new java.util.Date(); // For each health profile measure: set person id and current timestamp for (HealthProfile healthProfile : p.healthProfile) { healthProfile.setPerson(p); healthProfile.setCreated(date); } return p; }
private static Person copyHealthProfileToHistory(Person p) { // Create new history list List<HealthProfileHistory> history = new ArrayList<HealthProfileHistory>(); for (HealthProfile healthProfile : p.healthProfile) { // Create new history object HealthProfileHistory h = new HealthProfileHistory(); h.setMeasureType(healthProfile.getMeasureType()); h.setMeasureValue(healthProfile.getMeasureValue()); h.setPerson(p); h.setTimestamp(healthProfile.getTimestamp()); // Add to history list history.add(h); } p.setHealthProfileHistory(history); return p; }