package api.unicore.component;
 
import static api.util.ComponentConstants.BOOLEAN_NULL;
import static api.util.ComponentConstants.BOOLEAN_NULL_CODE;
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.Portfolio;
import api.util.BooleanFormat;
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.Min;
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 2014/01/07
 */
 
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"id", "code", "name", "createDate", "isActive", "dataExportPolicy", "annualFeePolicy", "facilitatorPrefix", "isMultipleReturnsFileSupported", "tagList", "cloudCode", "street1", "street2", "city", "state", "zipCode", "countryCode"})
@JsonPropertyOrder({"id", "code", "name", "createDate", "isActive", "dataExportPolicy", "annualFeePolicy", "facilitatorPrefix", "isMultipleReturnsFileSupported", "tagList", "cloudCode", "street1", "street2", "city", "state", "zipCode", "countryCode"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(Portfolio.class)
@CustomValidator
public abstract class AbstractPortfolio extends UnoComponent<unicore.model.Portfolio> {
 
    @FormParam("id")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer id;
 
    @FormParam("code")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String code;
 
    @FormParam("name")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String name;
 
    @FormParam("createDate")
    @DateFormat
    @DefaultValue(DATE_NULL_CODE)
    protected Date createDate;
 
    @FormParam("isActive")
    @BooleanFormat
    protected Boolean isActive;
 
    @FormParam("dataExportPolicy")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String dataExportPolicy;
 
    @FormParam("annualFeePolicy")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String annualFeePolicy;
 
    @FormParam("facilitatorPrefix")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String facilitatorPrefix;
 
    @FormParam("isMultipleReturnsFileSupported")
    @BooleanFormat
    @DefaultValue(BOOLEAN_NULL_CODE)
    protected Boolean isMultipleReturnsFileSupported;
 
    @FormParam("tagList")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String tagList;
 
    @FormParam("cloudCode")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String cloudCode;
 
    @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;
 
 
    public AbstractPortfolio(){
        super();
        applyDefaults();
    }
 
    public AbstractPortfolio(unicore.model.Portfolio object){
        super(object);
    }
 
 
    private void applyDefaults() {
        if (!isProxyObject()) {
            id = INTEGER_NULL;
            code = STRING_NULL;
            name = STRING_NULL;
            createDate = DATE_NULL;
            dataExportPolicy = STRING_NULL;
            annualFeePolicy = STRING_NULL;
            facilitatorPrefix = STRING_NULL;
            isMultipleReturnsFileSupported = BOOLEAN_NULL;
            tagList = STRING_NULL;
            cloudCode = STRING_NULL;
            street1 = STRING_NULL;
            street2 = STRING_NULL;
            city = STRING_NULL;
            state = STRING_NULL;
            zipCode = STRING_NULL;
            countryCode = STRING_NULL;
        }
        isActive = true;
    }
 
    @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("portfolio: {");
        sb.append("id: ");
        sb.append(id);
        sb.append(',').append(' ');
        sb.append("code: ");
        sb.append(code);
        sb.append(',').append(' ');
        sb.append("name: ");
        sb.append(name);
        sb.append(',').append(' ');
        sb.append("createDate: ");
        sb.append(createDate);
        sb.append(',').append(' ');
        sb.append("isActive: ");
        sb.append(isActive);
        sb.append(',').append(' ');
        sb.append("dataExportPolicy: ");
        sb.append(dataExportPolicy);
        sb.append(',').append(' ');
        sb.append("annualFeePolicy: ");
        sb.append(annualFeePolicy);
        sb.append(',').append(' ');
        sb.append("facilitatorPrefix: ");
        sb.append(facilitatorPrefix);
        sb.append(',').append(' ');
        sb.append("isMultipleReturnsFileSupported: ");
        sb.append(isMultipleReturnsFileSupported);
        sb.append(',').append(' ');
        sb.append("tagList: ");
        sb.append(tagList);
        sb.append(',').append(' ');
        sb.append("cloudCode: ");
        sb.append(cloudCode);
        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('}');
        return sb.toString();
    }
 
 
    @XmlAttribute(name="id")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("id")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    @Min(100)
    @Max(999)
    public Integer getId(){
        return id;
    }
 
 
    @XmlAttribute(name="code")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("code")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 60)
    @Pattern(regexp = unipay.validator.PatternName.CODE)
    public String getCode(){
        return code;
    }
 
    public void setCode(String value){
        this.code = value;
    }
 
    @XmlAttribute(name="name")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("name")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(max = 128)
    @Pattern(regexp = unipay.validator.PatternName.NAME_BUSINESS)
    public String getName(){
        return name;
    }
 
    public void setName(String value){
        this.name = value;
    }
 
    @XmlAttribute(name="createDate")
    @FormParam("createDate")
    @DateFormat
    @JsonDeserialize(using=api.util.DateDeserializer.class)
    public Date getCreateDate(){
        return createDate;
    }
 
 
    @XmlAttribute(name="isActive")
    @FormParam("isActive")
    @BooleanFormat
    public Boolean getIsActive(){
        return isActive;
    }
 
    public void setIsActive(Boolean value){
        this.isActive = value;
    }
 
    @XmlAttribute(name="dataExportPolicy")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("dataExportPolicy")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 10)
    @Pattern(regexp = unipay.validator.PatternName.CUSTOM_DATA_EXPORT_POLICY)
    public String getDataExportPolicy(){
        return dataExportPolicy;
    }
 
    public void setDataExportPolicy(String value){
        this.dataExportPolicy = value;
    }
 
    @XmlAttribute(name="annualFeePolicy")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("annualFeePolicy")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(min = 12, max = 12)
    public String getAnnualFeePolicy(){
        return annualFeePolicy;
    }
 
    public void setAnnualFeePolicy(String value){
        this.annualFeePolicy = value;
    }
 
    @XmlAttribute(name="facilitatorPrefix")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("facilitatorPrefix")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(max = 3)
    public String getFacilitatorPrefix(){
        return facilitatorPrefix;
    }
 
    public void setFacilitatorPrefix(String value){
        this.facilitatorPrefix = value;
    }
 
    @XmlAttribute(name="isMultipleReturnsFileSupported")
    @FormParam("isMultipleReturnsFileSupported")
    @BooleanFormat
    public Boolean getIsMultipleReturnsFileSupported(){
        return isMultipleReturnsFileSupported;
    }
 
    public void setIsMultipleReturnsFileSupported(Boolean value){
        this.isMultipleReturnsFileSupported = value;
    }
 
    @XmlAttribute(name="tagList")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("tagList")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 50)
    @Pattern(regexp = unipay.validator.PatternName.TEXT)
    public String getTagList(){
        return tagList;
    }
 
    public void setTagList(String value){
        this.tagList = value;
    }
 
    @XmlAttribute(name="cloudCode")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("cloudCode")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 1)
    @Pattern(regexp = unipay.validator.PatternName.ALPHA)
    public String getCloudCode(){
        return cloudCode;
    }
 
    public void setCloudCode(String value){
        this.cloudCode = value;
    }
 
    @XmlAttribute(name="street1")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("street1")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 128)
    @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 = 128)
    @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)
    @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)
    @Size(max = 3)
    @Pattern(regexp = unipay.validator.PatternName.ALPHANUMERIC_EXTENDED)
    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)
    @Size(max = 2)
    @Pattern(regexp = unipay.validator.PatternName.ALPHA)
    public String getCountryCode(){
        return countryCode;
    }
 
    public void setCountryCode(String value){
        this.countryCode = value;
    }
 
 
    public void audit(AuditHelper helper, ServerObject object) {
        unicore.model.Portfolio s_object = (unicore.model.Portfolio) object;
        helper.audit("id", id, s_object.getCode());
        helper.audit("code", code, s_object.getRefCode());
        helper.audit("name", name, s_object.getName());
        helper.audit("createDate", createDate, s_object.getCreateDate());
        helper.audit("isActive", isActive, s_object.getIsActive());
        helper.audit("dataExportPolicy", dataExportPolicy, s_object.getDataExportPolicy());
        helper.audit("annualFeePolicy", annualFeePolicy, s_object.getAnnualFeePolicy());
        helper.audit("facilitatorPrefix", facilitatorPrefix, s_object.getFacilitatorPrefix());
        helper.audit("isMultipleReturnsFileSupported", isMultipleReturnsFileSupported, s_object.getIsMultipleReturnsFileSupported());
        helper.audit("tagList", tagList, s_object.getTagList());
        helper.audit("cloudCode", cloudCode, s_object.getCloudCode());
        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());
 
    }
 
 
}