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.issue;
018:
019: import java.util.ArrayList;
020: import java.util.HashMap;
021: import java.util.List;
022: import java.util.Vector;
023:
024: import org.ofbiz.base.util.Debug;
025: import org.ofbiz.entity.GenericDelegator;
026: import org.ofbiz.entity.GenericEntityException;
027: import org.ofbiz.entity.GenericValue;
028:
029: import com.sourcetap.sfa.ui.UICache;
030: import com.sourcetap.sfa.ui.UIFieldInfo;
031: import com.sourcetap.sfa.ui.UIWebScreenSection;
032: import com.sourcetap.sfa.util.UserInfo;
033:
034: /**
035: * DOCUMENT ME!
036: *
037: */
038: public class UIWebScreenSectionIssue extends UIWebScreenSection {
039: public static final String module = UIWebScreenSectionIssue.class
040: .getName();
041:
042: public UIWebScreenSectionIssue(UserInfo userInfo,
043: String screenName, String sectionName,
044: GenericDelegator delegator, UICache uiCache)
045: throws GenericEntityException {
046: super (userInfo, screenName, sectionName, delegator, uiCache);
047: }
048:
049: /**
050: * DOCUMENT ME!
051: *
052: * @param fieldInfo
053: * @param entityDetailsVector
054: * @param action
055: * @param row
056: * @param isSubsection
057: * @param tabOffset
058: *
059: * @return
060: */
061: public String displayField(UIFieldInfo fieldInfo,
062: Vector entityDetailsVector, String action, int row,
063: boolean isSubsection, int tabOffset) {
064:
065: try {
066: if ((fieldInfo.getUiAttribute().getAttributeName().trim()
067: .equals("notes"))
068: && (action.equals(ACTION_SHOW))) {
069: GenericValue fieldEntityDetails = (GenericValue) entityDetailsVector
070: .get(0);
071:
072: String issueId = fieldEntityDetails
073: .getString("issueId");
074:
075: HashMap issueMap = new HashMap();
076: issueMap.put("issueId", issueId);
077:
078: ArrayList orderBy = new ArrayList();
079: orderBy.add("modifiedDate DESC");
080:
081: List issueHistoryList = delegator.findByAnd(
082: "ItIssueHistory", issueMap, orderBy);
083:
084: GenericValue[] issueHistory = (GenericValue[]) issueHistoryList
085: .toArray(new GenericValue[0]);
086:
087: if (issueHistory.length > 0) {
088: GenericValue lastIssue = issueHistory[0];
089:
090: String dataId = lastIssue.getString("dataId");
091:
092: if ((dataId != null) && (dataId.length() > 0)) {
093: HashMap dataMap = new HashMap();
094: dataMap.put("dataId", dataId);
095:
096: GenericValue notes = delegator
097: .findByPrimaryKey("LargeData", dataMap);
098:
099: if (notes != null) {
100: fieldEntityDetails.set("notes", notes
101: .getString("dataValue"));
102: }
103: }
104: }
105: }
106: } catch (Exception e) {
107: Debug
108: .logError(
109: "[UIWebScreenSectionIssue.displayField]: Error occurred while searching for Issue Notes: ",
110: module);
111: Debug.logError(" " + e.getLocalizedMessage(), module);
112: }
113:
114: return super.displayField(fieldInfo, entityDetailsVector,
115: action, row, isSubsection, tabOffset);
116: }
117: }
|