| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.student.r2.core.search.dto; |
| 18 | |
|
| 19 | |
import java.io.Serializable; |
| 20 | |
import java.util.ArrayList; |
| 21 | |
import java.util.List; |
| 22 | |
|
| 23 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 24 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 25 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 26 | |
import javax.xml.bind.annotation.XmlElement; |
| 27 | |
import javax.xml.bind.annotation.XmlType; |
| 28 | |
|
| 29 | |
import org.kuali.student.r2.core.search.infc.SearchRequest; |
| 30 | |
import org.kuali.student.r2.core.search.infc.SearchParam; |
| 31 | |
import org.w3c.dom.Element; |
| 32 | |
|
| 33 | |
@XmlAccessorType(XmlAccessType.FIELD) |
| 34 | |
@XmlType(name = "SearchRequestInfo", propOrder = { |
| 35 | |
"searchKey", "params", "sortColumn", "sortDirection", |
| 36 | |
"startAt", "maxResults", "neededTotalResults", |
| 37 | |
"_futureElements" }) |
| 38 | |
|
| 39 | |
public class SearchRequestInfo |
| 40 | |
implements SearchRequest, Serializable { |
| 41 | |
|
| 42 | |
private static final long serialVersionUID = 1L; |
| 43 | |
|
| 44 | |
@XmlElement |
| 45 | |
private String searchKey; |
| 46 | |
|
| 47 | |
@XmlElement |
| 48 | |
private List<SearchParamInfo> params; |
| 49 | |
|
| 50 | |
@XmlElement |
| 51 | |
private String sortColumn; |
| 52 | |
|
| 53 | |
@XmlElement |
| 54 | |
private SortDirection sortDirection; |
| 55 | |
|
| 56 | |
@XmlElement |
| 57 | |
private Integer startAt; |
| 58 | |
|
| 59 | |
@XmlElement |
| 60 | |
private Integer maxResults; |
| 61 | |
|
| 62 | |
@XmlElement |
| 63 | |
private Boolean neededTotalResults; |
| 64 | |
|
| 65 | |
@XmlAnyElement |
| 66 | |
private List<Element> _futureElements; |
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | 0 | public SearchRequestInfo() { |
| 73 | 0 | } |
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | 0 | public SearchRequestInfo(SearchRequest request) { |
| 81 | 0 | if (request != null) { |
| 82 | 0 | this.searchKey = request.getSearchKey(); |
| 83 | |
|
| 84 | 0 | this.params = new ArrayList<SearchParamInfo>(); |
| 85 | 0 | for (SearchParam param : request.getParams()) { |
| 86 | 0 | this.params.add(new SearchParamInfo(param)); |
| 87 | |
} |
| 88 | |
|
| 89 | 0 | this.sortColumn = request.getSortColumn(); |
| 90 | 0 | this.sortDirection = request.getSortDirection(); |
| 91 | 0 | this.startAt = request.getStartAt(); |
| 92 | 0 | this.maxResults = request.getMaxResults(); |
| 93 | 0 | this.neededTotalResults = request.getNeededTotalResults(); |
| 94 | |
} |
| 95 | 0 | } |
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | 0 | public SearchRequestInfo(String searchKey) { |
| 103 | 0 | this.searchKey = searchKey; |
| 104 | 0 | } |
| 105 | |
|
| 106 | |
public void addParam(String key, String value) { |
| 107 | 0 | getParams().add(new SearchParamInfo(key, value)); |
| 108 | 0 | } |
| 109 | |
|
| 110 | |
public void addParam(String key, List<String> value) { |
| 111 | 0 | getParams().add(new SearchParamInfo(key, value)); |
| 112 | 0 | } |
| 113 | |
|
| 114 | |
@Override |
| 115 | |
public String getSearchKey() { |
| 116 | 0 | return searchKey; |
| 117 | |
} |
| 118 | |
|
| 119 | |
public void setSearchKey(String searchKey) { |
| 120 | 0 | this.searchKey = searchKey; |
| 121 | 0 | } |
| 122 | |
|
| 123 | |
@Override |
| 124 | |
public List<SearchParamInfo> getParams() { |
| 125 | 0 | if(params == null) { |
| 126 | 0 | params = new ArrayList<SearchParamInfo>(); |
| 127 | |
} |
| 128 | |
|
| 129 | 0 | return params; |
| 130 | |
} |
| 131 | |
|
| 132 | |
public void setParams(List<SearchParamInfo> params) { |
| 133 | 0 | this.params = params; |
| 134 | 0 | } |
| 135 | |
|
| 136 | |
@Override |
| 137 | |
public String getSortColumn() { |
| 138 | 0 | return sortColumn; |
| 139 | |
} |
| 140 | |
|
| 141 | |
public void setSortColumn(String sortColumn) { |
| 142 | 0 | this.sortColumn = sortColumn; |
| 143 | 0 | } |
| 144 | |
|
| 145 | |
@Override |
| 146 | |
public SortDirection getSortDirection() { |
| 147 | 0 | return sortDirection; |
| 148 | |
} |
| 149 | |
|
| 150 | |
public void setSortDirection(SortDirection sortDirection) { |
| 151 | 0 | this.sortDirection = sortDirection; |
| 152 | 0 | } |
| 153 | |
|
| 154 | |
@Override |
| 155 | |
public Integer getStartAt() { |
| 156 | 0 | return startAt; |
| 157 | |
} |
| 158 | |
|
| 159 | |
public void setStartAt(Integer startAt) { |
| 160 | 0 | this.startAt = startAt; |
| 161 | 0 | } |
| 162 | |
|
| 163 | |
@Override |
| 164 | |
public Integer getMaxResults() { |
| 165 | 0 | return maxResults; |
| 166 | |
} |
| 167 | |
|
| 168 | |
public void setMaxResults(Integer maxResults) { |
| 169 | 0 | this.maxResults = maxResults; |
| 170 | 0 | } |
| 171 | |
|
| 172 | |
@Override |
| 173 | |
public Boolean getNeededTotalResults() { |
| 174 | 0 | return neededTotalResults; |
| 175 | |
} |
| 176 | |
|
| 177 | |
public void setNeededTotalResults(Boolean neededTotalResults) { |
| 178 | 0 | this.neededTotalResults = neededTotalResults; |
| 179 | 0 | } |
| 180 | |
|
| 181 | |
@Override |
| 182 | |
public String toString() { |
| 183 | 0 | return "SearchRequest [searchKey=" + searchKey + ", params=" + params |
| 184 | |
+ ", sortColumn=" + sortColumn + ", sortDirection=" |
| 185 | |
+ sortDirection + ", startAt=" + startAt + ", maxResults=" |
| 186 | |
+ maxResults + ", neededTotalResults=" + neededTotalResults |
| 187 | |
+ "]"; |
| 188 | |
} |
| 189 | |
|
| 190 | |
@Override |
| 191 | |
public boolean equals(Object o) { |
| 192 | 0 | if (this == o) return true; |
| 193 | 0 | if (o == null || getClass() != o.getClass()) return false; |
| 194 | |
|
| 195 | 0 | SearchRequestInfo that = (SearchRequestInfo) o; |
| 196 | |
|
| 197 | 0 | if (maxResults != null ? !maxResults.equals(that.maxResults) : that.maxResults != null) return false; |
| 198 | 0 | if (neededTotalResults != null ? !neededTotalResults.equals(that.neededTotalResults) : that.neededTotalResults != null) |
| 199 | 0 | return false; |
| 200 | 0 | if (params != null ? !params.equals(that.params) : that.params != null) return false; |
| 201 | 0 | if (searchKey != null ? !searchKey.equals(that.searchKey) : that.searchKey != null) return false; |
| 202 | 0 | if (sortColumn != null ? !sortColumn.equals(that.sortColumn) : that.sortColumn != null) return false; |
| 203 | 0 | if (sortDirection != that.sortDirection) return false; |
| 204 | 0 | if (startAt != null ? !startAt.equals(that.startAt) : that.startAt != null) return false; |
| 205 | |
|
| 206 | 0 | return true; |
| 207 | |
} |
| 208 | |
|
| 209 | |
@Override |
| 210 | |
public int hashCode() { |
| 211 | 0 | int result = searchKey != null ? searchKey.hashCode() : 0; |
| 212 | 0 | result = 31 * result + (params != null ? params.hashCode() : 0); |
| 213 | 0 | result = 31 * result + (sortColumn != null ? sortColumn.hashCode() : 0); |
| 214 | 0 | result = 31 * result + (sortDirection != null ? sortDirection.hashCode() : 0); |
| 215 | 0 | result = 31 * result + (startAt != null ? startAt.hashCode() : 0); |
| 216 | 0 | result = 31 * result + (maxResults != null ? maxResults.hashCode() : 0); |
| 217 | 0 | result = 31 * result + (neededTotalResults != null ? neededTotalResults.hashCode() : 0); |
| 218 | 0 | return result; |
| 219 | |
} |
| 220 | |
} |