/*
 * This file is part of NavalPlan
 *
 * Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
 *                         Desenvolvemento Tecnolóxico de Galicia
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.navalplanner.web.resources.search;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.navalplanner.business.resources.entities.Criterion;
import org.navalplanner.business.resources.entities.CriterionType;
import org.navalplanner.business.resources.entities.Machine;
import org.navalplanner.business.resources.entities.Resource;
import org.navalplanner.business.resources.entities.ResourceEnum;
import org.navalplanner.business.resources.entities.Worker;

/**
 * Conversation for worker search
 *
 * @author Diego Pino Garcia <dpino@igalia.com>
 */
public interface IResourceSearchModel {

    public interface IResourcesQuery<T extends Resource> {

        IResourcesQuery<T> byName(String name);

        IResourcesQuery<T> byCriteria(Collection<? extends Criterion> criteria);

        IResourcesQuery<T> byLimiting(boolean limiting);

        List<T> execute();

        /**
         * <p>
         * Gets all {@link Criterion} and groups then by {@link CriterionType}
         * with the condition that the {@link CriterionType#getResource()} is of
         * a type compatible for this query.
         * </p>
         * For example if this query has been created by
         * {@link IResourceSearchModel#searchWorkers()} only the criteria with
         * criterion type such its resource is {@link ResourceEnum.WORKER}
         * @return HashMap<CriterionType, Set<Criterion>>
         */
        Map<CriterionType, Set<Criterion>> getCriteria();
    }

    public IResourcesQuery<Worker> searchWorkers();

    public IResourcesQuery<Machine> searchMachines();

    public IResourcesQuery<?> searchBy(ResourceEnum resourceType);

    public IResourcesQuery<Resource> searchBoth();

}

@@ -1582,188 +1582,1112 @@
     
-IResourcesQuery%3CT%3E byName(String name);%0A%0A        IResourcesQuery%3CT%3E byCriteria(Collection%3C? extends Criterion%3E criteria);%0A%0A        IResourcesQuery%3CT%3E byLimiting(boolean limiting);%0A
+/**%0A         * Restrict the result to resources that have name as a substring. The%0A         * match is case insensitive.%0A         *%0A         * @param name%0A         * @return this same object in order to cascade calls%0A         */%0A        IResourcesQuery%3CT%3E byName(String name);%0A%0A        /**%0A         * Restrict the result to a list of %7B@link Resource%7D satisfying all%0A         * criteria at some point in time%0A         *%0A         * @param criteria%0A         * @return this same object in order to cascade calls%0A         */%0A        IResourcesQuery%3CT%3E byCriteria(Collection%3C? extends Criterion%3E criteria);%0A%0A        /**%0A         * Restrict resources to the ones having the provided limiting value. By%0A         * default, if this method is not called, the resources are restricted%0A         * to the ones not limiting.%0A         * @param limiting%0A         * @return this same object in order to cascade calls%0A         */%0A        IResourcesQuery%3CT%3E byLimiting(boolean limiting);%0A%0A        /**%0A         * Retrieve the list of resources that match the restrictions specified.%0A         *%0A         * @return%0A         */
 %0A   
@@ -3313,179 +3313,529 @@
     
-public IResourcesQuery%3CWorker%3E searchWorkers();%0A%0A    public IResourcesQuery%3CMachine%3E searchMachines();%0A%0A    public IResourcesQuery%3C?%3E searchBy(ResourceEnum resourceType);%0A
+/**%0A     * Do the search limited to workers%0A     *%0A     * @return%0A     */%0A    public IResourcesQuery%3CWorker%3E searchWorkers();%0A%0A    /**%0A     * Do the search limited to machines%0A     * @return%0A     */%0A    public IResourcesQuery%3CMachine%3E searchMachines();%0A%0A    /**%0A     * Search machines or workers based on the value of resourceType%0A     * @param resourceType%0A     * @return%0A     */%0A    public IResourcesQuery%3C?%3E searchBy(ResourceEnum resourceType);%0A%0A    /**%0A     * Search both resources and machines%0A     * @return%0A     */
 %0A   

Add javadoc