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