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.Debug;
008: import org.ofbiz.base.util.UtilMisc;
009: import org.ofbiz.entity.GenericDelegator;
010: import org.ofbiz.entity.GenericEntityException;
011: import org.ofbiz.entity.GenericValue;
012:
013: public class UIReportField {
014: public static final String module = UIReportField.class.getName();
015:
016: protected String reportFieldId;
017: protected String reportId;
018: protected String attributeId;
019: protected String displayTypeId;
020: protected String displayObjectId;
021: protected String groupBy;
022: protected int displayOrder;
023: protected String displayLabel;
024: protected String sqlFunction;
025:
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 reportFieldGVL) {
035: List retList = new ArrayList();
036: Iterator iter = reportFieldGVL.iterator();
037: while (iter.hasNext()) {
038: GenericValue gv = (GenericValue) iter.next();
039: retList.add(new UIReportField(gv));
040: }
041: return retList;
042: }
043:
044: public UIReportField(GenericValue reportFieldGV) {
045: setReportFieldId(reportFieldGV.getString("reportFieldId"));
046: setReportId(reportFieldGV.getString("reportId"));
047: setAttributeId(reportFieldGV.getString("attributeId"));
048: setDisplayTypeId(reportFieldGV.getString("displayTypeId"));
049: setDisplayObjectId(reportFieldGV.getString("displayObjectId"));
050: setGroupBy(reportFieldGV.getString("groupBy"));
051: setSqlFunction(reportFieldGV.getString("sqlFunction"));
052:
053: setDisplayOrder(reportFieldGV.getString("displayOrder"));
054: setDisplayLabel(reportFieldGV.getString("displayLabel"));
055:
056: setDelegator(reportFieldGV.getDelegator());
057: loadEntityAttributeInfo(delegator, attributeId);
058: }
059:
060: public UIReportField(String attributeId, String displayTypeId,
061: String displayObjectId, String displayLabel,
062: String displayOrder) {
063: setAttributeId(attributeId);
064: setDisplayTypeId(displayTypeId);
065: setDisplayObjectId(displayObjectId);
066: setDisplayLabel(displayLabel);
067: setDisplayOrder(displayOrder);
068: }
069:
070: public void loadEntityAttributeInfo(GenericDelegator delegator,
071: String attributeId) {
072: try {
073: List eaGVL = delegator.findByAnd("UiEntityAttribute",
074: UtilMisc.toMap("attributeId", attributeId));
075: GenericValue eaGV = (GenericValue) eaGVL.get(0);
076:
077: setEntityName(eaGV.getString("entityName"));
078: setAttributeName(eaGV.getString("attributeName"));
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: return attributeName;
098: }
099:
100: /**
101: * @return
102: */
103: public GenericDelegator getDelegator() {
104: return delegator;
105: }
106:
107: /**
108: * @return
109: */
110: public String getDisplayLabel() {
111: return displayLabel;
112: }
113:
114: /**
115: * @return
116: */
117: public String getDisplayObjectId() {
118: return displayObjectId;
119: }
120:
121: /**
122: * @return
123: */
124: public int getDisplayOrder() {
125: return displayOrder;
126: }
127:
128: /**
129: * @return
130: */
131: public String getDisplayTypeId() {
132: return displayTypeId;
133: }
134:
135: /**
136: * @return
137: */
138: public String getEntityName() {
139: return entityName;
140: }
141:
142: /**
143: * @return
144: */
145: public String getGroupBy() {
146: return groupBy;
147: }
148:
149: /**
150: * @return
151: */
152: public String getReportFieldId() {
153: return reportFieldId;
154: }
155:
156: /**
157: * @return
158: */
159: public String getReportId() {
160: return reportId;
161: }
162:
163: /**
164: * @return
165: */
166: public String getSectionId() {
167: return sectionId;
168: }
169:
170: /**
171: * @return
172: */
173: public String getSectionName() {
174: return sectionName;
175: }
176:
177: /**
178: * @param string
179: */
180: public void setAttributeId(String string) {
181: attributeId = string;
182: }
183:
184: /**
185: * @param string
186: */
187: public void setAttributeName(String string) {
188: attributeName = string;
189: }
190:
191: /**
192: * @param delegator
193: */
194: public void setDelegator(GenericDelegator delegator) {
195: this .delegator = delegator;
196: }
197:
198: /**
199: * @param string
200: */
201: public void setDisplayLabel(String string) {
202: displayLabel = string;
203: }
204:
205: /**
206: * @param string
207: */
208: public void setDisplayObjectId(String string) {
209: displayObjectId = string;
210: }
211:
212: /**
213: * @param intVal
214: */
215: public void setDisplayOrder(int intVal) {
216: displayOrder = intVal;
217: }
218:
219: /**
220: * @param intVal
221: */
222: public void setDisplayOrder(String string) {
223: try {
224: setDisplayOrder(Integer.valueOf(string).intValue());
225: } catch (NumberFormatException e) {
226: setDisplayOrder(0);
227: Debug.logError("invalid number:" + string, module);
228: }
229: }
230:
231: /**
232: * @param string
233: */
234: public void setDisplayTypeId(String string) {
235: displayTypeId = string;
236: }
237:
238: /**
239: * @param string
240: */
241: public void setEntityName(String string) {
242: entityName = string;
243: }
244:
245: /**
246: * @param string
247: */
248: public void setGroupBy(String string) {
249: groupBy = string;
250: }
251:
252: /**
253: * @param string
254: */
255: public void setReportFieldId(String string) {
256: reportFieldId = string;
257: }
258:
259: /**
260: * @param string
261: */
262: public void setReportId(String string) {
263: reportId = string;
264: }
265:
266: /**
267: * @param string
268: */
269: public void setSectionId(String string) {
270: sectionId = string;
271: }
272:
273: /**
274: * @param string
275: */
276: public void setSectionName(String string) {
277: sectionName = string;
278: }
279:
280: /**
281: * @return
282: */
283: public String getSqlFunction() {
284: return sqlFunction;
285: }
286:
287: /**
288: * @param string
289: */
290: public void setSqlFunction(String string) {
291: sqlFunction = string;
292: }
293:
294: }
|