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

package ejb;

import java.io.Serializable;
import java.sql.Time;
import java.util.TreeMap;
import java.util.Vector;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;


/**
 *
 * @author e1502608 revising revising
 */
@Entity
public class BestPaths implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private float distance;
    //@ManyToMany(targetEntity = Trains.class, fetch = FetchType.LAZY)
    //@JoinColumn(name = "id")
    //private Vector<Long> trainIds;

    private TreeMap<Long,Vector<Time> > departureTimes;
    private TreeMap<Long, Vector<Time> > arrivalTimes;

    //artık one to many
    //@ManyToMany(targetEntity=Trains.class,fetch=FetchType.LAZY)
    //@JoinColumn(name="id")
    private long departurePlace;

    //@ManyToMany(targetEntity=Trains.class,fetch=FetchType.LAZY)
    //@JoinColumn(name="id")
    private long arrivalPlace;


    public TreeMap<Long, Vector<Time>> getArrivalTimes() {
        return arrivalTimes;
    }

    public void setArrivalTimes(TreeMap<Long, Vector<Time>> arrivalTimes) {
        this.arrivalTimes = arrivalTimes;
    }

    public TreeMap<Long, Vector<Time>> getDepartureTimes() {
        return departureTimes;
    }

    public void setDepartureTimes(TreeMap<Long, Vector<Time>> departureTimes) {
        this.departureTimes = departureTimes;
    }


    public long getArrivalPlace() {
        return arrivalPlace;
    }

    public void setArrivalPlace(long arrivalPlace) {
        this.arrivalPlace = arrivalPlace;
    }

    public long getDeparturePlace() {
        return departurePlace;
    }

    public void setDeparturePlace(long departurePlace) {
        this.departurePlace = departurePlace;
    }


    public float getDistance() {
        return distance;
    }

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

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BestPaths)) {
            return false;
        }
        BestPaths other = (BestPaths) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ejb.BestPaths[id=" + id + "]";
    }


    public void printBestPath()
    {
        System.out.print(id+" ; "+departurePlace+" ; "+arrivalPlace+" ; ");
        Object[] keyset=departureTimes.keySet().toArray();
        int numOfKeySet=keyset.length;
        System.out.println("num of trains: "+ numOfKeySet);
        for(int i=0;i<numOfKeySet;i++)
        {
            Vector<Time> times=departureTimes.get(keyset[i]);
            int numoftime=times.size();
            System.out.println("timelar: "+numoftime);
            for(int j=0;j<numoftime;j++)
                System.out.print(times.get(j)+" , ");
            System.out.print(" - ");
        }

        System.out.println();


    }

}
