All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.evasion.entity.booktravel.Itinerary Maven / Gradle / Ivy

The newest version!
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.evasion.entity.booktravel;

import com.evasion.EntityJPA;
import com.evasion.entity.geolocation.Location;
import java.util.*;
import javax.persistence.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 *
 * @author sebastien
 */
@Entity(name = Itinerary.ENTITY_NAME)
@Table(name = Itinerary.ENTITY_NAME)
public class Itinerary extends EntityJPA {

    /**
     * *
     * serialVersionUID.
     */
    private static final long serialVersionUID = 1L;

    public static final String ENTITY_NAME = "TRAVEl_ITINERARY";

    /**
     * Id technique.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private int distance;

    private int denivele;

    private int altitudeMax;

    private float pourcentagePente;

    private String typeTransport;

    @Temporal(javax.persistence.TemporalType.TIME)
    private Calendar tempsSelle;

    private float vitesseMoyenne;

    @OneToMany()
    @OrderColumn(name = "numero_ligne")
    private List breakPointInternal;

    /**
     * Getter de l'ID technique.
     *
     * @return ID technique.
     */
    @Override
    public Long getId() {
        return id;
    }

    /**
     * Setter de l'ID technique.
     *
     * @param id ID technique.
     */
    public void setId(Long id) {
        this.id = id;
    }

    public int getAltitudeMax() {
        return altitudeMax;
    }

    public void setAltitudeMax(int altitudeMax) {
        this.altitudeMax = altitudeMax;
    }

    public int getDenivele() {
        return denivele;
    }

    public void setDenivele(int denivele) {
        this.denivele = denivele;
    }

    public int getDistance() {
        return distance;
    }

    public void setDistance(int distance) {
        this.distance = distance;
    }

    public float getPourcentagePente() {
        return pourcentagePente;
    }

    public void setPourcentagePente(float pourcentagePente) {
        this.pourcentagePente = pourcentagePente;
    }

    public Date getTempsSelle() {
        return tempsSelle.getTime();
    }

    public void setTempsSelle(Date tempsSelle) {
        this.tempsSelle.setTime(tempsSelle);
    }

    public float getVitesseMoyenne() {
        return vitesseMoyenne;
    }

    public void setVitesseMoyenne(float vitesseMoyenne) {
        this.vitesseMoyenne = vitesseMoyenne;
    }

    public String getTypeTransport() {
        return typeTransport;
    }

    public void setTypeTransport(String typeTransport) {
        this.typeTransport = typeTransport;
    }

    /**
     * Getter pour la persistance de l'ensemble des points de passage.
     *
     * @return ensemble des points de passage.
     */
    protected List getBreakPointInternal() {
        if (breakPointInternal == null) {
            breakPointInternal = new ArrayList();
        }
        return breakPointInternal;
    }

    /**
     * Setter pour la persistance de l'ensemble des points de passage.
     *
     * @param breakPoint ensemble des points de passage.
     */
    protected void setBreakPointInternal(List breakPoint) {
        this.breakPointInternal = breakPoint;
    }

    /**
     * Getter de l'ensemble des feuilles de route.
     *
     * @return ensemble de feuilles de route.
     */
    public List getBreakPoints() {
        return Collections.unmodifiableList(getBreakPointInternal());
    }

    /**
     * Ajout d'une feuille de route.
     *
     * @param roadMap feuille de route
     * @return renvoi
     * true si l'ajout est réussi; sinon
     * false
     */
    public boolean addBreakPoint(Location breakPoint) {
        return getBreakPointInternal().add(breakPoint);
    }

    /**
     * Supprime tous les breakpoint non présent en paramètre.
     *
     * @param roadMap feuille de route
     * @return renvoi
     * true si les suppressions ont réussi; sinon
     * false
     */
    public boolean retainAllBreakPoint(Collection breakPoints) {
        return getBreakPointInternal().retainAll(breakPoints);
    }

    /**
     * Met à jour la liste après avoir supprimer l'ensenble des enregistrements
     * présent.
     *
     * @param breakPoints
     * @return renvoi
     * true si l'ajout est réussi; sinon
     * false
     */
    public boolean updateBreakPoint(Collection breakPoints) {
        getBreakPointInternal().clear();
        return getBreakPointInternal().addAll(breakPoints);

    }
    
    public void replaceBreakPoint(int id, Location loc) {
        getBreakPointInternal().set(id, loc);
        //getBreakPointInternal().remove(id+1);
    }

    /**
     * {@inheritDoc }.
     */
    @Override
    public boolean equals(final Object obj) {
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof Itinerary)) {
            return false;
        }
        final Itinerary other = (Itinerary) obj;
        return new EqualsBuilder().append(this.id, other.id).isEquals();
    }

    /**
     * {@inheritDoc }.
     */
    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(id).toHashCode();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy