/*
 *  This file is part of Renspur.
 *  
 *  Copyright (C) 2016  Leo Winter
 *  
 *  Rennspur is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  Rennspur is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *  
 *  You should have received a copy of the GNU Affero General Public License
 *  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */
package de.rennspur.backend;

import java.util.List;

import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;

import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import de.rennspur.model.Club;
import de.rennspur.model.Event;
import de.rennspur.model.Race;
import de.rennspur.model.Team;
import de.rennspur.model.TeamMember;
import de.rennspur.model.TeamPosition;
import java.util.List;

import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import javax.ws.rs.GET;
import javax.ws.rs.POST;

import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import de.rennspur.model.Club;
import de.rennspur.model.Event;
import de.rennspur.model.Race;
import de.rennspur.model.Team;
import de.rennspur.model.TeamMember;
import de.rennspur.model.TeamPosition;

/**
 * This Api part provides the Api endpoint for the webfrontend.
 * 
 * @author leo.winter, leon.schlender
 * @param <FrontendData>
 */


@Path("/APId")

public class ApiFrontend<FrontendData> {
	@Inject
	private EntityManagerFactory emf;

	@GET
	@Path("/full")
	@Produces(MediaType.APPLICATION_JSON)
	public FrontendData getFrontendDataInJSON() {
		// TODO - Output of every needed value.
		Club club = new Club();
		Event event = new Event();
		Race race = new Race();
		Team team = new Team();
		TeamMember teammember = new TeamMember();
		TeamPosition teamposition = new TeamPosition();

		team.getName();
		club.getAbreviation();
		
		club.getId();
		// Backend.getLatestMemberPositions(i?, 10);

		event.getHandicap();
		event.getWaypoints();
		
		// pos part
		//teampostion.getTime();
		//teampostion.getLatitude();
		//teampostion.getLongitude();

		// TODO - return the result to the client
		return null;
	}
	

	/**
	 * Returns a specific amount of the latest Positions of a team
	 * 
	 * @param teamid
	 *            ID of the wanted team
	 * @param positionsCount
	 * @return
	 */


	@POST	
	@Path("/FrontendUpdate")
	@Produces(MediaType.APPLICATION_XML)
	
	/**
	 * Returns a specific amount of the latest Positions of a team
	 * 
	 * @param teamid
	 *            ID of the wanted team
	 * @param positionsCount
	 * @return
	 */

	public List<TeamPosition> getLatestTeamPositions(@FormParam("id") int teamid) {
		EntityManager em = emf.createEntityManager();

		Query query = em.createNamedQuery("TeamPosition.findLatestPositions");
		query.setParameter("id", teamid);
		//query.setParameter("limit", limit);
		@SuppressWarnings("unchecked")
		List<TeamPosition> positions = query.getResultList();
		return positions;

	}
	
}
@@ -1121,520 +1121,8 @@
 e;%0A%0A
-import de.rennspur.model.Club;%0Aimport de.rennspur.model.Event;%0Aimport de.rennspur.model.Race;%0Aimport de.rennspur.model.Team;%0Aimport de.rennspur.model.TeamMember;%0Aimport de.rennspur.model.TeamPosition;%0Aimport java.util.List;%0A%0Aimport javax.inject.Inject;%0Aimport javax.persistence.EntityManager;%0Aimport javax.persistence.EntityManagerFactory;%0Aimport javax.persistence.Query;%0Aimport javax.ws.rs.GET;%0Aimport javax.ws.rs.POST;%0A%0Aimport javax.ws.rs.Path;%0Aimport javax.ws.rs.Produces;%0Aimport javax.ws.rs.core.MediaType;%0A%0A
 impo
@@ -1472,11 +1472,15 @@
 h(%22/
-API
+fronten
 d%22)%0A
@@ -2443,17 +2443,9 @@
 h(%22/
-FrontendU
+u
 pdat

Update for #6 and 7cc5612cdfe46d5c2f9fda341330fb6e4af4e2e4