org.openlmis.fulfillment.service.referencedata.ProgramReferenceDataService.java Source code

Java tutorial

Introduction

Here is the source code for org.openlmis.fulfillment.service.referencedata.ProgramReferenceDataService.java

Source

/*
 * This program is part of the OpenLMIS logistics management information system platform software.
 * Copyright  2017 VillageReach
 *
 * 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. For additional information contact info@OpenLMIS.org.
 */

package org.openlmis.fulfillment.service.referencedata;

import java.util.Collection;
import java.util.Collections;
import java.util.UUID;
import org.openlmis.fulfillment.service.request.RequestParameters;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

@Service
public class ProgramReferenceDataService extends BaseReferenceDataService<ProgramDto> {

    @Override
    protected String getUrl() {
        return "/api/programs/";
    }

    @Override
    protected Class<ProgramDto> getResultClass() {
        return ProgramDto.class;
    }

    @Override
    protected Class<ProgramDto[]> getArrayResultClass() {
        return ProgramDto[].class;
    }

    /**
     * Finds programs by their ids.
     *
     * @param ids ids to look for.
     * @return a page of programs
     */
    public Collection<ProgramDto> findByIds(Collection<UUID> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return Collections.emptyList();
        }
        return findAll("", RequestParameters.init().set("id", ids));
    }
}