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

import java.util.ArrayList;
import java.util.List;

import ch.openech.client.ewk.PersonPanel;
import ch.openech.client.ewk.PersonPanel.PersonPanelType;
import ch.openech.client.ewk.XmlEditor;
import ch.openech.client.ewk.event.EchFormPanel;
import ch.openech.dm.code.TypeOfRelationship;
import ch.openech.dm.code.TypeOfRelationshipInverted;
import ch.openech.dm.person.Person;
import ch.openech.mj.db.model.Constants;
import ch.openech.mj.edit.Wizard;
import ch.openech.mj.edit.WizardPage;
import ch.openech.mj.edit.fields.AbstractEditField;
import ch.openech.mj.edit.fields.EditField;
import ch.openech.mj.edit.form.DependingOnFieldAbove;
import ch.openech.mj.edit.form.FormVisual;
import ch.openech.mj.edit.validation.ValidationMessage;
import ch.openech.mj.toolkit.ClientToolkit;
import ch.openech.mj.toolkit.ComboBox;
import ch.openech.xml.write.EchNamespaceContext;
import ch.openech.xml.write.WriterEch0020;


public class MoveInWizard extends Wizard<MoveInWizard.MoveInEditorData> {

	private final EchNamespaceContext echNamespaceContext;
	private final Person person;
	private final MoveInEditorData data;
	private final MoveInPersonWizardPage moveInPersonWizardPage;
	private final MoveInNextPersonWizardPage moveInNextPersonWizardPage;
	private int personIndex; // merge with currentPageIndex?
	
	public MoveInWizard(String version) {
		this(EchNamespaceContext.getNamespaceContext(20, version));
	}
	
	public MoveInWizard(EchNamespaceContext echNamespaceContext) {
		this(echNamespaceContext, null);
	}
	
	public MoveInWizard(EchNamespaceContext echNamespaceContext, Person person) {
		this.echNamespaceContext = echNamespaceContext;
		this.person = person;
		this.data = new MoveInEditorData();
		this.moveInPersonWizardPage = new MoveInPersonWizardPage();
		this.moveInNextPersonWizardPage = new MoveInNextPersonWizardPage();
	}
	
	public static class MoveInNextPerson {
		public static final MoveInNextPerson MOVE_IN_NEXT_PERSON = Constants.of(MoveInNextPerson.class);
		
		public String typeOfRelationshipInverted = TypeOfRelationshipInverted.Kind.getKey();
		public Person basePerson;
		public Person mother, father;
		public Person fosterMother, fosterFather;
		
		public TypeOfRelationshipInverted typeOfRelationshipInverted() {
			return TypeOfRelationshipInverted.lookup(typeOfRelationshipInverted);
		}
	}
		
	public static class MoveInEditorData {
		public static final MoveInEditorData MOVE_IN_EDITOR_DATA = Constants.of(MoveInEditorData.class);
		
		public final List<Person> persons = new ArrayList<Person>();
		public final List<MoveInNextPerson> nextPersons = new ArrayList<MoveInWizard.MoveInNextPerson>();
	}

	@Override
	protected WizardPage<?> getFirstPage() {
		return moveInPersonWizardPage;
	}

	protected WriterEch0020 getWriterEch0020() {
		return echNamespaceContext.getWriterEch0020();
	}
	
	public void generateSedexOutput(Person person) throws Exception {
//		if (person.comesFrom != null && !person.comesFrom.municipalityIdentification.isEmpty()) {
//			WriterEch0093 sedexWriter = new WriterEch0093(getEchNamespaceContext());
//			sedexWriter.setRecepientMunicipality(person.comesFrom.municipalityIdentification);
//			String sedexOutput = sedexWriter.moveIn(person);
//			SedexOutputGenerator.generateSedex(sedexOutput, sedexWriter.getEnvelope());
//		}
	}

	@Override
	protected MoveInEditorData load() {
		return data;
	}

	@Override
	protected MoveInEditorData getObject() {
		return data;
	}

	private class MoveInPersonWizardPage extends WizardPage<Person> {

		@Override
		protected FormVisual<Person> createForm() {<commit_msg>MoveInWizard darf Daten nicht selber behalten, sondern muss normalen Editor - Mechanismus verwenden (sonst werden die Werte bei erneutem Öffnen wieder angezeigt)<commit_after>package ch.openech.client.ewk.event.moveIn;

import java.util.ArrayList;
import java.util.List;

import ch.openech.client.ewk.PersonPanel;
import ch.openech.client.ewk.PersonPanel.PersonPanelType;
import ch.openech.client.ewk.XmlEditor;
import ch.openech.client.ewk.event.EchFormPanel;
import ch.openech.dm.code.TypeOfRelationship;
import ch.openech.dm.code.TypeOfRelationshipInverted;
import ch.openech.dm.person.Person;
import ch.openech.mj.db.model.Constants;
import ch.openech.mj.edit.Wizard;
import ch.openech.mj.edit.WizardPage;
import ch.openech.mj.edit.fields.AbstractEditField;
import ch.openech.mj.edit.fields.EditField;
import ch.openech.mj.edit.form.DependingOnFieldAbove;
import ch.openech.mj.edit.form.FormVisual;
import ch.openech.mj.edit.validation.ValidationMessage;
import ch.openech.mj.toolkit.ClientToolkit;
import ch.openech.mj.toolkit.ComboBox;
import ch.openech.xml.write.EchNamespaceContext;
import ch.openech.xml.write.WriterEch0020;


public class MoveInWizard extends Wizard<MoveInWizard.MoveInEditorData> {

	private final EchNamespaceContext echNamespaceContext;
	private final Person person;
	private final MoveInPersonWizardPage moveInPersonWizardPage;
	private final MoveInNextPersonWizardPage moveInNextPersonWizardPage;
	private int personIndex; // merge with currentPageIndex?
	
	public MoveInWizard(String version) {
		this(EchNamespaceContext.getNamespaceContext(20, version));
	}
	
	public MoveInWizard(EchNamespaceContext echNamespaceContext) {
		this(echNamespaceContext, null);
	}
	
	public MoveInWizard(EchNamespaceContext echNamespaceContext, Person person) {
		this.echNamespaceContext = echNamespaceContext;
		this.person = person;
		this.moveInPersonWizardPage = new MoveInPersonWizardPage();
		this.moveInNextPersonWizardPage = new MoveInNextPersonWizardPage();
	}

	public static class MoveInNextPerson {
		public static final MoveInNextPerson MOVE_IN_NEXT_PERSON = Constants.of(MoveInNextPerson.class);
		
		public String typeOfRelationshipInverted = TypeOfRelationshipInverted.Kind.getKey();
		public Person basePerson;
		public Person mother, father;
		public Person fosterMother, fosterFather;
		
		public TypeOfRelationshipInverted typeOfRelationshipInverted() {
			return TypeOfRelationshipInverted.lookup(typeOfRelationshipInverted);
		}
	}
		
	public static class MoveInEditorData {
		public static final MoveInEditorData MOVE_IN_EDITOR_DATA = Constants.of(MoveInEditorData.class);
		
		public final List<Person> persons = new ArrayList<Person>();
		public final List<MoveInNextPerson> nextPersons = new ArrayList<MoveInWizard.MoveInNextPerson>();
	}

	@Override
	protected WizardPage<?> getFirstPage() {
		return moveInPersonWizardPage;
	}

	protected WriterEch0020 getWriterEch0020() {
		return echNamespaceContext.getWriterEch0020();
	}
	
	public void generateSedexOutput(Person person) throws Exception {
//		if (person.comesFrom != null && !person.comesFrom.municipalityIdentification.isEmpty()) {
//			WriterEch0093 sedexWriter = new WriterEch0093(getEchNamespaceContext());
//			sedexWriter.setRecepientMunicipality(person.comesFrom.municipalityIdentification);
//			String sedexOutput = sedexWriter.moveIn(person);
//			SedexOutputGenerator.generateSedex(sedexOutput, sedexWriter.getEnvelope());
//		}
	}

	@Override
	protected MoveInEditorData load() {
		return new MoveInEditorData();
	}

	private class MoveInPersonWizardPage extends WizardPage<Person> {

		@Override
		protected FormVisual<Person> createForm() {
{'fraction_non_alphanumeric': 0.08748114630467571, 'fraction_numerical': 0.0071301247771836, 'mean_word_length': 6.186206896551724, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '3111689', 'n_tokens_mistral': 2453, 'n_tokens_neox': 2268, 'n_words': 422}