001 /* 002 * Copyright 2009 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 1.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl1.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.student.common.dto; 017 018 import java.io.Serializable; 019 import java.util.ArrayList; 020 import java.util.Collections; 021 import java.util.List; 022 023 import javax.xml.bind.annotation.XmlAccessType; 024 import javax.xml.bind.annotation.XmlAccessorType; 025 import javax.xml.bind.annotation.XmlAnyElement; 026 import javax.xml.bind.annotation.XmlElement; 027 import javax.xml.bind.annotation.XmlElementWrapper; 028 import javax.xml.bind.annotation.XmlType; 029 030 import org.kuali.student.common.infc.Comparison; 031 import org.kuali.student.common.infc.Criteria; 032 import org.kuali.student.common.infc.ModelBuilder; 033 import org.w3c.dom.Element; 034 035 /** 036 * Query to return some information regarding LUI to person relationships. 037 * 038 * @Author KSContractMojo 039 * @Author Kamal 040 * @Since Tue Mar 01 15:54:06 PST 2011 041 * @See <a href="https://wiki.kuali.org/display/KULSTU/luiPersonRelationCriteria+Structure">LuiPersonRelationCriteria</a> 042 */ 043 @XmlAccessorType(XmlAccessType.FIELD) 044 @XmlType(name = "CriteriaInfo", propOrder = {"comparisons", "maxResults", "_futureElements"}) 045 public class CriteriaInfo implements Criteria, Serializable { 046 047 private static final long serialVersionUID = 1L; 048 049 @XmlElementWrapper(name="comparisons") 050 @XmlElement(name="comparison") 051 private final List<ComparisonInfo> comparisons; 052 @XmlElement 053 private final Integer maxResults; 054 @XmlAnyElement 055 private final List<Element> _futureElements; 056 057 private CriteriaInfo() { 058 comparisons = null; 059 maxResults = null; 060 _futureElements = null; 061 } 062 063 @Override 064 public List<ComparisonInfo> getComparisons() { 065 return this.comparisons; 066 } 067 068 @Override 069 public Integer getMaxResults() { 070 return this.maxResults; 071 } 072 073 private CriteriaInfo(Criteria builder) { 074 if (builder.getComparisons() == null) { 075 this.comparisons = null; 076 } else { 077 List<ComparisonInfo> list = new ArrayList(builder.getComparisons().size()); 078 for (Comparison infc : builder.getComparisons()) { 079 list.add(new ComparisonInfo.Builder(infc).build()); 080 } 081 this.comparisons = Collections.unmodifiableList(list); 082 } 083 this.maxResults = builder.getMaxResults(); 084 this._futureElements = null; 085 } 086 087 public static class Builder implements ModelBuilder<CriteriaInfo>, Criteria { 088 089 private List<? extends Comparison> comparisons; 090 private Integer maxResults; 091 092 public Builder() { 093 } 094 095 public Builder(Criteria info) { 096 this.comparisons = info.getComparisons(); 097 this.maxResults = info.getMaxResults(); 098 } 099 100 public CriteriaInfo build() { 101 return new CriteriaInfo(this); 102 } 103 104 @Override 105 public List<? extends Comparison> getComparisons() { 106 return this.comparisons; 107 } 108 109 @Override 110 public Integer getMaxResults() { 111 return this.maxResults; 112 } 113 114 public void setComparisons(List<? extends Comparison> comparisons) { 115 this.comparisons = comparisons; 116 } 117 118 public void setMaxResults(Integer maxResults) { 119 this.maxResults = maxResults; 120 } 121 } 122 }