001: package com.sourcetap.sfa.ui;
002:
003: import java.util.ArrayList;
004: import java.util.Iterator;
005: import java.util.List;
006:
007: import org.ofbiz.base.util.UtilMisc;
008: import org.ofbiz.entity.GenericDelegator;
009: import org.ofbiz.entity.GenericEntityException;
010: import org.ofbiz.entity.GenericValue;
011:
012: public class UIReportCriteria {
013: public static final String module = UIReportCriteria.class
014: .getName();
015:
016: protected String reportCriteriaId;
017: protected String reportId;
018: protected String attributeId;
019: protected String displayTypeId;
020: protected String displayObjectId;
021: protected String queryOperatorId;
022: protected String attributeValue;
023: protected String displayLabel;
024:
025: protected boolean attNameLoaded = false;
026: protected String attributeName;
027: protected String entityName;
028:
029: protected String sectionId;
030: protected String sectionName;
031:
032: protected GenericDelegator delegator;
033:
034: public static List loadFromGVL(List reportCriteriaGVL) {
035: List retList = new ArrayList();
036: Iterator iter = reportCriteriaGVL.iterator();
037: while (iter.hasNext()) {
038: GenericValue gv = (GenericValue) iter.next();
039: retList.add(new UIReportCriteria(gv));
040: }
041: return retList;
042: }
043:
044: public UIReportCriteria(GenericValue genricValue) {
045: setReportCriteriaId(genricValue.getString("reportCriteriaId"));
046: setReportId(genricValue.getString("reportId"));
047: setAttributeId(genricValue.getString("attributeId"));
048: setDisplayTypeId(genricValue.getString("displayTypeId"));
049: setDisplayObjectId(genricValue.getString("displayObjectId"));
050: setQueryOperatorId(genricValue.getString("queryOperatorId"));
051: setAttributeValue(genricValue.getString("attributeValue"));
052: setDisplayLabel(genricValue.getString("displayLabel"));
053:
054: setDelegator(genricValue.getDelegator());
055: }
056:
057: public UIReportCriteria(String attributeId, String displayTypeId,
058: String displayObjectId, String queryOperatorId,
059: String attributeValue, String displayLabel) {
060: setAttributeId(attributeId);
061: setDisplayTypeId(displayTypeId);
062: setDisplayObjectId(displayObjectId);
063: setQueryOperatorId(queryOperatorId);
064: setAttributeValue(attributeValue);
065: setDisplayLabel(displayLabel);
066:
067: }
068:
069: public void loadEntityAttributeInfo(GenericDelegator delegator,
070: String attributeId) {
071: try {
072: List eaGVL = delegator.findByAnd("UiEntityAttribute",
073: UtilMisc.toMap("attributeId", attributeId));
074: GenericValue eaGV = (GenericValue) eaGVL.get(0);
075:
076: setEntityName(eaGV.getString("entityName"));
077: setAttributeName(eaGV.getString("attributeName"));
078: attNameLoaded = true;
079:
080: } catch (GenericEntityException e) {
081: // TODO Auto-generated catch block
082: e.printStackTrace();
083: }
084: }
085:
086: /**
087: * @return
088: */
089: public String getAttributeId() {
090: return attributeId;
091: }
092:
093: /**
094: * @return
095: */
096: public String getAttributeName() {
097: if (!attNameLoaded)
098: loadEntityAttributeInfo(getDelegator(), getAttributeId());
099:
100: return attributeName;
101: }
102:
103: /**
104: * @return
105: */
106: public String getAttributeValue() {
107: return attributeValue;
108: }
109:
110: /**
111: * @return
112: */
113: public GenericDelegator getDelegator() {
114: return delegator;
115: }
116:
117: /**
118: * @return
119: */
120: public String getDisplayObjectId() {
121: return displayObjectId;
122: }
123:
124: /**
125: * @return
126: */
127: public String getDisplayTypeId() {
128: return displayTypeId;
129: }
130:
131: /**
132: * @return
133: */
134: public String getEntityName() {
135: if (!attNameLoaded)
136: loadEntityAttributeInfo(getDelegator(), getAttributeId());
137:
138: return entityName;
139: }
140:
141: /**
142: * @return
143: */
144: public String getQueryOperatorId() {
145: return queryOperatorId;
146: }
147:
148: /**
149: * @return
150: */
151: public String getReportCriteriaId() {
152: return reportCriteriaId;
153: }
154:
155: /**
156: * @return
157: */
158: public String getReportId() {
159: return reportId;
160: }
161:
162: /**
163: * @return
164: */
165: public String getSectionId() {
166: return sectionId;
167: }
168:
169: /**
170: * @return
171: */
172: public String getSectionName() {
173: return sectionName;
174: }
175:
176: /**
177: * @param string
178: */
179: public void setAttributeId(String string) {
180: attributeId = string;
181: }
182:
183: /**
184: * @param string
185: */
186: public void setAttributeName(String string) {
187: attributeName = string;
188: attNameLoaded = true;
189: }
190:
191: /**
192: * @param string
193: */
194: public void setAttributeValue(String string) {
195: attributeValue = string;
196: }
197:
198: /**
199: * @param delegator
200: */
201: public void setDelegator(GenericDelegator delegator) {
202: this .delegator = delegator;
203: }
204:
205: /**
206: * @param string
207: */
208: public void setDisplayObjectId(String string) {
209: displayObjectId = string;
210: }
211:
212: /**
213: * @param string
214: */
215: public void setDisplayTypeId(String string) {
216: displayTypeId = string;
217: }
218:
219: /**
220: * @param string
221: */
222: public void setEntityName(String string) {
223: entityName = string;
224: attNameLoaded = true;
225: }
226:
227: /**
228: * @param string
229: */
230: public void setQueryOperatorId(String string) {
231: queryOperatorId = string;
232: }
233:
234: /**
235: * @param string
236: */
237: public void setReportCriteriaId(String string) {
238: reportCriteriaId = string;
239: }
240:
241: /**
242: * @param string
243: */
244: public void setReportId(String string) {
245: reportId = string;
246: }
247:
248: /**
249: * @param string
250: */
251: public void setSectionId(String string) {
252: sectionId = string;
253: }
254:
255: /**
256: * @param string
257: */
258: public void setSectionName(String string) {
259: sectionName = string;
260: }
261:
262: /**
263: * @return
264: */
265: public String getDisplayLabel() {
266: return displayLabel;
267: }
268:
269: /**
270: * @param string
271: */
272: public void setDisplayLabel(String string) {
273: displayLabel = string;
274: }
275:
276: }
|