use of gov.ca.cwds.data.persistence.ns.PersonLanguage in project API by ca-cwds.
the class PersonService method populatePersonDetails.
/**
*
* @param person - The person
* @param managedPerson - The managedPerson
*/
private void populatePersonDetails(Person person, gov.ca.cwds.data.persistence.ns.Person managedPerson) {
if (person.getAddress() != null && !person.getAddress().isEmpty()) {
for (Address address : person.getAddress()) {
gov.ca.cwds.data.persistence.ns.Address managedAddress = new gov.ca.cwds.data.persistence.ns.Address(address, null, null);
PersonAddress personAddress = new PersonAddress(managedPerson, managedAddress);
managedPerson.addPersonAddress(personAddress);
addressDao.create(managedAddress);
personAddressDao.create(personAddress);
}
}
if (person.getPhoneNumber() != null && !person.getPhoneNumber().isEmpty()) {
for (PhoneNumber phoneNumber : person.getPhoneNumber()) {
gov.ca.cwds.data.persistence.ns.PhoneNumber managedPhoneNumber = new gov.ca.cwds.data.persistence.ns.PhoneNumber(phoneNumber, null, null);
PersonPhone personPhone = new PersonPhone(managedPerson, managedPhoneNumber);
managedPerson.addPersonPhone(personPhone);
phoneNumberDao.create(managedPhoneNumber);
personPhoneDao.create(personPhone);
}
}
if (person.getLanguage() != null && !person.getLanguage().isEmpty()) {
for (Language language : person.getLanguage()) {
gov.ca.cwds.data.persistence.ns.Language managedLanguage = new gov.ca.cwds.data.persistence.ns.Language(language, null, null);
PersonLanguage personLanguage = new PersonLanguage(managedPerson, managedLanguage);
managedPerson.addPersonLanguage(personLanguage);
languageDao.create(managedLanguage);
personLanguageDao.create(personLanguage);
}
}
if (person.getRace() != null && !person.getRace().isEmpty()) {
for (Race race : person.getRace()) {
gov.ca.cwds.data.persistence.ns.Race managedRace = new gov.ca.cwds.data.persistence.ns.Race(race, null, null);
PersonRace personRace = new PersonRace(managedPerson, managedRace);
managedPerson.addPersonRace(personRace);
raceDao.create(managedRace);
personRaceDao.create(personRace);
}
}
if (person.getEthnicity() != null && !person.getEthnicity().isEmpty()) {
for (Ethnicity ethnicity : person.getEthnicity()) {
gov.ca.cwds.data.persistence.ns.Ethnicity managedEthnicity = new gov.ca.cwds.data.persistence.ns.Ethnicity(ethnicity, null, null);
PersonEthnicity personEthnicity = new PersonEthnicity(managedPerson, managedEthnicity);
managedPerson.addPersonEthnicity(personEthnicity);
ethnicityDao.create(managedEthnicity);
personEthnicityDao.create(personEthnicity);
}
}
}
Aggregations