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