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 java.util.ArrayList;
020: import java.util.HashMap;
021: import java.util.List;
022: import java.util.Map;
023:
024: import org.ofbiz.base.util.Debug;
025: import org.ofbiz.base.util.UtilTimer;
026: import org.ofbiz.entity.GenericDelegator;
027: import org.ofbiz.entity.GenericEntityException;
028: import org.ofbiz.entity.GenericValue;
029:
030: import com.sourcetap.sfa.util.DelimitedPairDecoder;
031: import com.sourcetap.sfa.util.DelimitedValueDecoder;
032:
033: /**
034: * DOCUMENT ME!
035: *
036: */
037: public class UIScreenSectionEntity {
038:
039: public static final String module = UIScreenSectionEntity.class
040: .getName();
041:
042: private static final boolean DEBUG = false;
043: private static final boolean TIMER = false;
044: protected String sectionId = "";
045: protected String entityId = "";
046: protected boolean isUpdateable = false;
047: protected boolean isOuterJoined = false;
048: protected boolean hasSequenceKey = false;
049: protected int insertOrder = 0;
050: protected int retrieveOrder = 0;
051: protected int deleteOrder = 0;
052: protected int updateOrder = 0;
053: protected String relationTitle = "";
054: protected String relationByAndFields = "";
055: protected String relationOrderByFields = "";
056: UIEntity uiEntity = null;
057: protected GenericValue genericValue = null;
058:
059: UIScreenSectionEntity() {
060: }
061:
062: public UIScreenSectionEntity(GenericValue uiScreenSectionEntityGV,
063: GenericDelegator delegator, UICache uiCache)
064: throws GenericEntityException {
065: UtilTimer timer = new UtilTimer();
066:
067: if (TIMER) {
068: timer
069: .timerString(4,
070: "[UIScreenSectionEntity.UIScreenSectionEntity] Start");
071: }
072:
073: setGenericValue(uiScreenSectionEntityGV);
074:
075: setSectionId(uiScreenSectionEntityGV.getString("sectionId"));
076: setEntityId(uiScreenSectionEntityGV.getString("entityId"));
077: setIsUpdateable(uiScreenSectionEntityGV
078: .getString("isUpdateable"));
079: setIsOuterJoined(uiScreenSectionEntityGV
080: .getString("isOuterJoined"));
081: setHasSequenceKey(uiScreenSectionEntityGV
082: .getString("hasSequenceKey"));
083: setRelationTitle(uiScreenSectionEntityGV
084: .getString("relationTitle"));
085: setRelationByAndFields(uiScreenSectionEntityGV
086: .getString("relationByAndFields"));
087: setRelationOrderByFields(uiScreenSectionEntityGV
088: .getString("relationOrderByFields"));
089: setInsertOrder(uiScreenSectionEntityGV.getString("insertOrder"));
090: setRetrieveOrder(uiScreenSectionEntityGV
091: .getString("retrieveOrder"));
092: setDeleteOrder(uiScreenSectionEntityGV.getString("deleteOrder"));
093: setUpdateOrder(uiScreenSectionEntityGV.getString("updateOrder"));
094:
095: // Get the UIEntity object.
096: if (TIMER) {
097: timer
098: .timerString(4,
099: "[UIScreenSectionEntity.UIScreenSectionEntity] Looking for UIEntity in cache.");
100: }
101:
102: UIEntity uiEntity = uiCache.getUiEntity(getEntityId());
103:
104: if (uiEntity == null) {
105: if (TIMER) {
106: timer
107: .timerString(
108: 4,
109: "[UIScreenSectionEntity.UIScreenSectionEntity] UIEntity not found in cache. Creating a new one.");
110: }
111:
112: GenericValue uiEntityGV = delegator.getRelatedOne(
113: "UiEntity", uiScreenSectionEntityGV);
114: uiEntity = new UIEntity(uiEntityGV, delegator, uiCache);
115: uiCache.putUiEntity(getEntityId(), uiEntity);
116: } else {
117: if (TIMER) {
118: timer
119: .timerString(4,
120: "[UIScreenSectionEntity.UIScreenSectionEntity] Found UIEntity in cache.");
121: }
122:
123: }
124:
125: setUiEntity(uiEntity);
126:
127: if (TIMER) {
128: timer
129: .timerString(4,
130: "[UIScreenSectionEntity.UIScreenSectionEntity] Got UIEntity");
131: timer
132: .timerString(4,
133: "[UIScreenSectionEntity.UIScreenSectionEntity] End");
134: }
135: }
136:
137: /**
138: * DOCUMENT ME!
139: *
140: * @param sectionId_
141: */
142: public void setSectionId(String sectionId_) {
143: sectionId = (sectionId_ == null) ? "" : sectionId_;
144: }
145:
146: /**
147: * DOCUMENT ME!
148: *
149: * @return
150: */
151: public String getSectionId() {
152: return sectionId;
153: }
154:
155: /**
156: * DOCUMENT ME!
157: *
158: * @param entityId_
159: */
160: public void setEntityId(String entityId_) {
161: entityId = (entityId_ == null) ? "" : entityId_;
162: }
163:
164: /**
165: * DOCUMENT ME!
166: *
167: * @return
168: */
169: public String getEntityId() {
170: return entityId;
171: }
172:
173: /**
174: * DOCUMENT ME!
175: *
176: * @param isUpdateable_
177: */
178: public void setIsUpdateable(boolean isUpdateable_) {
179: isUpdateable = isUpdateable_;
180: }
181:
182: /**
183: * DOCUMENT ME!
184: *
185: * @param isUpdateable_
186: */
187: public void setIsUpdateable(String isUpdateable_) {
188: if ((isUpdateable_ == null) || isUpdateable_.equals("")
189: || isUpdateable_.equalsIgnoreCase("N")) {
190: isUpdateable = false;
191: } else {
192: isUpdateable = true;
193: }
194: }
195:
196: /**
197: * DOCUMENT ME!
198: *
199: * @return
200: */
201: public boolean getIsUpdateable() {
202: return isUpdateable;
203: }
204:
205: /**
206: * DOCUMENT ME!
207: *
208: * @param isOuterJoined_
209: */
210: public void setIsOuterJoined(boolean isOuterJoined_) {
211: isOuterJoined = isOuterJoined_;
212: }
213:
214: /**
215: * DOCUMENT ME!
216: *
217: * @param isOuterJoined_
218: */
219: public void setIsOuterJoined(String isOuterJoined_) {
220: if ((isOuterJoined_ == null) || isOuterJoined_.equals("")
221: || isOuterJoined_.equalsIgnoreCase("N")) {
222: isOuterJoined = false;
223: } else {
224: isOuterJoined = true;
225: }
226: }
227:
228: /**
229: * DOCUMENT ME!
230: *
231: * @return
232: */
233: public boolean getIsOuterJoined() {
234: return isOuterJoined;
235: }
236:
237: /**
238: * DOCUMENT ME!
239: *
240: * @param hasSequenceKey_
241: */
242: public void setHasSequenceKey(boolean hasSequenceKey_) {
243: hasSequenceKey = hasSequenceKey_;
244: }
245:
246: /**
247: * DOCUMENT ME!
248: *
249: * @param hasSequenceKey_
250: */
251: public void setHasSequenceKey(String hasSequenceKey_) {
252: if ((hasSequenceKey_ == null) || hasSequenceKey_.equals("")
253: || hasSequenceKey_.equalsIgnoreCase("N")) {
254: hasSequenceKey = false;
255: } else {
256: hasSequenceKey = true;
257: }
258: }
259:
260: /**
261: * DOCUMENT ME!
262: *
263: * @return
264: */
265: public boolean getHasSequenceKey() {
266: return hasSequenceKey;
267: }
268:
269: /**
270: * DOCUMENT ME!
271: *
272: * @param insertOrder_
273: */
274: public void setInsertOrder(int insertOrder_) {
275: insertOrder = insertOrder_;
276: }
277:
278: /**
279: * DOCUMENT ME!
280: *
281: * @param insertOrder_
282: */
283: public void setInsertOrder(String insertOrder_) {
284: insertOrder = (insertOrder_ == null) ? 0 : Integer.valueOf(
285: insertOrder_).intValue();
286: }
287:
288: /**
289: * DOCUMENT ME!
290: *
291: * @return
292: */
293: public int getInsertOrder() {
294: return insertOrder;
295: }
296:
297: /**
298: * DOCUMENT ME!
299: *
300: * @param retrieveOrder_
301: */
302: public void setRetrieveOrder(int retrieveOrder_) {
303: retrieveOrder = retrieveOrder_;
304: }
305:
306: /**
307: * DOCUMENT ME!
308: *
309: * @param retrieveOrder_
310: */
311: public void setRetrieveOrder(String retrieveOrder_) {
312: retrieveOrder = (retrieveOrder_ == null) ? 0 : Integer.valueOf(
313: retrieveOrder_).intValue();
314: }
315:
316: /**
317: * DOCUMENT ME!
318: *
319: * @return
320: */
321: public int getRetrieveOrder() {
322: return retrieveOrder;
323: }
324:
325: /**
326: * DOCUMENT ME!
327: *
328: * @param deleteOrder_
329: */
330: public void setDeleteOrder(int deleteOrder_) {
331: deleteOrder = deleteOrder_;
332: }
333:
334: /**
335: * DOCUMENT ME!
336: *
337: * @param deleteOrder_
338: */
339: public void setDeleteOrder(String deleteOrder_) {
340: deleteOrder = (deleteOrder_ == null) ? 0 : Integer.valueOf(
341: deleteOrder_).intValue();
342: }
343:
344: /**
345: * DOCUMENT ME!
346: *
347: * @return
348: */
349: public int getDeleteOrder() {
350: return deleteOrder;
351: }
352:
353: /**
354: * DOCUMENT ME!
355: *
356: * @param updateOrder_
357: */
358: public void setUpdateOrder(int updateOrder_) {
359: updateOrder = updateOrder_;
360: }
361:
362: /**
363: * DOCUMENT ME!
364: *
365: * @param updateOrder_
366: */
367: public void setUpdateOrder(String updateOrder_) {
368: updateOrder = (updateOrder_ == null) ? 0 : Integer.valueOf(
369: updateOrder_).intValue();
370: }
371:
372: /**
373: * DOCUMENT ME!
374: *
375: * @return
376: */
377: public int getUpdateOrder() {
378: return updateOrder;
379: }
380:
381: /**
382: * DOCUMENT ME!
383: *
384: * @param relationTitle_
385: */
386: public void setRelationTitle(String relationTitle_) {
387: relationTitle = (relationTitle_ == null) ? "" : relationTitle_;
388: }
389:
390: /**
391: * DOCUMENT ME!
392: *
393: * @return
394: */
395: public String getRelationTitle() {
396: return relationTitle;
397: }
398:
399: /**
400: * DOCUMENT ME!
401: *
402: * @param relationByAndFields_
403: */
404: public void setRelationByAndFields(String relationByAndFields_) {
405: relationByAndFields = (relationByAndFields_ == null) ? ""
406: : relationByAndFields_;
407: }
408:
409: /**
410: * DOCUMENT ME!
411: *
412: * @return
413: */
414: public String getRelationByAndFields() {
415: return relationByAndFields;
416: }
417:
418: /**
419: * DOCUMENT ME!
420: *
421: * @param relationOrderByFields_
422: */
423: public void setRelationOrderByFields(String relationOrderByFields_) {
424: relationOrderByFields = (relationOrderByFields_ == null) ? ""
425: : relationOrderByFields_;
426: }
427:
428: /**
429: * DOCUMENT ME!
430: *
431: * @return
432: */
433: public String getRelationOrderByFields() {
434: return relationOrderByFields;
435: }
436:
437: /**
438: * DOCUMENT ME!
439: *
440: * @param genericValue_
441: */
442: public void setGenericValue(GenericValue genericValue_) {
443: genericValue = genericValue_;
444: }
445:
446: /**
447: * DOCUMENT ME!
448: *
449: * @return
450: */
451: public GenericValue getGenericValue() {
452: return genericValue;
453: }
454:
455: /**
456: * DOCUMENT ME!
457: *
458: * @param uiEntity_
459: */
460: public void setUiEntity(UIEntity uiEntity_) {
461: uiEntity = uiEntity_;
462: }
463:
464: /**
465: * DOCUMENT ME!
466: *
467: * @return
468: */
469: public UIEntity getUiEntity() {
470: return uiEntity;
471: }
472:
473: public String getEntityName() {
474: return uiEntity.getEntityName();
475: }
476:
477: public Map getDecodedAndFields() {
478: try {
479: DelimitedPairDecoder byAndFieldDecoder = new DelimitedPairDecoder(
480: relationByAndFields);
481: HashMap byAndFieldsMap = byAndFieldDecoder.decode();
482: return byAndFieldsMap;
483: } catch (GenericEntityException e) {
484: // TODO Auto-generated catch block
485: Debug.logError("Error decoding relationByAndFields: "
486: + relationByAndFields + " for " + getEntityName(),
487: module);
488: }
489: return new HashMap();
490: }
491:
492: public List getDecodedOrderBy() {
493: DelimitedValueDecoder orderByFieldDecoder = new DelimitedValueDecoder(
494: relationOrderByFields);
495: ArrayList orderByFields = orderByFieldDecoder.decode();
496: return orderByFields;
497: }
498: }
|