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.MerchantContactInfo;
import api.unicore.component_manual.MerchantFacade;
import api.unicore.component_manual.MerchantLetters;
import api.unicore.component_manual.MerchantPhases;
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.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.XmlElement;
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;
/**
* @author CodeGen
* @company UnitedThinkers
* @since 2012/05/13
*/
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"code", "referenceCode", "name", "createDate", "isActive", "notes", "phases", "contactInfo", "letters"})
@JsonPropertyOrder({"code", "referenceCode", "name", "createDate", "isActive", "notes", "phases", "contactInfo", "letters"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(MerchantFacade.class)
public abstract class AbstractMerchantFacade extends UnoComponent<unicore.model.Merchant> {
@FormParam("code")
@IntegerFormat
@DefaultValue(INTEGER_NULL_CODE)
protected Integer code;
@FormParam("referenceCode")
@StringFormat
@DefaultValue(STRING_NULL_CODE)
protected String referenceCode;
@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("notes")
@StringFormat
@DefaultValue(STRING_NULL_CODE)
protected String notes;
protected MerchantPhases phases = new MerchantPhases();
protected MerchantContactInfo contactInfo = new MerchantContactInfo();
protected MerchantLetters letters = new MerchantLetters();
public AbstractMerchantFacade(){
super();
applyDefaults();
}
public AbstractMerchantFacade(unicore.model.Merchant object){
super(object);
}
private void applyDefaults() {
if (!isProxyObject()) {
code = INTEGER_NULL;
referenceCode = STRING_NULL;
name = STRING_NULL;
createDate = DATE_NULL;
notes = STRING_NULL;
phases = null;
contactInfo = null;
letters = null;
}
isActive = Boolean.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("merchant: {");
sb.append("code: ");
sb.append(code);
sb.append(',').append(' ');
sb.append("referenceCode: ");
sb.append(referenceCode);
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("notes: ");
sb.append(notes);
sb.append(',').append(' ');
sb.append("phases: ");
sb.append(phases);
sb.append(',').append(' ');
sb.append("contactInfo: ");
sb.append(contactInfo);
sb.append(',').append(' ');
sb.append("letters: ");
sb.append(letters);
sb.append('}');
return sb.toString();
}
@XmlAttribute(name="code")
@XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
@FormParam("code")
@IntegerFormat
@JsonDeserialize(using=api.util.NumberDeserializer.class)
public Integer getCode(){
return code;
}
public void setCode(Integer value){
this.code = value;
}
@XmlAttribute(name="referenceCode")
@XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
@FormParam("referenceCode")
@StringFormat
@JsonDeserialize(using = api.util.StringDeserializer.class)
public String getReferenceCode(){
return referenceCode;
}
public void setReferenceCode(String value){
this.referenceCode = value;
}
@XmlAttribute(name="name")
@XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
@FormParam("name")
@StringFormat
@JsonDeserialize(using = api.util.StringDeserializer.class)
public String getName(){
return name;
}
public void setName(String value){
this.name = value;
}
@XmlAttribute(name="createDate")
@XmlJavaTypeAdapter(api.util.DateTimeAdapter.class)
@FormParam("createDate")
@DateFormat
@JsonSerialize(using=api.util.DateTimeSerializer.class, include = NON_NULL)
@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;
}
@XmlElement(name="notes")
@XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
@FormParam("notes")
@StringFormat
@JsonDeserialize(using = api.util.StringDeserializer.class)
public String getNotes(){
return notes;
}
public void setNotes(String value){
this.notes = value;
}
@XmlElement(name="phases")
public MerchantPhases getPhases(){
return phases;
}
@XmlElement(name="contactInfo")
public MerchantContactInfo getContactInfo(){
return contactInfo;
}
@XmlElement(name="letters")
public MerchantLetters getLetters(){
return letters;
}
public void audit(AuditHelper helper, ServerObject object) {
unicore.model.Merchant s_object = (unicore.model.Merchant) object;
helper.audit("code", code, s_object.getCode());
helper.audit("referenceCode", referenceCode, 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("notes", notes, s_object.getNotes());
}
}