/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

import entity.AdminEditor;
import entity.MapBoard;
import entity.Player;
import entity.UrlBanners;
import facade.Facade;
import java.util.Collection;
import java.util.List;
import javax.persistence.EntityManager;

/**
 *
 * @author install1
 */
public class Initialization {

    public static void main(String[] args) {
        setupDBTablesWithPresentValues();
    }

    private static void setupDBTablesWithPresentValues() {
        Facade facade = new Facade();

        facade.checkTimeElapse();
        System.out.println("finished first timeelapse");
        List<Player> getAllPlayers = facade.getAllPlayersFromCache();
        System.out.println("finished getAllPlayers");
        facade.getleaderBoard(0);
        System.out.println("finished retrieving leaderboard");
        Collection<MapBoard> getAllMapBoards = facade.getAllMapBoardsFromCache();
        
        //facade.getPlayerMaps("STEAM_0:0:33155716", 0);
        /*
        AdminEditor admin = new AdminEditor("jenz", "1234");
        EntityManager em = PuSelector.getEntityManagerFactory("pu").createEntityManager();
        //simply cant persist collections/list
        em.getTransaction().begin();
        em.createQuery("delete from AdminEditor").executeUpdate();
        em.createQuery("delete from MapBoard").executeUpdate();
        em.createQuery("delete from MapValues").executeUpdate();
        em.createQuery("delete from Player").executeUpdate();
        em.createQuery("delete from UrlBanners").executeUpdate();
        for (Player player : getAllPlayers) {
            // System.out.println("player: " + player.getName());
            em.persist(player);
        }
        for (MapBoard mapboard : getAllMapBoards) {
            // System.out.println("mapboard: " + mapboard.getMapName());
            em.persist(mapboard);
        }
        em.persist(admin);
        em.getTransaction().commit();
        */
        System.out.println("checktime second time");
        facade.checkTimeElapse();
        facade.getSpecificMap("ze_Ancient_wrath_v1_fix2", 1, 153);
    }
}
