package api.unicore.component;
 
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.UserContactInfo;
import api.util.StringFormat;
import iapp.services.ServerObject;
import iapp.util.audit.AuditHelper;
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 [Kirill Zhukov]
 * @company UnitedThinkers
 * @since 2012/10/15
 */
 
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"street1", "street2", "city", "state", "zipCode", "countryCode", "primaryPhone", "cellPhone", "eveningPhone", "fax", "email"})
@JsonPropertyOrder({"street1", "street2", "city", "state", "zipCode", "countryCode", "primaryPhone", "cellPhone", "eveningPhone", "fax", "email"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(UserContactInfo.class)
@CustomValidator
public abstract class AbstractUserContactInfo extends UnoComponent<unicore.model.User> {
 
    @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("primaryPhone")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String primaryPhone;
 
    @FormParam("cellPhone")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String cellPhone;
 
    @FormParam("eveningPhone")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String eveningPhone;
 
    @FormParam("fax")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String fax;
 
    @FormParam("email")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String email;
 
 
    public AbstractUserContactInfo(){
        super();
        applyDefaults();
    }
 
    public AbstractUserContactInfo(unicore.model.User object){
        super(object);
    }
 
 
    private void applyDefaults() {
        if (!isProxyObject()) {
            street1 = STRING_NULL;
            street2 = STRING_NULL;
            city = STRING_NULL;
            state = STRING_NULL;
            zipCode = STRING_NULL;
            countryCode = STRING_NULL;
            primaryPhone = STRING_NULL;
            cellPhone = STRING_NULL;
            eveningPhone = STRING_NULL;
            fax = STRING_NULL;
            email = 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("contactInfo: {");
        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("primaryPhone: ");
        sb.append(primaryPhone);
        sb.append(',').append(' ');
        sb.append("cellPhone: ");
        sb.append(cellPhone);
        sb.append(',').append(' ');
        sb.append("eveningPhone: ");
        sb.append(eveningPhone);
        sb.append(',').append(' ');
        sb.append("fax: ");
        sb.append(fax);
        sb.append(',').append(' ');
        sb.append("email: ");
        sb.append(email);
        sb.append('}');
        return sb.toString();
    }
 
 
    @XmlAttribute(name="street1")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("street1")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @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)
    @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)
    @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)
    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)
    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)
    public String getCountryCode(){
        return countryCode;
    }
 
    public void setCountryCode(String value){
        this.countryCode = value;
    }
 
    @XmlAttribute(name="primaryPhone")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("primaryPhone")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(min = 10, max = 15)
    @Pattern(regexp = unipay.validator.PatternName.NUMERIC)
    public String getPrimaryPhone(){
        return primaryPhone;
    }
 
    public void setPrimaryPhone(String value){
        this.primaryPhone = value;
    }
 
    @XmlAttribute(name="cellPhone")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("cellPhone")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(min = 10, max = 15)
    @Pattern(regexp = unipay.validator.PatternName.NUMERIC)
    public String getCellPhone(){
        return cellPhone;
    }
 
    public void setCellPhone(String value){
        this.cellPhone = value;
    }
 
    @XmlAttribute(name="eveningPhone")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("eveningPhone")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(min = 10, max = 15)
    @Pattern(regexp = unipay.validator.PatternName.NUMERIC)
    public String getEveningPhone(){
        return eveningPhone;
    }
 
    public void setEveningPhone(String value){
        this.eveningPhone = value;
    }
 
    @XmlAttribute(name="fax")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("fax")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(min = 10, max = 15)
    @Pattern(regexp = unipay.validator.PatternName.NUMERIC)
    public String getFax(){
        return fax;
    }
 
    public void setFax(String value){
        this.fax = value;
    }
 
    @XmlAttribute(name="email")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("email")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Pattern(regexp = unipay.validator.PatternName.EMAIL)
    public String getEmail(){
        return email;
    }
 
    public void setEmail(String value){
        this.email = value;
    }
 
 
    public void audit(AuditHelper helper, ServerObject object) {
        unicore.model.User s_object = (unicore.model.User) object;
        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("primaryPhone", primaryPhone, s_object.getPhone());
        helper.audit("cellPhone", cellPhone, s_object.getCellPhone());
        helper.audit("eveningPhone", eveningPhone, s_object.getEveningPhone());
        helper.audit("fax", fax, s_object.getFax());
        helper.audit("email", email, s_object.getEmail());
 
    }
 
    public static String objectTypeCode(){
        return "contact-info";
    }
 
}