private void buildTrain() throws Exception
	{
        IRailwayRepository repo = this.getSite().getRequiredService(IRailwayRepository.class);
		
		
		this._route = Queries.query(this._train.getTrainNumber().getRoutes()).first(new Predicate<Route>(){

			@Override
			public boolean evaluate(Route r) throws Exception {
				return  (r.getStartDate().isBefore(_train.getDepartureDate()) || r.getStartDate().isEqual(_train.getDepartureDate()))
						&& r.getEndDate().isAfter(_train.getDepartureDate());
			}});
		
		
		int seatSeq = 0;
		for(int i = 0; i < 18; i ++)
		{
			Car car = new Car();
			car.setId(UUID.randomUUID());
			car.setTrain(this._train);
			CarType ct = repo.getCarTypes()[ i % repo.getCarTypes().length];
			car.setCarTyp(ct);
			_train.getCars().add(car);
			
			for(Seat seat : ct.getSeats())
			{
			     OperatingSeat oseat = new OperatingSeat();
			     oseat.setId(UUID.randomUUID());
			     oseat.setCar(car);
			     oseat.setSeatNumber(seat.getNumber());
			     oseat.setSequence(seatSeq);
			     oseat.setSeatType(ct.getSeatType());
			     seatSeq++;
			     car.getSeats().add(oseat);
			}
		}
	}