/**
 * Copyright (C) 2019 Patrik Dufresne Service Logiciel <info@patrikdufresne.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package com.planimod.ui.views.employees;

import java.util.Collection;

import com.patrikdufresne.managers.ManagerException;
import com.patrikdufresne.managers.databinding.ManagedObjectComputedSet;
import com.planimod.core.PlanimodManagers;
import com.planimod.core.Position;
import com.planimod.core.PositionManager;

public class ClassifiedPositionComputedSet extends ManagedObjectComputedSet {

    public ClassifiedPositionComputedSet(PlanimodManagers managers) {
        super(managers, Position.class);
    }

    /**
     * This implementation is calling {@link PositionManager#listClassified()}.
     * 
     * @return listof object
     */
    @Override
    protected Collection doList() throws ManagerException {
        return ((PlanimodManagers) getManagers()).getPositionManager().listClassified();
    }

    /**
     * Check if the element should be selected. Default implementation always return true.
     * <p>
     * Subclasses should override this function if it's override {@link #doList()}.
     * 
     * @param element
     *            the element to check
     * @return True if the element should be selected
     */
    @Override
    protected boolean doSelect(Object element) {
        return element instanceof Position && ((Position) element).getClassified();
    }

}
