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.base.util.UtilTimer;
020: import org.ofbiz.entity.GenericDelegator;
021: import org.ofbiz.entity.GenericEntityException;
022: import org.ofbiz.entity.GenericValue;
023:
024: /**
025: * DOCUMENT ME!
026: *
027: */
028: public class UIFieldInfo {
029: public static final String module = UIFieldInfo.class.getName();
030: private static final boolean TIMER = false;
031: protected static final int DEFAULT_WIDTH = 100;
032: protected String sectionId = "";
033: protected String partyId = "";
034: protected String attributeId = "";
035: protected String displayLabel = "";
036: protected int displayLength = DEFAULT_WIDTH;
037: protected int maxLength = DEFAULT_WIDTH;
038:
039: // protected boolean isUpdateable = false;
040: protected boolean isReadOnly = false;
041: protected boolean isVisible = true;
042: protected boolean isMandatory = false;
043: protected boolean isSearchable = false;
044: protected int displayOrder = 0;
045: protected String displayObjectId = "";
046: protected int rowSpan = 0;
047: protected int colSpan = 0;
048: protected boolean startOnNewRow = false;
049:
050: // protected UIScreen uiScreen = null;
051: // protected UIScreenSection uiScreenSection = null;
052: // protected UIEntity uiEntity = null;
053: protected UIScreenSectionEntity uiScreenSectionEntity = null;
054: protected UIAttribute uiAttribute = null;
055: protected UIDisplayObject uiDisplayObject = null;
056:
057: public UIFieldInfo(GenericValue uiScreenSectionInfoGV,
058: GenericDelegator delegator, UICache uiCache)
059: throws GenericEntityException {
060: UtilTimer timer = new UtilTimer();
061:
062: if (TIMER) {
063: timer.timerString(1, "[UIFieldInfo.UIFieldInfo] Start");
064: }
065:
066: setSectionId(uiScreenSectionInfoGV.getString("sectionId"));
067: setPartyId(uiScreenSectionInfoGV.getString("partyId"));
068: setAttributeId(uiScreenSectionInfoGV.getString("attributeId"));
069: setDisplayObjectId(uiScreenSectionInfoGV
070: .getString("displayObjectId"));
071: setMaxLength(uiScreenSectionInfoGV.getString("maxLength"));
072: setIsMandatory(uiScreenSectionInfoGV.getString("isMandatory"));
073: setIsReadOnly(uiScreenSectionInfoGV.getString("isReadOnly"));
074: setIsVisible(uiScreenSectionInfoGV.getString("isVisible"));
075: setIsSearchable(uiScreenSectionInfoGV.getString("isSearchable"));
076: setDisplayOrder(uiScreenSectionInfoGV.getString("displayOrder"));
077: setDisplayLabel(uiScreenSectionInfoGV.getString("displayLabel"));
078: setDisplayLength(uiScreenSectionInfoGV
079: .getString("displayLength"));
080: setColSpan(uiScreenSectionInfoGV.getString("colSpan"));
081: setRowSpan(uiScreenSectionInfoGV.getString("rowSpan"));
082: setStartOnNewRow(uiScreenSectionInfoGV
083: .getString("startOnNewRow"));
084:
085: // Get the UIDisplayObject.
086: if (TIMER) {
087: timer
088: .timerString(2,
089: "[UIFieldInfo.UIFieldInfo] Looking for UIDisplayObject in cache.");
090: }
091:
092: String displayObjectId = getDisplayObjectId();
093: UIDisplayObject uiDisplayObject = uiCache
094: .getUiDisplayObject(displayObjectId);
095:
096: if (uiDisplayObject == null) {
097: if (TIMER) {
098: timer
099: .timerString(
100: 2,
101: "[UIFieldInfo.UIFieldInfo] UIDisplayObject not found in cache. Creating a new one.");
102: }
103:
104: uiDisplayObject = new UIDisplayObject(displayObjectId,
105: delegator);
106: uiCache
107: .putUiDisplayObject(displayObjectId,
108: uiDisplayObject);
109: } else {
110: if (TIMER) {
111: timer
112: .timerString(2,
113: "[UIFieldInfo.UIFieldInfo] Found UIDisplayObject in cache.");
114: }
115: }
116:
117: setUiDisplayObject(uiDisplayObject);
118:
119: if (TIMER) {
120: timer.timerString(2,
121: "[UIFieldInfo.UIFieldInfo] Got UIDisplayObject");
122: }
123:
124: // Get the UIAttribute object.
125: if (TIMER) {
126: timer.timerString(2,
127: "[UIFieldInfo.UIFieldInfo] Looking for UIAttribute "
128: + attributeId + " in cache.");
129: }
130:
131: String attributeId = getAttributeId();
132: UIAttribute uiAttribute = uiCache.getUiAttribute(attributeId);
133:
134: if (uiAttribute == null) {
135: throw new GenericEntityException(
136: "Attribute "
137: + attributeId
138: + " does not appear in any of the entities for this screen section.");
139: } else {
140: if (TIMER) {
141: timer
142: .timerString(2,
143: "[UIFieldInfo.UIFieldInfo] Found UIAttribute in cache.");
144: }
145: }
146:
147: setUiAttribute(uiAttribute);
148:
149: if (TIMER) {
150: timer.timerString(2,
151: "[UIFieldInfo.UIFieldInfo] Got UIAttribute");
152: }
153:
154: // Get the UIScreenSectionEntity object.
155: if (TIMER) {
156: timer
157: .timerString(2,
158: "[UIFieldInfo.UIFieldInfo] Looking for UIScreenSectionEntity in cache.");
159: }
160:
161: String sectionId = getSectionId();
162: String entityId = getUiAttribute().getEntityId();
163: UIScreenSectionEntity uiScreenSectionEntity = uiCache
164: .getUiScreenSectionEntity(sectionId, entityId);
165:
166: if (uiScreenSectionEntity == null) {
167:
168: throw new GenericEntityException(
169: "Attribute '"
170: + getUiAttribute().getAttributeName()
171: + "' does not appear in any of the entities for this screen section.");
172: } else {
173: if (TIMER) {
174: timer
175: .timerString(2,
176: "[UIFieldInfo.UIFieldInfo] Found UIScreenSectionEntity in cache.");
177: }
178: }
179:
180: setUiScreenSectionEntity(uiScreenSectionEntity);
181:
182: if (TIMER) {
183: timer
184: .timerString(2,
185: "[UIFieldInfo.UIFieldInfo] Got UIScreenSectionEntity");
186: }
187:
188: if (TIMER) {
189: timer.timerString(1, "[UIFieldInfo.UIFieldInfo] End");
190: }
191: }
192:
193: /**
194: * DOCUMENT ME!
195: *
196: * @param sectionId_
197: */
198: public void setSectionId(String sectionId_) {
199: sectionId = (sectionId_ == null) ? "" : sectionId_;
200: }
201:
202: /**
203: * DOCUMENT ME!
204: *
205: * @return
206: */
207: public String getSectionId() {
208: return sectionId;
209: }
210:
211: /**
212: * DOCUMENT ME!
213: *
214: * @param partyId_
215: */
216: public void setPartyId(String partyId_) {
217: partyId = (partyId_ == null) ? "" : partyId_;
218: }
219:
220: /**
221: * DOCUMENT ME!
222: *
223: * @return
224: */
225: public String getPartyId() {
226: return partyId;
227: }
228:
229: /**
230: * DOCUMENT ME!
231: *
232: * @param attributeId_
233: */
234: public void setAttributeId(String attributeId_) {
235: attributeId = (attributeId_ == null) ? "" : attributeId_;
236: }
237:
238: /**
239: * DOCUMENT ME!
240: *
241: * @return
242: */
243: public String getAttributeId() {
244: return attributeId;
245: }
246:
247: /**
248: * DOCUMENT ME!
249: *
250: * @param displayLabel_
251: */
252: public void setDisplayLabel(String displayLabel_) {
253: displayLabel = (displayLabel_ == null) ? "" : displayLabel_;
254: }
255:
256: /**
257: * DOCUMENT ME!
258: *
259: * @return
260: */
261: public String getDisplayLabel() {
262: if (displayLabel == null) {
263: return getUiAttribute().getAttributeName();
264: } else {
265: return displayLabel;
266: }
267: }
268:
269: /**
270: * DOCUMENT ME!
271: *
272: * @param displayLength_
273: */
274: public void setDisplayLength(int displayLength_) {
275: displayLength = displayLength_;
276: }
277:
278: /**
279: * DOCUMENT ME!
280: *
281: * @param displayLength_
282: */
283: public void setDisplayLength(String displayLength_) {
284: displayLength = (displayLength_ == null) ? 0 : Integer.valueOf(
285: displayLength_).intValue();
286: }
287:
288: /**
289: * DOCUMENT ME!
290: *
291: * @return
292: */
293: public int getDisplayLength() {
294: return displayLength;
295: }
296:
297: /**
298: * DOCUMENT ME!
299: *
300: * @param maxLength_
301: */
302: public void setMaxLength(int maxLength_) {
303: maxLength = maxLength_;
304: }
305:
306: /**
307: * DOCUMENT ME!
308: *
309: * @param maxLength_
310: */
311: public void setMaxLength(String maxLength_) {
312: maxLength = (maxLength_ == null) ? 0 : Integer.valueOf(
313: maxLength_).intValue();
314: }
315:
316: /**
317: * DOCUMENT ME!
318: *
319: * @return
320: */
321: public int getMaxLength() {
322: return maxLength;
323: }
324:
325: /**
326: * DOCUMENT ME!
327: *
328: * @param displayOrder_
329: */
330: public void setDisplayOrder(int displayOrder_) {
331: displayOrder = displayOrder_;
332: }
333:
334: /**
335: * DOCUMENT ME!
336: *
337: * @param displayOrder_
338: */
339: public void setDisplayOrder(String displayOrder_) {
340: displayOrder = (displayOrder_ == null) ? 0 : Integer.valueOf(
341: displayOrder_).intValue();
342: }
343:
344: /**
345: * DOCUMENT ME!
346: *
347: * @return
348: */
349: public int getDisplayOrder() {
350: return displayOrder;
351: }
352:
353: /**
354: * DOCUMENT ME!
355: *
356: * @param isVisible_
357: */
358: public void setIsVisible(boolean isVisible_) {
359: isVisible = isVisible_;
360: }
361:
362: /**
363: * DOCUMENT ME!
364: *
365: * @param isVisible_
366: */
367: public void setIsVisible(String isVisible_) {
368: isVisible = (isVisible_ == null) ? false : isVisible_
369: .toUpperCase().equals("Y");
370: }
371:
372: /**
373: * DOCUMENT ME!
374: *
375: * @return
376: */
377: public boolean getIsVisible() {
378: return isVisible;
379: }
380:
381: /**
382: * DOCUMENT ME!
383: *
384: * @param isReadOnly_
385: */
386: public void setIsReadOnly(boolean isReadOnly_) {
387: isReadOnly = isReadOnly_;
388: }
389:
390: /**
391: * DOCUMENT ME!
392: *
393: * @param isReadOnly_
394: */
395: public void setIsReadOnly(String isReadOnly_) {
396: isReadOnly = (isReadOnly_ == null) ? false : isReadOnly_
397: .toUpperCase().equals("Y");
398: }
399:
400: /**
401: * DOCUMENT ME!
402: *
403: * @return
404: */
405: public boolean getIsReadOnly() {
406: return isReadOnly;
407: }
408:
409: // public void setIsUpdateable(boolean isUpdateable_) {
410: // isUpdateable = isUpdateable_;
411: // }
412: // public void setIsUpdateable(String isUpdateable_) {
413: // isUpdateable = isUpdateable_==null ? false : isUpdateable_.toUpperCase().equals("Y");
414: // }
415: // public boolean getIsUpdateable() {
416: // return isUpdateable;
417: // }
418: public void setIsMandatory(boolean isMandatory_) {
419: isMandatory = isMandatory_;
420: }
421:
422: /**
423: * DOCUMENT ME!
424: *
425: * @param isMandatory_
426: */
427: public void setIsMandatory(String isMandatory_) {
428: isMandatory = (isMandatory_ == null) ? false : isMandatory_
429: .toUpperCase().equals("Y");
430: }
431:
432: /**
433: * DOCUMENT ME!
434: *
435: * @return
436: */
437: public boolean getIsMandatory() {
438: return isMandatory;
439: }
440:
441: /**
442: * DOCUMENT ME!
443: *
444: * @param isSearchable_
445: */
446: public void setIsSearchable(boolean isSearchable_) {
447: isSearchable = isSearchable_;
448: }
449:
450: /**
451: * DOCUMENT ME!
452: *
453: * @param isSearchable_
454: */
455: public void setIsSearchable(String isSearchable_) {
456: isSearchable = (isSearchable_ == null) ? false : isSearchable_
457: .toUpperCase().equals("Y");
458: }
459:
460: /**
461: * DOCUMENT ME!
462: *
463: * @return
464: */
465: public boolean getIsSearchable() {
466: return isSearchable;
467: }
468:
469: /**
470: * DOCUMENT ME!
471: *
472: * @param displayObjectId_
473: */
474: public void setDisplayObjectId(String displayObjectId_) {
475: displayObjectId = (displayObjectId_ == null) ? ""
476: : displayObjectId_;
477: }
478:
479: /**
480: * DOCUMENT ME!
481: *
482: * @return
483: */
484: public String getDisplayObjectId() {
485: return displayObjectId;
486: }
487:
488: /**
489: * DOCUMENT ME!
490: *
491: * @param uiDisplayObject_
492: */
493: public void setUiDisplayObject(UIDisplayObject uiDisplayObject_) {
494: uiDisplayObject = uiDisplayObject_;
495: }
496:
497: /**
498: * DOCUMENT ME!
499: *
500: * @return
501: */
502: public UIDisplayObject getUiDisplayObject() {
503: return uiDisplayObject;
504: }
505:
506: /**
507: * DOCUMENT ME!
508: *
509: * @param rowSpan_
510: */
511: public void setRowSpan(int rowSpan_) {
512: rowSpan = rowSpan_;
513: }
514:
515: /**
516: * DOCUMENT ME!
517: *
518: * @param rowSpan_
519: */
520: public void setRowSpan(String rowSpan_) {
521: rowSpan = (rowSpan_ == null) ? 0 : Integer.valueOf(rowSpan_)
522: .intValue();
523: }
524:
525: /**
526: * DOCUMENT ME!
527: *
528: * @return
529: */
530: public int getRowSpan() {
531: return rowSpan;
532: }
533:
534: /**
535: * DOCUMENT ME!
536: *
537: * @param colSpan_
538: */
539: public void setColSpan(int colSpan_) {
540: colSpan = colSpan_;
541: }
542:
543: /**
544: * DOCUMENT ME!
545: *
546: * @param colSpan_
547: */
548: public void setColSpan(String colSpan_) {
549: colSpan = (colSpan_ == null) ? 0 : Integer.valueOf(colSpan_)
550: .intValue();
551: }
552:
553: /**
554: * DOCUMENT ME!
555: *
556: * @return
557: */
558: public int getColSpan() {
559: return colSpan;
560: }
561:
562: public void setStartOnNewRow(boolean startOnNewRow_) {
563: startOnNewRow = startOnNewRow_;
564: }
565:
566: /**
567: * DOCUMENT ME!
568: *
569: * @param startOnNewRow_
570: */
571: public void setStartOnNewRow(String startOnNewRow_) {
572: startOnNewRow = (startOnNewRow_ == null) ? false
573: : startOnNewRow_.toUpperCase().equals("Y");
574: }
575:
576: /**
577: * DOCUMENT ME!
578: *
579: * @return
580: */
581: public boolean getStartOnNewRow() {
582: return startOnNewRow;
583: }
584:
585: // public void setUiScreen(UIScreen uiScreen_) {
586: // uiScreen = uiScreen_;
587: // }
588: // public UIScreen getUiScreen() {
589: // return uiScreen;
590: // }
591: // public void setUiScreenSection(UIScreenSection uiScreenSection_) {
592: // uiScreenSection = uiScreenSection_;
593: // }
594: // public UIScreenSection getUiScreenSection() {
595: // return uiScreenSection;
596: // }
597: public void setUiAttribute(UIAttribute uiAttribute_) {
598: uiAttribute = uiAttribute_;
599: }
600:
601: /**
602: * DOCUMENT ME!
603: *
604: * @return
605: */
606: public UIAttribute getUiAttribute() {
607: return uiAttribute;
608: }
609:
610: // public void setUiEntity(UIEntity uiEntity_) {
611: // uiEntity = uiEntity_;
612: // }
613: // public UIEntity getUiEntity() {
614: // return uiEntity;
615: // }
616: public void setUiScreenSectionEntity(
617: UIScreenSectionEntity uiScreenSectionEntity_) {
618: uiScreenSectionEntity = uiScreenSectionEntity_;
619: }
620:
621: /**
622: * DOCUMENT ME!
623: *
624: * @return
625: */
626: public UIScreenSectionEntity getUiScreenSectionEntity() {
627: return uiScreenSectionEntity;
628: }
629: }
|