/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package converter;

import TestRest.Arrival;
import java.math.BigDecimal;
import java.net.URI;
import java.util.Date;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlAttribute;
import javax.ws.rs.core.UriBuilder;
import javax.persistence.EntityManager;

/**
 *
 * @author aparnab
 */

@XmlRootElement(name = "arrival")
public class ArrivalConverter {
    private Arrival entity;
    private URI uri;
    private int expandLevel;
  
    /** Creates a new instance of ArrivalConverter */
    public ArrivalConverter() {
        entity = new Arrival();
    }

    /**
     * Creates a new instance of ArrivalConverter.
     *
     * @param entity associated entity
     * @param uri associated uri
     * @param expandLevel indicates the number of levels the entity graph should be expanded@param isUriExtendable indicates whether the uri can be extended
     */
    public ArrivalConverter(Arrival entity, URI uri, int expandLevel, boolean isUriExtendable) {
        this.entity = entity;
        this.uri = (isUriExtendable) ? UriBuilder.fromUri(uri).path(entity.getArid() + "/").build() : uri;
        this.expandLevel = expandLevel;
    }

    /**
     * Creates a new instance of ArrivalConverter.
     *
     * @param entity associated entity
     * @param uri associated uri
     * @param expandLevel indicates the number of levels the entity graph should be expanded
     */
    public ArrivalConverter(Arrival entity, URI uri, int expandLevel) {
        this(entity, uri, expandLevel, false);
    }

    /**
     * Getter for arid.
     *
     * @return value for arid
     */
    @XmlElement
    public Long getArid() {
        return (expandLevel > 0) ? entity.getArid() : null;
    }

    /**
     * Setter for arid.
     *
     * @param value the value to set
     */
    public void setArid(Long value) {
        entity.setArid(value);
    }

    /**
     * Getter for commid.
     *
     * @return value for commid
     */
    @XmlElement
    public Long getCommid() {
        return (expandLevel > 0) ? entity.getCommid() : null;
    }

    /**
     * Setter for commid.
     *
     * @param value the value to set
     */
    public void setCommid(Long value) {
        entity.setCommid(value);
    }

    /**
     * Getter for datetime.
     *
     * @return value for datetime
     */
    @XmlElement
    public BigDecimal getDatetime() {
        return (expandLevel > 0) ? entity.getDatetime() : null;
    }

    /**
     * Setter for datetime.
     *
     * @param value the value to set
     */
    public void setDatetime(BigDecimal value) {
        entity.setDatetime(value);
    }

    /**
     * Getter for sta.
     *
     * @return value for sta
     */
    @XmlElement
    public String getSta() {
        return (expandLevel > 0) ? entity.getSta() : null;
    }

    /**
     * Setter for sta.
     *
     * @param value the value to set
     */
    public void setSta(String value) {
        entity.setSta(value);
    }

    /**
     * Getter for net.
     *
     * @return value for net
     */
    @XmlElement
    public String getNet() {
        return (expandLevel > 0) ? entity.getNet() : null;
    }

    /**
     * Setter for net.
     *
     * @param value the value to set
     */
    public void setNet(String value) {
        entity.setNet(value);
    }

    /**
     * Getter for auth.
     *
     * @return value for auth
     */
    @XmlElement
    public String getAuth() {
        return (expandLevel > 0) ? entity.getAuth() : null;
    }

    /**
     * Setter for auth.
     *
     * @param value the value to set
     */
    public void setAuth(String value) {
        entity.setAuth(value);
    }

    /**
     * Getter for subsource.
     *
     * @return value for subsource
     */
    @XmlElement
    public String getSubsource() {
        return (expandLevel > 0) ? entity.getSubsource() : null;
    }

    /**
     * Setter for subsource.
     *
     * @param value the value to set
     */
    public void setSubsource(String value) {
        entity.setSubsource(value);
    }

    /**
     * Getter for channel.
     *
     * @return value for channel
     */
    @XmlElement
    public String getChannel() {
        return (expandLevel > 0) ? entity.getChannel() : null;
    }

    /**
     * Setter for channel.
     *
     * @param value the value to set
     */
    public void setChannel(String value) {
        entity.setChannel(value);
    }

    /**
     * Getter for channelsrc.
     *
     * @return value for channelsrc
     */
    @XmlElement
    public String getChannelsrc() {
        return (expandLevel > 0) ? entity.getChannelsrc() : null;
    }

    /**
     * Setter for channelsrc.
     *
     * @param value the value to set
     */
    public void setChannelsrc(String value) {
        entity.setChannelsrc(value);
    }

    /**
     * Getter for seedchan.
     *
     * @return value for seedchan
     */
    @XmlElement
    public String getSeedchan() {
        return (expandLevel > 0) ? entity.getSeedchan() : null;
    }

    /**
     * Setter for seedchan.
     *
     * @param value the value to set
     */
    public void setSeedchan(String value) {
        entity.setSeedchan(value);
    }

    /**
     * Getter for location.
     *
     * @return value for location
     */
    @XmlElement
    public String getLocation() {
        return (expandLevel > 0) ? entity.getLocation() : null;
    }

    /**
     * Setter for location.
     *
     * @param value the value to set
     */
    public void setLocation(String value) {
        entity.setLocation(value);
    }

    /**
     * Getter for iphase.
     *
     * @return value for iphase
     */
    @XmlElement
    public String getIphase() {
        return (expandLevel > 0) ? entity.getIphase() : null;
    }

    /**
     * Setter for iphase.
     *
     * @param value the value to set
     */
    public void setIphase(String value) {
        entity.setIphase(value);
    }

    /**
     * Getter for qual.
     *
     * @return value for qual
     */
    @XmlElement
    public String getQual() {
        return (expandLevel > 0) ? entity.getQual() : null;
    }

    /**
     * Setter for qual.
     *
     * @param value the value to set
     */
    public void setQual(String value) {
        entity.setQual(value);
    }

    /**
     * Getter for clockqual.
     *
     * @return value for clockqual
     */
    @XmlElement
    public String getClockqual() {
        return (expandLevel > 0) ? entity.getClockqual() : null;
    }

    /**
     * Setter for clockqual.
     *
     * @param value the value to set
     */
    public void setClockqual(String value) {
        entity.setClockqual(value);
    }

    /**
     * Getter for clockcorr.
     *
     * @return value for clockcorr
     */
    @XmlElement
    public Long getClockcorr() {
        return (expandLevel > 0) ? entity.getClockcorr() : null;
    }

    /**
     * Setter for clockcorr.
     *
     * @param value the value to set
     */
    public void setClockcorr(Long value) {
        entity.setClockcorr(value);
    }

    /**
     * Getter for ccset.
     *
     * @return value for ccset
     */
    @XmlElement
    public String getCcset() {
        return (expandLevel > 0) ? entity.getCcset() : null;
    }

    /**
     * Setter for ccset.
     *
     * @param value the value to set
     */
    public void setCcset(String value) {
        entity.setCcset(value);
    }

    /**
     * Getter for fm.
     *
     * @return value for fm
     */
    @XmlElement
    public String getFm() {
        return (expandLevel > 0) ? entity.getFm() : null;
    }

    /**
     * Setter for fm.
     *
     * @param value the value to set
     */
    public void setFm(String value) {
        entity.setFm(value);
    }

    /**
     * Getter for ema.
     *
     * @return value for ema
     */
    @XmlElement
    public BigDecimal getEma() {
        return (expandLevel > 0) ? entity.getEma() : null;
    }

    /**
     * Setter for ema.
     *
     * @param value the value to set
     */
    public void setEma(BigDecimal value) {
        entity.setEma(value);
    }

    /**
     * Getter for azimuth.
     *
     * @return value for azimuth
     */
    @XmlElement
    public BigDecimal getAzimuth() {
        return (expandLevel > 0) ? entity.getAzimuth() : null;
    }

    /**
     * Setter for azimuth.
     *
     * @param value the value to set
     */
    public void setAzimuth(BigDecimal value) {
        entity.setAzimuth(value);
    }

    /**
     * Getter for slow.
     *
     * @return value for slow
     */
    @XmlElement
    public BigDecimal getSlow() {
        return (expandLevel > 0) ? entity.getSlow() : null;
    }

    /**
     * Setter for slow.
     *
     * @param value the value to set
     */
    public void setSlow(BigDecimal value) {
        entity.setSlow(value);
    }

    /**
     * Getter for deltim.
     *
     * @return value for deltim
     */
    @XmlElement
    public BigDecimal getDeltim() {
        return (expandLevel > 0) ? entity.getDeltim() : null;
    }

    /**
     * Setter for deltim.
     *
     * @param value the value to set
     */
    public void setDeltim(BigDecimal value) {
        entity.setDeltim(value);
    }

    /**
     * Getter for delinc.
     *
     * @return value for delinc
     */
    @XmlElement
    public BigDecimal getDelinc() {
        return (expandLevel > 0) ? entity.getDelinc() : null;
    }

    /**
     * Setter for delinc.
     *
     * @param value the value to set
     */
    public void setDelinc(BigDecimal value) {
        entity.setDelinc(value);
    }

    /**
     * Getter for delaz.
     *
     * @return value for delaz
     */
    @XmlElement
    public BigDecimal getDelaz() {
        return (expandLevel > 0) ? entity.getDelaz() : null;
    }

    /**
     * Setter for delaz.
     *
     * @param value the value to set
     */
    public void setDelaz(BigDecimal value) {
        entity.setDelaz(value);
    }

    /**
     * Getter for delslo.
     *
     * @return value for delslo
     */
    @XmlElement
    public BigDecimal getDelslo() {
        return (expandLevel > 0) ? entity.getDelslo() : null;
    }

    /**
     * Setter for delslo.
     *
     * @param value the value to set
     */
    public void setDelslo(BigDecimal value) {
        entity.setDelslo(value);
    }

    /**
     * Getter for quality.
     *
     * @return value for quality
     */
    @XmlElement
    public BigDecimal getQuality() {
        return (expandLevel > 0) ? entity.getQuality() : null;
    }

    /**
     * Setter for quality.
     *
     * @param value the value to set
     */
    public void setQuality(BigDecimal value) {
        entity.setQuality(value);
    }

    /**
     * Getter for snr.
     *
     * @return value for snr
     */
    @XmlElement
    public Double getSnr() {
        return (expandLevel > 0) ? entity.getSnr() : null;
    }

    /**
     * Setter for snr.
     *
     * @param value the value to set
     */
    public void setSnr(Double value) {
        entity.setSnr(value);
    }

    /**
     * Getter for rflag.
     *
     * @return value for rflag
     */
    @XmlElement
    public String getRflag() {
        return (expandLevel > 0) ? entity.getRflag() : null;
    }

    /**
     * Setter for rflag.
     *
     * @param value the value to set
     */
    public void setRflag(String value) {
        entity.setRflag(value);
    }

    /**
     * Getter for lddate.
     *
     * @return value for lddate
     */
    @XmlElement
    public Date getLddate() {
        return (expandLevel > 0) ? entity.getLddate() : null;
    }

    /**
     * Setter for lddate.
     *
     * @param value the value to set
     */
    public void setLddate(Date value) {
        entity.setLddate(value);
    }

    /**
     * Returns the URI associated with this converter.
     *
     * @return the uri
     */
    @XmlAttribute
    public URI getUri() {
        return uri;
    }

    /**
     * Sets the URI for this reference converter.
     *
     */
    public void setUri(URI uri) {
        this.uri = uri;
    }

    /**
     * Returns the Arrival entity.
     *
     * @return an entity
     */
    @XmlTransient
    public Arrival getEntity() {
        if (entity.getArid() == null) {
            ArrivalConverter converter = UriResolver.getInstance().resolve(ArrivalConverter.class, uri);
            if (converter != null) {
                entity = converter.getEntity();
            }
        }
        return entity;
    }

    /**
     * Returns the resolved Arrival entity.
     *
     * @return an resolved entity
     */
    public Arrival resolveEntity(EntityManager em) {
        return entity;
    }
}
