001
014
015 package com.liferay.portal.kernel.dao.orm;
016
017 import com.liferay.portal.kernel.util.OrderByComparator;
018 import com.liferay.portal.kernel.util.TableNameOrderByComparator;
019 import com.liferay.portal.kernel.workflow.WorkflowConstants;
020
021 import java.io.Serializable;
022
023 import java.util.HashMap;
024 import java.util.Map;
025
026
029 public class QueryDefinition {
030
031 public QueryDefinition() {
032 }
033
034 public QueryDefinition(int status) {
035 this(status, 0, false);
036 }
037
038 public QueryDefinition(
039 int status, boolean excludeStatus, int start, int end,
040 OrderByComparator orderByComparator) {
041
042 this(status, excludeStatus, 0, false, start, end, orderByComparator);
043 }
044
045 public QueryDefinition(
046 int status, boolean excludeStatus, long ownerUserId,
047 boolean includeOwner, int start, int end,
048 OrderByComparator orderByComparator) {
049
050 _status = status;
051 _excludeStatus = excludeStatus;
052 _ownerUserId = ownerUserId;
053 _includeOwner = includeOwner;
054 _start = start;
055 _end = end;
056
057 setOrderByComparator(orderByComparator);
058 }
059
060 public QueryDefinition(
061 int status, int start, int end, OrderByComparator orderByComparator) {
062
063 this(status, 0, false, start, end, orderByComparator);
064 }
065
066 public QueryDefinition(int status, long ownerUserId, boolean includeOwner) {
067 if (status == WorkflowConstants.STATUS_ANY) {
068 setStatus(WorkflowConstants.STATUS_IN_TRASH, true);
069 }
070 else {
071 setStatus(status);
072 }
073
074 _ownerUserId = ownerUserId;
075 _includeOwner = includeOwner;
076 }
077
078 public QueryDefinition(
079 int status, long ownerUserId, boolean includeOwner, int start, int end,
080 OrderByComparator orderByComparator) {
081
082 if (status == WorkflowConstants.STATUS_ANY) {
083 setStatus(WorkflowConstants.STATUS_IN_TRASH, true);
084 }
085 else {
086 setStatus(status);
087 }
088
089 _ownerUserId = ownerUserId;
090 _includeOwner = includeOwner;
091 _start = start;
092 _end = end;
093
094 setOrderByComparator(orderByComparator);
095 }
096
097 public Serializable getAttribute(String name) {
098 if (_attributes == null) {
099 return null;
100 }
101
102 return _attributes.get(name);
103 }
104
105 public Map<String, Serializable> getAttributes() {
106 return _attributes;
107 }
108
109 public int getEnd() {
110 return _end;
111 }
112
113 public OrderByComparator getOrderByComparator() {
114 return _orderByComparator;
115 }
116
117 public OrderByComparator getOrderByComparator(String tableName) {
118 if (_orderByComparator == null) {
119 return null;
120 }
121
122 return new TableNameOrderByComparator(_orderByComparator, tableName);
123 }
124
125 public long getOwnerUserId() {
126 return _ownerUserId;
127 }
128
129 public int getStart() {
130 return _start;
131 }
132
133 public int getStatus() {
134 return _status;
135 }
136
137 public boolean isExcludeStatus() {
138 return _excludeStatus;
139 }
140
141 public boolean isIncludeOwner() {
142 return _includeOwner;
143 }
144
145 public void setAttribute(String name, Serializable value) {
146 if (_attributes == null) {
147 _attributes = new HashMap<String, Serializable>();
148 }
149
150 _attributes.put(name, value);
151 }
152
153 public void setAttributes(Map<String, Serializable> attributes) {
154 _attributes = attributes;
155 }
156
157 public void setEnd(int end) {
158 _end = end;
159 }
160
161 public void setIncludeOwner(boolean includeOwner) {
162 _includeOwner = includeOwner;
163 }
164
165 public void setOrderByComparator(OrderByComparator orderByComparator) {
166 _orderByComparator = orderByComparator;
167 }
168
169 public void setOwnerUserId(long ownerUserId) {
170 _ownerUserId = ownerUserId;
171 }
172
173 public void setStart(int start) {
174 _start = start;
175 }
176
177 public void setStatus(int status) {
178 setStatus(status, false);
179 }
180
181 public void setStatus(int status, boolean exclude) {
182 _excludeStatus = exclude;
183 _status = status;
184 }
185
186 private Map<String, Serializable> _attributes;
187 private int _end = QueryUtil.ALL_POS;
188 private boolean _excludeStatus;
189 private boolean _includeOwner;
190 private OrderByComparator _orderByComparator;
191 private long _ownerUserId;
192 private int _start = QueryUtil.ALL_POS;
193 private int _status = WorkflowConstants.STATUS_ANY;
194
195 }