View Javadoc
1   /*
2    * Copyright 2006 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.module.cg.document.service.impl;
17  
18  import java.util.ArrayList;
19  import java.util.Arrays;
20  import java.util.HashMap;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.kuali.ole.module.cg.CGPropertyConstants;
25  import org.kuali.ole.module.cg.businessobject.ResearchRiskType;
26  import org.kuali.ole.module.cg.document.service.RoutingFormResearchRiskService;
27  import org.kuali.ole.sys.OLEPropertyConstants;
28  import org.kuali.rice.krad.service.BusinessObjectService;
29  
30  public class RoutingFormResearchRiskServiceImpl implements RoutingFormResearchRiskService {
31  
32      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(RoutingFormResearchRiskServiceImpl.class);
33  
34      private BusinessObjectService businessObjectService;
35  
36    
37  
38      /**
39       * Get the list of all active research risk types from the database.
40       * 
41       * @return List<ResearchRiskType>
42       */
43      protected List<ResearchRiskType> getAllResearchRiskTypes() {
44          return getResearchRiskTypes(new String[0]);
45      }
46  
47      /**
48       * @see org.kuali.ole.module.cg.document.service.RoutingFormResearchRiskService#getResearchRiskTypes(String[])
49       */
50      public List<ResearchRiskType> getResearchRiskTypes(String[] exceptCodes) {
51          Map criteria = new HashMap();
52          criteria.put(OLEPropertyConstants.ACTIVE, true);
53          List<ResearchRiskType> allActiveResearchRiskTypes = (List<ResearchRiskType>) this.businessObjectService.findMatchingOrderBy(ResearchRiskType.class, criteria, CGPropertyConstants.RESEARCH_RISK_TYPE_SORT_NUMBER, true);
54  
55          List<String> exceptCodesList = Arrays.asList(exceptCodes);
56          List<ResearchRiskType> result = new ArrayList<ResearchRiskType>();
57          for (ResearchRiskType type : allActiveResearchRiskTypes) {
58              if (!exceptCodesList.contains(type.getResearchRiskTypeCode())) {
59                  result.add(type);
60              }
61          }
62          return result;
63      }
64  
65      /**
66       * Setter for BusinessObjectService property.
67       * 
68       * @param businessObjectService businessObjectService
69       */
70      public void setBusinessObjectService(BusinessObjectService businessObjectService) {
71          this.businessObjectService = businessObjectService;
72      }
73  }