001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.module.cg.document.service.impl;
017
018 import java.util.ArrayList;
019 import java.util.Arrays;
020 import java.util.HashMap;
021 import java.util.List;
022 import java.util.Map;
023
024 import org.kuali.kfs.module.cg.CGPropertyConstants;
025 import org.kuali.kfs.module.cg.businessobject.ResearchRiskType;
026 import org.kuali.kfs.module.cg.document.service.RoutingFormResearchRiskService;
027 import org.kuali.kfs.sys.KFSPropertyConstants;
028 import org.kuali.rice.kns.service.BusinessObjectService;
029
030 public class RoutingFormResearchRiskServiceImpl implements RoutingFormResearchRiskService {
031
032 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(RoutingFormResearchRiskServiceImpl.class);
033
034 private BusinessObjectService businessObjectService;
035
036
037
038 /**
039 * Get the list of all active research risk types from the database.
040 *
041 * @return List<ResearchRiskType>
042 */
043 protected List<ResearchRiskType> getAllResearchRiskTypes() {
044 return getResearchRiskTypes(new String[0]);
045 }
046
047 /**
048 * @see org.kuali.kfs.module.cg.document.service.RoutingFormResearchRiskService#getResearchRiskTypes(String[])
049 */
050 public List<ResearchRiskType> getResearchRiskTypes(String[] exceptCodes) {
051 Map criteria = new HashMap();
052 criteria.put(KFSPropertyConstants.ACTIVE, true);
053 List<ResearchRiskType> allActiveResearchRiskTypes = (List<ResearchRiskType>) this.businessObjectService.findMatchingOrderBy(ResearchRiskType.class, criteria, CGPropertyConstants.RESEARCH_RISK_TYPE_SORT_NUMBER, true);
054
055 List<String> exceptCodesList = Arrays.asList(exceptCodes);
056 List<ResearchRiskType> result = new ArrayList<ResearchRiskType>();
057 for (ResearchRiskType type : allActiveResearchRiskTypes) {
058 if (!exceptCodesList.contains(type.getResearchRiskTypeCode())) {
059 result.add(type);
060 }
061 }
062 return result;
063 }
064
065 /**
066 * Setter for BusinessObjectService property.
067 *
068 * @param businessObjectService businessObjectService
069 */
070 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
071 this.businessObjectService = businessObjectService;
072 }
073 }