package api.unicore.component;
 
import static api.util.ComponentConstants.DATE_NULL;
import static api.util.ComponentConstants.DATE_NULL_CODE;
import static api.util.ComponentConstants.INTEGER_NULL;
import static api.util.ComponentConstants.INTEGER_NULL_CODE;
import static api.util.ComponentConstants.STRING_NULL;
import static api.util.ComponentConstants.STRING_NULL_CODE;
import static org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion.NON_NULL;
 
import api.UnoComponent;
import api.unicore.component_manual.BusinessOwner;
import api.util.DateFormat;
import api.util.IntegerFormat;
import api.util.StringFormat;
import iapp.services.ServerObject;
import iapp.util.audit.AuditHelper;
import java.util.Date;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.FormParam;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.codehaus.jackson.annotate.JsonPropertyOrder;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import unipay.validator.CustomValidator;
 
/**
 * @author CodeGen [Anton Shershnov]
 * @company UnitedThinkers
 * @since 2013/04/02
 */
 
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"firstName", "lastName", "socialSecurity", "birthDate", "driverLicense", "driverLicenseState", "phone", "email", "street1", "street2", "city", "state", "zipCode", "countryCode", "driverLicenseCountryCode", "rolePolicyType", "stakePercentage", "ownerCode"})
@JsonPropertyOrder({"firstName", "lastName", "socialSecurity", "birthDate", "driverLicense", "driverLicenseState", "phone", "email", "street1", "street2", "city", "state", "zipCode", "countryCode", "driverLicenseCountryCode", "rolePolicyType", "stakePercentage", "ownerCode"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(BusinessOwner.class)
@CustomValidator
public abstract class AbstractBusinessOwner extends UnoComponent<unicore.model.BusinessOwner> {
 
    @FormParam("firstName")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String firstName;
 
    @FormParam("lastName")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String lastName;
 
    @FormParam("socialSecurity")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String socialSecurity;
 
    @FormParam("birthDate")
    @DateFormat
    @DefaultValue(DATE_NULL_CODE)
    protected Date birthDate;
 
    @FormParam("driverLicense")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String driverLicense;
 
    @FormParam("driverLicenseState")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String driverLicenseState;
 
    @FormParam("phone")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String phone;
 
    @FormParam("email")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String email;
 
    @FormParam("street1")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String street1;
 
    @FormParam("street2")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String street2;
 
    @FormParam("city")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String city;
 
    @FormParam("state")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String state;
 
    @FormParam("zipCode")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String zipCode;
 
    @FormParam("countryCode")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String countryCode;
 
    @FormParam("driverLicenseCountryCode")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String driverLicenseCountryCode;
 
    @FormParam("rolePolicyType")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String rolePolicyType;
 
    @FormParam("stakePercentage")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer stakePercentage;
 
    @FormParam("ownerCode")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String ownerCode;
 
 
    public AbstractBusinessOwner(){
        super();
        applyDefaults();
    }
 
    public AbstractBusinessOwner(unicore.model.BusinessOwner object){
        super(object);
    }
 
 
    private void applyDefaults() {
        if (!isProxyObject()) {
            firstName = STRING_NULL;
            lastName = STRING_NULL;
            socialSecurity = STRING_NULL;
            birthDate = DATE_NULL;
            driverLicense = STRING_NULL;
            driverLicenseState = STRING_NULL;
            phone = STRING_NULL;
            email = STRING_NULL;
            street1 = STRING_NULL;
            street2 = STRING_NULL;
            city = STRING_NULL;
            state = STRING_NULL;
            zipCode = STRING_NULL;
            countryCode = STRING_NULL;
            driverLicenseCountryCode = STRING_NULL;
            rolePolicyType = STRING_NULL;
            stakePercentage = INTEGER_NULL;
            ownerCode = STRING_NULL;
        }
    }
 
    @Override
    public void from() {
        fromInternal();
        super.from();
    }
 
    protected abstract void fromInternal();
    @Override
    public abstract void to();
    @Override
    public abstract void initializeNew();
 
    @Override
    public String toString(){
        StringBuilder sb = new StringBuilder();
        sb.append("businessOwner: {");
        sb.append("firstName: ");
        sb.append(firstName);
        sb.append(',').append(' ');
        sb.append("lastName: ");
        sb.append(lastName);
        sb.append(',').append(' ');
        sb.append("socialSecurity: ");
        sb.append(socialSecurity);
        sb.append(',').append(' ');
        sb.append("birthDate: ");
        sb.append(birthDate);
        sb.append(',').append(' ');
        sb.append("driverLicense: ");
        sb.append(driverLicense);
        sb.append(',').append(' ');
        sb.append("driverLicenseState: ");
        sb.append(driverLicenseState);
        sb.append(',').append(' ');
        sb.append("phone: ");
        sb.append(phone);
        sb.append(',').append(' ');
        sb.append("email: ");
        sb.append(email);
        sb.append(',').append(' ');
        sb.append("street1: ");
        sb.append(street1);
        sb.append(',').append(' ');
        sb.append("street2: ");
        sb.append(street2);
        sb.append(',').append(' ');
        sb.append("city: ");
        sb.append(city);
        sb.append(',').append(' ');
        sb.append("state: ");
        sb.append(state);
        sb.append(',').append(' ');
        sb.append("zipCode: ");
        sb.append(zipCode);
        sb.append(',').append(' ');
        sb.append("countryCode: ");
        sb.append(countryCode);
        sb.append(',').append(' ');
        sb.append("driverLicenseCountryCode: ");
        sb.append(driverLicenseCountryCode);
        sb.append(',').append(' ');
        sb.append("rolePolicyType: ");
        sb.append(rolePolicyType);
        sb.append(',').append(' ');
        sb.append("stakePercentage: ");
        sb.append(stakePercentage);
        sb.append(',').append(' ');
        sb.append("ownerCode: ");
        sb.append(ownerCode);
        sb.append('}');
        return sb.toString();
    }
 
 
    @XmlAttribute(name="firstName")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("firstName")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(min = 1, max = 50)
    @Pattern(regexp = unipay.validator.PatternName.NAME)
    public String getFirstName(){
        return firstName;
    }
 
    public void setFirstName(String value){
        this.firstName = value;
    }
 
    @XmlAttribute(name="lastName")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("lastName")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(min = 1, max = 50)
    @Pattern(regexp = unipay.validator.PatternName.NAME)
    public String getLastName(){
        return lastName;
    }
 
    public void setLastName(String value){
        this.lastName = value;
    }
 
    @XmlAttribute(name="socialSecurity")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("socialSecurity")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(min = 9, max = 9)
    @Pattern(regexp = unipay.validator.PatternName.NUMERIC)
    public String getSocialSecurity(){
        return socialSecurity;
    }
 
    public void setSocialSecurity(String value){
        this.socialSecurity = value;
    }
 
    @XmlAttribute(name="birthDate")
    @FormParam("birthDate")
    @DateFormat
    @JsonDeserialize(using=api.util.DateDeserializer.class)
    @NotNull
    public Date getBirthDate(){
        return birthDate;
    }
 
    public void setBirthDate(Date value){
        this.birthDate = value;
    }
 
    @XmlAttribute(name="driverLicense")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("driverLicense")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getDriverLicense(){
        return driverLicense;
    }
 
    public void setDriverLicense(String value){
        this.driverLicense = value;
    }
 
    @XmlAttribute(name="driverLicenseState")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("driverLicenseState")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(min = 2, max = 2)
    @Pattern(regexp = unipay.validator.PatternName.ALPHA)
    public String getDriverLicenseState(){
        return driverLicenseState;
    }
 
    public void setDriverLicenseState(String value){
        this.driverLicenseState = value;
    }
 
    @XmlAttribute(name="phone")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("phone")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(max = 15)
    @Pattern(regexp = unipay.validator.PatternName.NUMERIC)
    public String getPhone(){
        return phone;
    }
 
    public void setPhone(String value){
        this.phone = value;
    }
 
    @XmlAttribute(name="email")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("email")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(max = 100)
    @Pattern(regexp = unipay.validator.PatternName.EMAIL)
    public String getEmail(){
        return email;
    }
 
    public void setEmail(String value){
        this.email = value;
    }
 
    @XmlAttribute(name="street1")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("street1")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(max = 60)
    @Pattern(regexp = unipay.validator.PatternName.STREET)
    public String getStreet1(){
        return street1;
    }
 
    public void setStreet1(String value){
        this.street1 = value;
    }
 
    @XmlAttribute(name="street2")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("street2")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 60)
    @Pattern(regexp = unipay.validator.PatternName.STREET)
    public String getStreet2(){
        return street2;
    }
 
    public void setStreet2(String value){
        this.street2 = value;
    }
 
    @XmlAttribute(name="city")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("city")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(max = 50)
    @Pattern(regexp = unipay.validator.PatternName.ALPHANUMERIC_EXTENDED)
    public String getCity(){
        return city;
    }
 
    public void setCity(String value){
        this.city = value;
    }
 
    @XmlAttribute(name="state")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("state")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(max = 3)
    @Pattern(regexp = unipay.validator.PatternName.ALPHA)
    public String getState(){
        return state;
    }
 
    public void setState(String value){
        this.state = value;
    }
 
    @XmlAttribute(name="zipCode")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("zipCode")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(min = 4, max = 9)
    @Pattern(regexp = unipay.validator.PatternName.DOCUMENT_NUMBER)
    public String getZipCode(){
        return zipCode;
    }
 
    public void setZipCode(String value){
        this.zipCode = value;
    }
 
    @XmlAttribute(name="countryCode")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("countryCode")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(min = 2, max = 2)
    @Pattern(regexp = unipay.validator.PatternName.ALPHA)
    public String getCountryCode(){
        return countryCode;
    }
 
    public void setCountryCode(String value){
        this.countryCode = value;
    }
 
    @XmlAttribute(name="driverLicenseCountryCode")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("driverLicenseCountryCode")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getDriverLicenseCountryCode(){
        return driverLicenseCountryCode;
    }
 
    public void setDriverLicenseCountryCode(String value){
        this.driverLicenseCountryCode = value;
    }
 
    @XmlAttribute(name="rolePolicyType")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("rolePolicyType")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    public String getRolePolicyType(){
        return rolePolicyType;
    }
 
    public void setRolePolicyType(String value){
        this.rolePolicyType = value;
    }
 
    @XmlAttribute(name="stakePercentage")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("stakePercentage")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    @NotNull
    @Max(100)
    public Integer getStakePercentage(){
        return stakePercentage;
    }
 
    public void setStakePercentage(Integer value){
        this.stakePercentage = value;
    }
 
    @XmlAttribute(name="ownerCode")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("ownerCode")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 25)
    @Pattern(regexp = unipay.validator.PatternName.CODE)
    public String getOwnerCode(){
        return ownerCode;
    }
 
    public void setOwnerCode(String value){
        this.ownerCode = value;
    }
 
 
    public void audit(AuditHelper helper, ServerObject object) {
        unicore.model.BusinessOwner s_object = (unicore.model.BusinessOwner) object;
        helper.audit("firstName", firstName, s_object.getFirstName());
        helper.audit("lastName", lastName, s_object.getLastName());
        helper.audit("socialSecurity", socialSecurity, s_object.getSocialSecurity());
        helper.audit("birthDate", birthDate, s_object.getBirthDate());
        helper.audit("driverLicense", driverLicense, s_object.getDriverLicense());
        helper.audit("driverLicenseState", driverLicenseState, s_object.getDriverLicenseState());
        helper.audit("phone", phone, s_object.getPhone());
        helper.audit("email", email, s_object.getEmail());
        helper.audit("street1", street1, s_object.getStreet1());
        helper.audit("street2", street2, s_object.getStreet2());
        helper.audit("city", city, s_object.getCity());
        helper.audit("state", state, s_object.getState());
        helper.audit("zipCode", zipCode, s_object.getZipCode());
        helper.audit("countryCode", countryCode, s_object.getCountryCode());
        helper.audit("driverLicenseCountryCode", driverLicenseCountryCode, s_object.getDriverLicenseCountryCode());
        helper.audit("rolePolicyType", rolePolicyType, s_object.getRolePolicyCl() == null ? null : s_object.getRolePolicyCl().getValue());
        helper.audit("stakePercentage", stakePercentage, s_object.getStakePercentage());
        helper.audit("ownerCode", ownerCode, s_object.getCode());
 
    }
 
    public static String objectTypeCode(){
        return "business-owner";
    }
 
}