<commit_before>package ch.openech.client.ewk.event.moveIn;

import ch.openech.client.ewk.event.moveIn.MoveInWizard.MoveInNextPerson;
import ch.openech.dm.code.TypeOfRelationship;
import ch.openech.dm.person.Person;
import ch.openech.dm.person.Relation;
import ch.openech.mj.util.BusinessRule;

public class NextPersonHelper {

	@BusinessRule("Beim Zuzug werden bei Eingabe einer weiteren Person Daten von den früheren Personen übernommen (Partner)")
	public static Person createNextPersonPartner(Person partner, boolean married) {
		Person nextPerson = new Person();
		Relation relation = new Relation();
		Relation relation2 = new Relation();
	
		if (married) {
			nextPerson.personIdentification.officialName = partner.personIdentification.officialName;
			boolean partnerIsMale = "1".equals(partner.personIdentification.sex);
			nextPerson.personIdentification.sex = partnerIsMale ? "2" : "1";
			relation.typeOfRelationship = relation2.typeOfRelationship = "1";
		} else {
			nextPerson.alliancePartnershipName = partner.alliancePartnershipName;
			nextPerson.personIdentification.sex = partner.personIdentification.sex;
			relation.typeOfRelationship = relation2.typeOfRelationship = "2";
		}
		nextPerson.maritalStatus.maritalStatus = partner.maritalStatus.maritalStatus;
		nextPerson.religion = partner.religion;
		nextPerson.typeOfResidence = partner.typeOfResidence;
		nextPerson.residence.reportingMunicipality = partner.residence.reportingMunicipality;
		nextPerson.residence.setSecondary(partner.residence.secondary);
		nextPerson.arrivalDate = partner.arrivalDate;
		nextPerson.comesFrom = partner.comesFrom;
		nextPerson.dwellingAddress = partner.dwellingAddress;
	
		// Folgendes würde nichts nützen, da das Panel später vor dem
		// Speichern ein anderes Objekt zurückgibt
		// relation.partner = person;
		partner.relation.add(relation);
	
		relation2.partner = partner.personIdentification;
		nextPerson.relation.add(relation2);
		return nextPerson;
	}

	@BusinessRule("Beim Zuzug werden bei Eingabe einer weiteren Person Daten von den früheren Personen übernommen (Kind)")
	public static Person createNextPersonChild(MoveInNextPerson moveInNextPerson) {
		Person child = new Person();
		Person basePerson = moveInNextPerson.basePerson;

		child.personIdentification.officialName = basePerson.personIdentification.officialName;
		child.religion = basePerson.religion;
		child.typeOfResidence = basePerson.typeOfResidence;
		child.residence.reportingMunicipality = basePerson.residence.reportingMunicipality;
		child.residence.setSecondary(basePerson.residence.secondary);<commit_msg>MoveInWizard: Gegenseitige Beziehung bei verheirateten Personen wieder aktiviert<commit_after>package ch.openech.client.ewk.event.moveIn;

import ch.openech.client.ewk.event.moveIn.MoveInWizard.MoveInNextPerson;
import ch.openech.dm.code.TypeOfRelationship;
import ch.openech.dm.person.Person;
import ch.openech.dm.person.Relation;
import ch.openech.mj.util.BusinessRule;

public class NextPersonHelper {

	@BusinessRule("Beim Zuzug werden bei Eingabe einer weiteren Person Daten von den früheren Personen übernommen (Partner)")
	public static Person createNextPersonPartner(Person partner, boolean married) {
		Person nextPerson = new Person();
		Relation relation = new Relation();
		Relation relation2 = new Relation();
	
		if (married) {
			nextPerson.personIdentification.officialName = partner.personIdentification.officialName;
			boolean partnerIsMale = "1".equals(partner.personIdentification.sex);
			nextPerson.personIdentification.sex = partnerIsMale ? "2" : "1";
			relation.typeOfRelationship = relation2.typeOfRelationship = "1";
		} else {
			nextPerson.alliancePartnershipName = partner.alliancePartnershipName;
			nextPerson.personIdentification.sex = partner.personIdentification.sex;
			relation.typeOfRelationship = relation2.typeOfRelationship = "2";
		}
		nextPerson.maritalStatus.maritalStatus = partner.maritalStatus.maritalStatus;
		nextPerson.religion = partner.religion;
		nextPerson.typeOfResidence = partner.typeOfResidence;
		nextPerson.residence.reportingMunicipality = partner.residence.reportingMunicipality;
		nextPerson.residence.setSecondary(partner.residence.secondary);
		nextPerson.arrivalDate = partner.arrivalDate;
		nextPerson.comesFrom = partner.comesFrom;
		nextPerson.dwellingAddress = partner.dwellingAddress;
	
		relation.partner = nextPerson.personIdentification;
		partner.relation.add(relation);
	
		relation2.partner = partner.personIdentification;
		nextPerson.relation.add(relation2);
		return nextPerson;
	}

	@BusinessRule("Beim Zuzug werden bei Eingabe einer weiteren Person Daten von den früheren Personen übernommen (Kind)")
	public static Person createNextPersonChild(MoveInNextPerson moveInNextPerson) {
		Person child = new Person();
		Person basePerson = moveInNextPerson.basePerson;

		child.personIdentification.officialName = basePerson.personIdentification.officialName;
		child.religion = basePerson.religion;
		child.typeOfResidence = basePerson.typeOfResidence;
		child.residence.reportingMunicipality = basePerson.residence.reportingMunicipality;
		child.residence.setSecondary(basePerson.residence.secondary);
{'fraction_non_alphanumeric': 0.08587417985333848, 'fraction_numerical': 0.0038595137012736396, 'mean_word_length': 6.070941336971351, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '536414', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1542, 'n_words': 281}