1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.api.role;
17
18 import org.kuali.rice.core.api.CoreConstants;
19 import org.kuali.rice.core.api.criteria.QueryResults;
20 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
21 import org.kuali.rice.core.api.mo.ModelBuilder;
22 import org.kuali.rice.kim.api.responsibility.Responsibility;
23 import org.w3c.dom.Element;
24
25 import javax.xml.bind.annotation.XmlAccessType;
26 import javax.xml.bind.annotation.XmlAccessorType;
27 import javax.xml.bind.annotation.XmlAnyElement;
28 import javax.xml.bind.annotation.XmlElement;
29 import javax.xml.bind.annotation.XmlElementWrapper;
30 import javax.xml.bind.annotation.XmlRootElement;
31 import javax.xml.bind.annotation.XmlType;
32 import java.util.ArrayList;
33 import java.util.Collection;
34 import java.util.Collections;
35 import java.util.List;
36
37
38
39
40 @XmlRootElement(name = RoleQueryResults.Constants.ROOT_ELEMENT_NAME)
41 @XmlAccessorType(XmlAccessType.NONE)
42 @XmlType(name = RoleQueryResults.Constants.TYPE_NAME, propOrder = {
43 RoleQueryResults.Elements.RESULTS,
44 RoleQueryResults.Elements.TOTAL_ROW_COUNT,
45 RoleQueryResults.Elements.MORE_RESULTS_AVAILALBE,
46 CoreConstants.CommonElements.FUTURE_ELEMENTS })
47 public class RoleQueryResults extends AbstractDataTransferObject implements QueryResults<Role> {
48
49 @XmlElementWrapper(name = Elements.RESULTS, required = false)
50 @XmlElement(name = Elements.RESULT_ELEM, required = false)
51 private final List<Role> results;
52
53 @XmlElement(name = Elements.TOTAL_ROW_COUNT, required = false)
54 private final Integer totalRowCount;
55
56 @XmlElement(name = Elements.MORE_RESULTS_AVAILALBE, required = true)
57 private final boolean moreResultsAvailable;
58
59 @SuppressWarnings("unused")
60 @XmlAnyElement
61 private final Collection<Element> _futureElements = null;
62
63 private RoleQueryResults() {
64 this.results = null;
65 this.totalRowCount = null;
66 this.moreResultsAvailable = false;
67 }
68
69 private RoleQueryResults(Builder builder) {
70 final List<Role> temp = new ArrayList<Role>();
71 for (Role.Builder b : builder.getResults()) {
72 if (b != null) {
73 temp.add(b.build());
74 }
75 }
76
77 this.results = Collections.unmodifiableList(temp);
78 this.totalRowCount = builder.getTotalRowCount();
79 this.moreResultsAvailable = builder.isMoreResultsAvailable();
80 }
81
82 @Override
83 public List<Role> getResults() {
84 return results;
85 }
86
87 @Override
88 public Integer getTotalRowCount() {
89 return totalRowCount;
90 }
91
92 @Override
93 public boolean isMoreResultsAvailable() {
94 return moreResultsAvailable;
95 }
96
97 public static class Builder implements ModelBuilder, QueryResults<Role.Builder> {
98
99 private List<Role.Builder> results;
100 private Integer totalRowCount;
101 private boolean moreResultsAvailable;
102
103 public static Builder create() {
104 return new Builder();
105 }
106
107 private Builder() {
108 this.results = new ArrayList<Role.Builder>();
109 this.moreResultsAvailable = false;
110 }
111
112 @Override
113 public RoleQueryResults build() {
114 return new RoleQueryResults(this);
115 }
116
117 @Override
118 public List<Role.Builder> getResults() {
119 return Collections.unmodifiableList(this.results);
120 }
121
122 public void setResults(List<Role.Builder> results) {
123 this.results = new ArrayList<Role.Builder>(results);
124 }
125
126 @Override
127 public Integer getTotalRowCount() {
128 return this.totalRowCount;
129 }
130
131 public void setTotalRowCount(Integer totalRowCount) {
132 this.totalRowCount = totalRowCount;
133 }
134
135 @Override
136 public boolean isMoreResultsAvailable() {
137 return this.moreResultsAvailable;
138 }
139
140 public void setMoreResultsAvailable(boolean moreResultsAvailable) {
141 this.moreResultsAvailable = moreResultsAvailable;
142 }
143
144 }
145
146
147
148
149 public static class Constants {
150 public final static String ROOT_ELEMENT_NAME = "roleQueryResults";
151 public final static String TYPE_NAME = "RoleQueryResultsType";
152 }
153
154
155
156
157
158 public static class Elements {
159 public final static String RESULTS = "results";
160 public final static String RESULT_ELEM = "role";
161 public final static String TOTAL_ROW_COUNT = "totalRowCount";
162 public final static String MORE_RESULTS_AVAILALBE = "moreResultsAvailable";
163 }
164
165 }