package api.unicore.component;
import static api.util.ComponentConstants.DATE_NULL;
import static api.util.ComponentConstants.DATE_NULL_CODE;
import static api.util.ComponentConstants._NULL;
import static api.util.ComponentConstants._NULL_CODE;
import static org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion.NON_NULL;
import api.DuoComponent;
import api.unicore.VirtualFields;
import api.unicore.component_manual.Key;
import api.unicore.component_manual.KeyType;
import api.util.DateFormat;
import api.util.Format;
import iapp.services.ServerObject;
import iapp.util.audit.AuditHelper;
import java.util.Date;
import javax.validation.constraints.NotNull;
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 [Liza Zhydok]
* @company UnitedThinkers
* @since 2012/06/08
*/
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"name", "type", "lastModified"})
@JsonPropertyOrder({"name", "type", "lastModified"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(Key.class)
public abstract class AbstractKey extends DuoComponent<> {
@FormParam("name")
@Format
@DefaultValue(_NULL_CODE)
protected name;
protected KeyType type = new KeyType();
@FormParam("lastModified")
@DateFormat
@DefaultValue(DATE_NULL_CODE)
protected Date lastModified;
public AbstractKey(){
super();
applyDefaults();
}
public AbstractKey(){
super();
}
private void applyDefaults() {
if (!isProxyObject()) {
name = _NULL;
type = null;
lastModified = DATE_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("key: {");
sb.append("name: ");
sb.append(name);
sb.append(',').append(' ');
sb.append("type: ");
sb.append(type);
sb.append(',').append(' ');
sb.append("lastModified: ");
sb.append(lastModified);
sb.append('}');
return sb.toString();
}
@XmlAttribute(name="name")
@FormParam("name")
@Format
@NotNull
public getName(){
return name;
}
public void setName( value){
this.name = value;
}
@XmlElement(name="type")
@NotNull
public KeyType getType(){
return type;
}
public void setType(KeyType value){
this.type = value;
}
@XmlAttribute(name="lastModified")
@FormParam("lastModified")
@DateFormat
@JsonDeserialize(using=api.util.DateDeserializer.class)
@NotNull
public Date getLastModified(){
return lastModified;
}
public void setLastModified(Date value){
this.lastModified = value;
}
public void audit(AuditHelper helper, ServerObject object) {
helper.audit("name", name, VirtualFields.Name.get(s_));
helper.audit("lastModified", lastModified, VirtualFields.LastModified.get(s_));
}
}