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