
package de.ivu.elect.presentation.staat.form;

import java.io.Serializable;

import javax.inject.Inject;

import de.ivu.elect.business.staat.entity.Staat;
import de.ivu.elect.business.staat.entity.StaatProperties;
import de.ivu.elect.jee.presentation.dynamicform.FormBuilder;

public class StaatViewFormBuilder implements Serializable {

  private static final long serialVersionUID = 1L;

  @Inject
  private StaatUniqueUKFacesValidator staatUniqueUKFacesValidator;

  public StaatViewFormBuilder() {
    super();
  }

  public void addProperties(FormBuilder formBuilder, Staat staat) {
    StaatProperties staatProperties = staat.getProperties();

    formBuilder.addProperty(staatProperties.getCustomCodeStaatProperty());
    formBuilder.addProperty(staatProperties.getCustomCodeStaatsangehoerigkeitProperty()).withValidatorAndPk(staatUniqueUKFacesValidator,
        staat.getPk());

    formBuilder.addProperty(staatProperties.getNameStaatProperty());
    formBuilder.addProperty(staatProperties.getNameStaatsangehoerigkeitProperty());

    formBuilder.addProperty(staatProperties.getIso3166Alpha2Property());
    formBuilder.addProperty(staatProperties.getIso3166NumerischProperty());
  }
}
