@Override
	public Ticket[] toTicket(TicketPoolTicket[] poolTickets) throws Exception {
		
		
		IRailwayRepository repo = this.getSite().getRequiredService(IRailwayRepository.class);
		
		Ticket[] rs = new Ticket[poolTickets.length];
		
		for(int i = 0; i < poolTickets.length; i ++)
		{
			final TicketPoolTicket pt = poolTickets[i];
		    Ticket ticket = new Ticket();
		    ticket.setId(UUID.randomUUID());
		    ticket.setTrainNumber(this.getTrain().getTrainNumber().getName());
		    ticket.setSeatNumber(pt.getSeat().getSeatNumber());
		    ticket.setCar(Integer.toString(pt.getSeat().getCar().getCarNumber()));
		    String seatTypeName = Queries.query(repo.getSeatTypes())
		        .where(new Predicate<SeatType>(){

				    @Override
				    public boolean evaluate(SeatType seatType) throws Exception {
					    return seatType.getCode() == pt.getSeat().getSeatType();
				    }})
				.select(new Selector<SeatType, String>(){

					@Override
					public String select(SeatType seatType) {
						return seatType.getName();
					}})
				.first();
		    ticket.setSeatType(seatTypeName);
		    
		    ticket.setDepartureStation(this._route.getStops().get(pt.getDepartureStop()).getStation().getName());
		    ticket.setDestinationStation(this._route.getStops().get(pt.getDestinationStop()).getStation().getName());
		    ticket.setDepartureDate(this._train.getDepartureDate());
		    
		    rs[i] = ticket;
		   
		}
		
		
		return rs;
	}