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.account;
018:
019: import java.util.List;
020:
021: import javax.servlet.http.HttpServletRequest;
022: import javax.servlet.http.HttpServletResponse;
023:
024: import org.ofbiz.base.util.Debug;
025: import org.ofbiz.entity.GenericDelegator;
026: import org.ofbiz.entity.GenericValue;
027: import org.ofbiz.entity.condition.EntityOperator;
028:
029: import com.sourcetap.sfa.event.DataMatrix;
030: import com.sourcetap.sfa.event.GenericEventProcessor;
031: import com.sourcetap.sfa.event.GenericWebEventProcessor;
032: import com.sourcetap.sfa.ui.UICache;
033: import com.sourcetap.sfa.ui.UIWebScreenSection;
034: import com.sourcetap.sfa.util.QueryInfo;
035: import com.sourcetap.sfa.util.UserInfo;
036:
037: /**
038: * DOCUMENT ME!
039: *
040: */
041: public class AccountWebEventProcessor extends GenericWebEventProcessor {
042: private static final boolean DEBUG = false;
043: public static final String module = AccountWebEventProcessor.class
044: .getName();
045:
046: // overide the default. do not display accounts with type = BASE.
047: protected void addUseQueryParameterClauses(
048: UIWebScreenSection uiWebScreenSection, QueryInfo queryInfo,
049: List relatedSearchClauses, String primaryEntityName,
050: HttpServletRequest request) {
051: if (DEBUG) {
052: Debug
053: .logVerbose(
054: "-->[AccountWebEventProcessor.addUseQueryParameterClauses]",
055: module);
056: }
057:
058: queryInfo.addCondition("Account", "accountTypeId",
059: EntityOperator.NOT_EQUAL, "base");
060: }
061:
062: /**
063: * DOCUMENT ME!
064: *
065: * @param userInfo
066: * @param uiWebScreenSection
067: * @param request
068: * @param response
069: * @param delegator
070: * @param eventProcessor
071: * @param dataMatrix
072: * @param uiCache
073: *
074: * @return
075: */
076: protected int postInsert(UserInfo userInfo,
077: UIWebScreenSection uiWebScreenSection,
078: HttpServletRequest request, HttpServletResponse response,
079: GenericDelegator delegator,
080: GenericEventProcessor eventProcessor,
081: DataMatrix dataMatrix, UICache uiCache) {
082: if (DEBUG) {
083: Debug.logVerbose(
084: "-->[AccountWebEventProcessor.postInsert]", module);
085: }
086:
087: // Need to get the account ID and store it
088: // in the request object so the other event processors can read it and store
089: // it on the other entities being created.
090: GenericValue accountGV = dataMatrix.getCurrentBuffer()
091: .getGenericValue(0, 0);
092: String accountId = accountGV.getString("accountId");
093:
094: if (DEBUG) {
095: Debug
096: .logVerbose(
097: "-->[AccountWebEventProcessor.postInsert] Storing "
098: + accountId
099: + " as the account ID in the request object.",
100: module);
101: }
102:
103: request.setAttribute("com.sourcetap.sfa.account.accountId",
104: accountId);
105:
106: return STATUS_CONTINUE;
107: }
108:
109: /**
110: * This function gets the application path to be used to reconstruct the URI when a
111: * UI History record is logged. Example: "/accounts"
112: * @author John Nutting
113: * @param url The URL used to open the screen section
114: * @return String containing the application path
115: */
116: protected String getUiHistoryAppPath(String url) {
117: return "/accounts";
118: }
119:
120: /**
121: * This function gets the description to store in the UI history table. This description
122: * will show up in the UI History drop list.
123: * @author John Nutting
124: * @param dataMatrix DataMatrix object containing the data from the screen
125: * @param delegator Generic delegator through which the data base is accessed
126: * @param action The action being performed on the screen
127: * @param uiWebScreenSection The UIWebScreenSection being used to construct the screen section
128: * @return String containing the UI History description
129: */
130: protected String getUiHistoryDescription(DataMatrix dataMatrix,
131: GenericDelegator delegator, String action,
132: UIWebScreenSection uiWebScreenSection) {
133: GenericValue primaryGV = dataMatrix.getCurrentBuffer()
134: .getGenericValue(0, 0);
135:
136: return "Account: "
137: + ((primaryGV.getString("accountName") == null) ? ""
138: : primaryGV.getString("accountName"));
139: }
140: }
|