001: /*
002: *
003: * Copyright (c) 2004 SourceTap - www.sourcetap.com
004: *
005: * The contents of this file are subject to the SourceTap Public License
006: * ("License"); You may not use this file except in compliance with the
007: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
008: * Software distributed under the License is distributed on an "AS IS" basis,
009: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
010: * the specific language governing rights and limitations under the License.
011: *
012: * The above copyright notice and this permission notice shall be included
013: * in all copies or substantial portions of the Software.
014: *
015: */
016:
017: package com.sourcetap.sfa.ui;
018:
019: import org.ofbiz.entity.GenericDelegator;
020: import org.ofbiz.entity.GenericValue;
021: import org.ofbiz.entity.condition.EntityComparisonOperator;
022:
023: /**
024: * This class holds the attributes of one value within a query used in the UI builder.
025: *
026: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
027: * @see #UIQuery
028: */
029: public class UIQueryValue {
030: public static final String module = UIQueryValue.class.getName();
031:
032: /*
033: * Query Value ID - Uniquely identifies this query value
034: */
035: protected String queryValueId = "";
036:
037: /*
038: * Query ID - Uniquely identifies the query to which this query value is attached
039: */
040: protected String queryId = "";
041:
042: /*
043: * Attribute ID - Uniquely identifies an attribute defined in the UI data
044: */
045: protected String attributeId = "";
046:
047: /*
048: * Attribute Value - The value to be compared to the specified attribute on entities in the data base
049: * when the query is executed
050: */
051: protected String attributeValue = "";
052:
053: /*
054: * Entity Operator - The operator to be used to compare the value to the specified attribute on
055: * entities in the data base when the query is executed
056: */
057: protected EntityComparisonOperator entityOperator = null;
058:
059: /*
060: * Dislay Type Id - The type of the field being queried, which is used to determine how to add the condition.
061: * This allows for SELECT fields to be searched on lookup tables
062: */
063: protected String displayTypeId = "";
064: /*
065: * Dislay Object Id - The display object of the field being queried, which is used to determine how to add the condition.
066: * This allows for SELECT fields to be searched on lookup tables
067: */
068: protected String displayObjectId = "";
069:
070: /**
071: * Basic constructor
072: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
073: */
074: public UIQueryValue() {
075: }
076:
077: /**
078: * Constructor with initial values
079: * @param queryvalueId_ Query Value ID - Uniquely identifies this query value
080: * @param queryId_ Query ID - Uniquely identifies the query to which this query value is attached
081: * @param attributeId_ Attribute ID - Uniquely identifies an attribute defined in the UI data
082: * @param attributeValue_ The value to be compared to the specified attribute on entities in the data base
083: * when the query is executed
084: * @param entityOperator_ The operator to be used to compare the value to the specified attribute on
085: * entities in the data base when the query is executed
086: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
087: */
088: public UIQueryValue(String queryValueId_, String queryId_,
089: String attributeId_, String attributeValue_,
090: EntityComparisonOperator entityOperator_,
091: String displayTypeId_, String displayObjectId_) {
092:
093: setQueryValueId(queryValueId_);
094: setAttributeId(attributeId_);
095: setQueryId(queryId_);
096: setAttributeValue(attributeValue_);
097: setEntityOperator(entityOperator_);
098: setDisplayTypeId(displayTypeId_);
099: setDisplayObjectId(displayObjectId_);
100: }
101:
102: /**
103: * Gets the Query Value ID
104: * @return_ Query Value ID - Uniquely identifies this query value
105: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
106: */
107: public String getQueryValueId() {
108: return (queryValueId == null) ? "" : queryValueId;
109: }
110:
111: /**
112: * Sets the Query Value ID
113: * @param queryvalueId_ Query Value ID - Uniquely identifies this query value
114: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
115: */
116: public void setQueryValueId(String queryValueId_) {
117: queryValueId = queryValueId_;
118:
119: return;
120: }
121:
122: /**
123: * Gets the Query ID
124: * @param queryId_ Query ID - Uniquely identifies the query to which this query value is attached
125: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
126: */
127: public String getQueryId() {
128: return (queryId == null) ? "" : queryId;
129: }
130:
131: /**
132: * Sets the Query ID
133: * @return Query ID - Uniquely identifies the query to which this query value is attached
134: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
135: */
136: public void setQueryId(String queryId_) {
137: queryId = queryId_;
138:
139: return;
140: }
141:
142: /**
143: * Gets the attribute ID
144: * @param attributeId_ Attribute ID - Uniquely identifies an attribute defined in the UI data
145: */
146: public String getAttributeId() {
147: return (attributeId == null) ? "" : attributeId;
148: }
149:
150: /**
151: * Sets the attribute ID
152: * @return Attribute ID - Uniquely identifies an attribute defined in the UI data
153: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
154: */
155: public void setAttributeId(String attributeId_) {
156: attributeId = attributeId_;
157:
158: return;
159: }
160:
161: /**
162: * Gets the Attribute Value
163: * return Attribute Value - The value to be compared to the specified attribute on entities in the data base
164: * when the query is executed
165: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
166: */
167: public String getAttributeValue() {
168: return (attributeValue == null) ? "" : attributeValue;
169: }
170:
171: /**
172: * Sets the Attribute Value
173: * @param attributeValue_ Attribute Value - The value to be compared to the specified attribute on entities in the data base
174: * when the query is executed
175: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
176: */
177: public void setAttributeValue(String attributeValue_) {
178: attributeValue = attributeValue_;
179:
180: return;
181: }
182:
183: /**
184: * Gets the Query Operator
185: * @return The operator to be used to compare the value to the specified attribute on
186: * entities in the data base when the query is executed
187: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
188: */
189: public EntityComparisonOperator getEntityOperator() {
190: return entityOperator;
191: }
192:
193: /**
194: * Sets the Query Operator
195: * @param entityOperator_ The operator to be used to compare the value to the specified attribute on
196: * entities in the data base when the query is executed
197: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
198: */
199: public void setEntityOperator(
200: EntityComparisonOperator entityOperator_) {
201: entityOperator = entityOperator_;
202:
203: return;
204: }
205:
206: /**
207: * Gets the Display Type ID
208: * @return_ Display Type ID - What type is used to display the field
209: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
210: */
211: public String getDisplayTypeId() {
212: return (displayTypeId == null) ? "" : displayTypeId;
213: }
214:
215: /**
216: * Sets the Display Type ID
217: * @param displayTypeId_ - the display type for the field
218: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
219: */
220: public void setDisplayTypeId(String displayTypeId_) {
221: displayTypeId = displayTypeId_;
222: return;
223: }
224:
225: /**
226: * Gets the Display Object ID
227: * @return_ Display Type ID - What object is used to display the field
228: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
229: */
230: public String getDisplayObjectId() {
231: return (displayObjectId == null) ? "" : displayObjectId;
232: }
233:
234: /**
235: * Sets the Display Object ID
236: * @param displayObjectId_ - the display object for the field
237: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
238: */
239: public void setDisplayObjectId(String displayObjectId_) {
240: displayObjectId = displayObjectId_;
241: return;
242: }
243:
244: /**
245: * Creates a generic value for this query value.
246: * @param delegator Generic delegator object required to attach to the correct data source
247: * @return Generic value representing this query value
248: * @author <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
249: */
250: public GenericValue toGenericValue(GenericDelegator delegator) {
251:
252: GenericValue uiQueryValueGV = new GenericValue(delegator
253: .getModelEntity("UiQueryValue"));
254: uiQueryValueGV.setDelegator(delegator);
255: uiQueryValueGV.set("queryValueId", getQueryValueId());
256: uiQueryValueGV.set("queryId", getQueryId());
257: uiQueryValueGV.set("attributeId", getAttributeId());
258: uiQueryValueGV.set("attributeValue", getAttributeValue());
259: uiQueryValueGV.set("queryOperatorId",
260: (getEntityOperator() == null) ? "1" : String
261: .valueOf(getEntityOperator().getId()));
262: uiQueryValueGV.set("displayTypeId", getDisplayTypeId());
263: uiQueryValueGV.set("displayObjectId", getDisplayObjectId());
264:
265: return uiQueryValueGV;
266: }
267: }
|