Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CampusServiceImpl |
|
| 3.0;3 |
1 | /** | |
2 | * Copyright 2011 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | package org.kuali.mobility.campus.service; | |
16 | ||
17 | import java.util.ArrayList; | |
18 | import java.util.Iterator; | |
19 | import java.util.List; | |
20 | ||
21 | import org.kuali.mobility.campus.entity.Campus; | |
22 | import org.springframework.stereotype.Service; | |
23 | ||
24 | /** | |
25 | * A service for doing the actual work of interacting with Campus objects. | |
26 | * | |
27 | * @author Kuali Mobility Team (moblitiy.collab@kuali.org) | |
28 | */ | |
29 | @Service | |
30 | 0 | public class CampusServiceImpl implements CampusService { |
31 | ||
32 | private List<Campus> campuses; | |
33 | ||
34 | public List<Campus> findCampusesByTool(String toolName) { | |
35 | 0 | List<Campus> toolCampuses = new ArrayList<Campus>(); |
36 | ||
37 | 0 | for (Iterator<Campus> iterator = campuses.iterator(); iterator.hasNext();) { |
38 | 0 | Campus campus = iterator.next(); |
39 | 0 | if (campus.getTools().contains(toolName)) { |
40 | 0 | toolCampuses.add(campus); |
41 | } | |
42 | 0 | } |
43 | 0 | return toolCampuses; |
44 | } | |
45 | ||
46 | public boolean needToSelectDifferentCampusForTool(String tool, String campus) { | |
47 | 0 | List<Campus> campuses = findCampusesByTool(tool); |
48 | 0 | boolean needDifferentCampus = true; |
49 | 0 | if (campuses != null && !campuses.isEmpty()) { |
50 | 0 | for (Campus foundCampus : campuses) { |
51 | 0 | if (foundCampus.getCode().equals(campus)) { |
52 | 0 | needDifferentCampus = false; |
53 | } | |
54 | } | |
55 | } | |
56 | 0 | return needDifferentCampus; |
57 | } | |
58 | ||
59 | public void setCampuses(List<Campus> campuses) { | |
60 | 0 | this.campuses = campuses; |
61 | 0 | } |
62 | ||
63 | } |