/*
 * Copyright (c) 2011, Patrik Dufresne. All rights reserved.
 * Patrik Dufresne PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
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();
	}

}
