/*
 * 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.taxiservicios.beans;

import com.arrebol.taxiservicios.controller.admin.DriverController;
import com.arrebol.taxiservicios.model.enums.GenericEnumType;
import com.arrebol.taxiservicios.model.enums.PersonType;
import com.arrebol.taxiservicios.model.view.DriverInactiveAndBlackListView;
import com.arrebol.taxiservicios.model.view.PersonListView;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
 */
public abstract class GenericPersonBean extends TaxiGenericBean {

    /**
     *
     * @param type
     * @return
     */
    protected List<PersonListView> findListOfPersonsByType(PersonType type) {
        try {
            return getController().findListOfPersonsByType(type, getLoggedUser().getLocation());
        } catch (Exception e) {
            return new ArrayList<>();
        }
    }

    /**
     *
     * @param blackList
     * @return
     */
    protected List<DriverInactiveAndBlackListView> findListOfInactiveDriversByType(GenericEnumType blackList) {
        try {
            return getController().findListOfInactiveDriversByType(blackList, getLoggedUser().getLocation());
        } catch (Exception e) {
            return new ArrayList<>();
        }
    }

    private DriverController controller;

    protected DriverController getController() {
        return controller;
    }

    protected void setController(DriverController controller) {
        this.controller = controller;
    }

}
