/*
 * Arrebol Consultancy copyright.
 * 
 * This code belongs to Arrebol Consultancy
 * its use, redistribution or modification are prohibited 
 * without written authorization from Arrebol Consultancy.
 */
package com.arrebol.apc.controller.admin;

import com.arrebol.apc.model.ModelParameter;
import com.arrebol.apc.model.catalog.Vehicle;
import com.arrebol.apc.model.views.constance.StatsVehicleCfg;
import com.arrebol.apc.repository.GenericEntityRepository;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 *
 * @author Oscar Armando Vargas Cardenas <oscar.vargas@arrebol.com.mx>
 */
public class StatsVehicleController implements Serializable {

    public List<Vehicle> fillVehicleDataTable(Date startDate, Date endDate) {
        logger.debug("fillVehicleDataTable");
        List<ModelParameter> parameters = new ArrayList<>();
        
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(startDate);
        calendar.add(Calendar.DAY_OF_YEAR, 1);
        startDate = calendar.getTime();

        Calendar calendarF = Calendar.getInstance();
        calendarF.setTime(endDate);
        calendarF.add(Calendar.DAY_OF_YEAR, 1);
        endDate = calendarF.getTime();
        
        List<Vehicle> dataComplete = genericEntityRepository.xmlQueryAPCEntities(Vehicle.class, StatsVehicleCfg.QUERY_FIND_ALL_VEHICLES, parameters);

        return dataComplete;
    }

    final Logger logger = LogManager.getLogger(StatsAdvancesController.class);
    private final GenericEntityRepository genericEntityRepository;

    public StatsVehicleController() {
        this.genericEntityRepository = new GenericEntityRepository();
    }
}
