<commit_before>package  ch.openech.model.common;

import java.time.LocalDate;
import java.util.List;
import org.minimalj.model.EnumUtils;
import org.minimalj.model.Keys;
import org.minimalj.model.Rendering;
import org.minimalj.model.annotation.Size;
import org.minimalj.model.validation.Validation;
import org.minimalj.model.validation.ValidationMessage;
import org.minimalj.util.DateUtils;
import org.minimalj.util.StringUtils;

import ch.openech.model.person.types.TypeOfHousehold;
import ch.openech.xml.write.EchSchema;

public class DwellingAddress implements Validation, Rendering {

	public static final DwellingAddress $ = Keys.of(DwellingAddress.class);
	
	public transient EchSchema echSchema;
	
	@Size(9)
	public String EGID;
	@Size(3)
	public String EWID;
	@Size(12) // ist nicht bekannt aus Schema
	public String householdID; // not for organisation
	public Address mailAddress;
	public TypeOfHousehold typeOfHousehold; // not for organisation
	public LocalDate movingDate;

	@Override
	public String render(RenderType renderType) {
		return toHtml();
	}

	@Override
	public RenderType getPreferredRenderType(RenderType firstType, RenderType... otherTypes) {
		return RenderType.HMTL;
	}
	
	@Deprecated
	public String toHtml() {
		StringBuilder s = new StringBuilder();
		toHtml(s);
		return s.toString();
	}
		
	public void toHtml(StringBuilder s) {
		if (mailAddress != null) {
			mailAddress.toHtml(s); s.append("<BR>");
		}
		if (!StringUtils.isBlank(EGID)) {
			s.append("EGID: " );
			s.append(EGID); 
		}
		if (!StringUtils.isBlank(EWID)) {
			s.append("<BR>EWID: ");
			s.append(EWID);
		}
		
		if (!StringUtils.isBlank(householdID)) {
			s.append("<BR>Haushalt ID: ");
			s.append(householdID);
		}
		s.append("<BR>");
		if (typeOfHousehold != null) {
			s.append(EnumUtils.getText(typeOfHousehold));
		}
		s.append("<BR>");
		if (movingDate != null) {
			s.append("Umzugsdatum: " ); s.append(DateUtils.format(movingDate));
		}
	}
	
	public void displayWidth(StringBuilder s) {
		s.append("EGID: " );
		if (!StringUtils.isBlank(EGID)) s.append(EGID); else s.append("- ");
		s.append(", EWID: ");
		if (!StringUtils.isBlank(EWID)) s.append(EWID); else s.append("- ");
		s.append(", Haushalt ID: ");
		if (!StringUtils.isBlank(householdID)) s.append(householdID); else s.append("- ");
		s.append("\n");
		if (mailAddress != null) {
			mailAddress.toHtml(s);
		}
		s.append("Haushaltsart: ");
		if (typeOfHousehold != null) s.append(EnumUtils.getText(typeOfHousehold)); else s.append("- ");<commit_msg>DwellingAddress: nicht zu viele Leerzeilen anzeigen<commit_after>package  ch.openech.model.common;

import java.time.LocalDate;
import java.util.List;

import org.minimalj.model.EnumUtils;
import org.minimalj.model.Keys;
import org.minimalj.model.Rendering;
import org.minimalj.model.annotation.Size;
import org.minimalj.model.validation.Validation;
import org.minimalj.model.validation.ValidationMessage;
import org.minimalj.util.DateUtils;
import org.minimalj.util.StringUtils;

import ch.openech.model.person.types.TypeOfHousehold;
import ch.openech.xml.write.EchSchema;

public class DwellingAddress implements Validation, Rendering {

	public static final DwellingAddress $ = Keys.of(DwellingAddress.class);
	
	public transient EchSchema echSchema;
	
	@Size(9)
	public String EGID;
	@Size(3)
	public String EWID;
	@Size(12) // ist nicht bekannt aus Schema
	public String householdID; // not for organisation
	public Address mailAddress;
	public TypeOfHousehold typeOfHousehold; // not for organisation
	public LocalDate movingDate;

	@Override
	public String render(RenderType renderType) {
		return toHtml();
	}

	@Override
	public RenderType getPreferredRenderType(RenderType firstType, RenderType... otherTypes) {
		return RenderType.HMTL;
	}
	
	@Deprecated
	public String toHtml() {
		StringBuilder s = new StringBuilder();
		toHtml(s);
		return s.toString();
	}
		
	public void toHtml(StringBuilder s) {
		if (mailAddress != null) {
			mailAddress.toHtml(s);
		}
		if (!StringUtils.isBlank(EGID)) {
			s.append("EGID: " ).append(EGID).append("<BR>");
		}
		if (!StringUtils.isBlank(EWID)) {
			s.append("EWID: ").append(EWID);
		}
		
		if (!StringUtils.isBlank(householdID)) {
			s.append("Haushalt ID: ");
			s.append(householdID).append(EWID);
		}
		if (typeOfHousehold != null) {
			s.append("<BR>").append(EnumUtils.getText(typeOfHousehold)).append("<BR>");
		}
		if (movingDate != null) {
			s.append("<BR>").append("Umzugsdatum: " ); s.append(DateUtils.format(movingDate)).append("<BR>");
		}
		if (s.toString().toLowerCase().endsWith("<br>")) {
			s.delete(s.length() - 4, s.length());
		}
	}
	
	public void displayWidth(StringBuilder s) {
		s.append("EGID: " );
		if (!StringUtils.isBlank(EGID)) s.append(EGID); else s.append("- ");
		s.append(", EWID: ");
		if (!StringUtils.isBlank(EWID)) s.append(EWID); else s.append("- ");
		s.append(", Haushalt ID: ");
		if (!StringUtils.isBlank(householdID)) s.append(householdID); else s.append("- ");
		s.append("\n");
		if (mailAddress != null) {
			mailAddress.toHtml(s);
		}
		s.append("Haushaltsart: ");
		if (typeOfHousehold != null) s.append(EnumUtils.getText(typeOfHousehold)); else s.append("- ");
{'fraction_non_alphanumeric': 0.15233320478210566, 'fraction_numerical': 0.0017354415734670266, 'mean_word_length': 4.650326797385621, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '825601', 'n_tokens_mistral': 1966, 'n_tokens_neox': 1789, 'n_words': 347}