View Javadoc
1   /**
2    * Copyright 2011-2012 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.people.entity;
16  
17  import java.util.ArrayList;
18  import java.util.List;
19  import javax.xml.bind.annotation.XmlElement;
20  import javax.xml.bind.annotation.XmlRootElement;
21  import org.apache.commons.collections.CollectionUtils;
22  import org.kuali.mobility.people.service.util.GroupTransform;
23  import org.kuali.mobility.people.service.util.PersonTransform;
24  
25  /**
26   * Implementation of a search result
27   * @author Kuali Mobility Team (mobility.collab@kuali.org)
28   * @since
29   */
30  @XmlRootElement(name="searchResults")
31  public class SearchResultImpl implements SearchResult {
32  	
33  	/**
34  	 * Error String
35  	 */
36  	private String error;
37  
38  	/**
39  	 * Search criteria
40  	 */
41  	private SearchCriteria searchCriteria;
42  
43  	/**
44  	 * List of people
45  	 */
46  	//@XmlElementWrapper
47  	@XmlElement(name="people")
48  	private List<PersonImpl> people;
49  
50  	/**
51  	 * List of groups
52  	 */
53  	// @XmlElementWrapper
54  	@XmlElement(name="groups")
55  	private List<GroupImpl> groups;
56  
57  	/**
58  	 * 
59  	 * Creates a new instance of a <code>SearchResultImpl</code>
60  	 */
61  	public SearchResultImpl() {
62  		people = new ArrayList<PersonImpl>();
63  		groups = new ArrayList<GroupImpl>();
64  	}
65  
66  	/*
67  	 * (non-Javadoc)
68  	 * @see org.kuali.mobility.people.entity.SearchResult#getError()
69  	 */
70  	@Override
71  	public String getError() {
72  		return error;
73  	}
74  
75  	/*
76  	 * (non-Javadoc)
77  	 * @see org.kuali.mobility.people.entity.SearchResult#setError(java.lang.String)
78  	 */
79  	@Override
80  	public void setError(String error) {
81  		this.error = error;
82  	}
83  
84  	/*
85  	 * (non-Javadoc)
86  	 * @see org.kuali.mobility.people.entity.SearchResult#getPeople()
87  	 */
88  	@Override
89  	public List<PersonImpl> getPeople() {
90  		return people;
91  	}
92  
93  	/*
94  	 * (non-Javadoc)
95  	 * @see org.kuali.mobility.people.entity.SearchResult#setPeople(java.util.List)
96  	 */
97  	@Override
98  	public void setPeople(List<? extends Person> people) {
99  		CollectionUtils.collect( people, new PersonTransform(), this.people );
100 	}
101 
102 	/*
103 	 * (non-Javadoc)
104 	 * @see org.kuali.mobility.people.entity.SearchResult#getGroups()
105 	 */
106 	@Override
107 	public List<GroupImpl> getGroups() {
108 		return groups;
109 	}
110 
111 	/*
112 	 * (non-Javadoc)
113 	 * @see org.kuali.mobility.people.entity.SearchResult#setGroups(java.util.List)
114 	 */
115 	@Override
116 	public void setGroups(List<? extends Group> groups) {
117 		CollectionUtils.collect( groups, new GroupTransform(), this.groups );
118 	}
119 
120 	/*
121 	 * (non-Javadoc)
122 	 * @see org.kuali.mobility.people.entity.SearchResult#getSearchCriteria()
123 	 */
124 	public SearchCriteria getSearchCriteria() {
125 		return searchCriteria;
126 	}
127 
128 	/*
129 	 * (non-Javadoc)
130 	 * @see org.kuali.mobility.people.entity.SearchResult#setSearchCriteria(org.kuali.mobility.people.entity.SearchCriteria)
131 	 */
132 	public void setSearchCriteria(SearchCriteria searchCriteria) {
133 		this.searchCriteria = searchCriteria;
134 	}
135 }