leadruleeventprocessor.java

来自「国外的一套开源CRM」· Java 代码 · 共 183 行

JAVA
183
字号
/*
 * 
 * Copyright (c) 2004 SourceTap - www.sourcetap.com
 *
 *  The contents of this file are subject to the SourceTap Public License 
 * ("License"); You may not use this file except in compliance with the 
 * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
 * Software distributed under the License is distributed on an  "AS IS"  basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 */

package com.sourcetap.sfa.lead;

import com.sourcetap.sfa.attachment.AbstractAttachmentEP;
import com.sourcetap.sfa.event.*;
import com.sourcetap.sfa.replication.*;
import com.sourcetap.sfa.security.*;
import com.sourcetap.sfa.util.UserInfo;

import org.ofbiz.entity.*;
import org.ofbiz.entity.model.*;
import org.ofbiz.base.util.*;

import java.sql.Timestamp;

import java.util.*;


/**
 * DOCUMENT ME!
 *
 */
public class LeadRuleEventProcessor extends GenericEventProcessor {
	public static final String module = LeadRuleEventProcessor.class.getName();

    /**
     * DOCUMENT ME!
     *
     * @param userInfo 
     * @param delegator 
     * @param dataMatrix 
     *
     * @return 
     */
    protected int preUpdate(UserInfo userInfo, GenericDelegator delegator,
        DataMatrix dataMatrix) {

        // Just process the first row for now.
        GenericValue leadRuleGV = null;

        try {
            leadRuleGV = dataMatrix.getCurrentBuffer().getGenericValue(0,
                    "LeadAssignmentRule", true);
        } catch (GenericEntityException e) {
            Debug.logError(
                "[LeadQueueEventProcessor.preUpdate] Error getting generic value: " +
                e.toString(), module);

            return STATUS_ERROR;
        }

        // Set the time stamps.
        Timestamp now = new Timestamp(Calendar.getInstance().getTime().getTime());
        leadRuleGV.set("modifiedDate", now);

        // Store the current user ID in the "modified by" field.
        leadRuleGV.set("modifiedBy", userInfo.getPartyId());

        return STATUS_CONTINUE;
    }

    /**
     * DOCUMENT ME!
     *
     * @param userInfo 
     * @param delegator 
     * @param dataMatrix 
     *
     * @return 
     */
    protected int preInsert(UserInfo userInfo, GenericDelegator delegator,
        DataMatrix dataMatrix) {

        // Just process the first row for now.
        GenericValue leadRuleGV = null;

        try {
            leadRuleGV = dataMatrix.getCurrentBuffer().getGenericValue(0,
                    "LeadAssignmentRule", true);
        } catch (GenericEntityException e) {
            Debug.logError(
                "[LeadQueueEventProcessor.preInsert] Error getting generic value: " +
                e.getLocalizedMessage(), module);

            return STATUS_ERROR;
        }

        // Generate new key for the leadQueue.
        String ruleId = GenericReplicator.getNextSeqId("LeadAssignmentRule",
                delegator);
        leadRuleGV.set("leadAssignmentRuleId", ruleId);

        // Set the time stamps.
        Timestamp now = new Timestamp(Calendar.getInstance().getTime().getTime());
        leadRuleGV.set("createdDate", now);
        leadRuleGV.set("modifiedDate", now);

        // Store the current user ID in the "modified by" field.
        leadRuleGV.set("createdBy", userInfo.getPartyId());
        leadRuleGV.set("modifiedBy", userInfo.getPartyId());

        leadRuleGV.set("accountId", userInfo.getAccountId());

        return STATUS_CONTINUE;
    }

    /**
     * DOCUMENT ME!
     *
     * @param userInfo 
     * @param entityNameList 
     * @param delegator 
     * @param dataMatrix 
     *
     * @return 
     */
    protected int postCreate(UserInfo userInfo, List entityNameList,
        GenericDelegator delegator, DataMatrix dataMatrix) {

        // Get the empty generic values.
        GenericValue leadRuleGV = null;

        try {
            leadRuleGV = dataMatrix.getCurrentBuffer().getGenericValue(0,
                    "LeadAssignmentRule", true);
        } catch (GenericEntityException e) {
            Debug.logError(
                "[ContactEventProcessor.postCreate] Error getting generic value: " +
                e.toString(), module);

            return STATUS_ERROR;
        }

        // Set default values on the new record so they will be displayed for the user to see before saving.
        // Active Flag
        leadRuleGV.set("activeFlag", new Boolean(true));

        // Refresh the cache in the delegator so that dropdowns will show the new leadRule
        delegator.getAndCache().clear();

        return STATUS_CONTINUE;
    }

    /**
     * DOCUMENT ME!
     *
     * @param userInfo 
     * @param delegator 
     * @param originatingEntityName 
     * @param entityGV 
     *
     * @return 
     */
    public int deleteAllRelated(UserInfo userInfo, GenericDelegator delegator,
        String originatingEntityName, GenericValue entityGV) {

        int status = STATUS_CONTINUE;

        return STATUS_CONTINUE;
    }

    /*        public SecurityLinkInfo getSecurityLinkInfo(UserInfo userInfo, GenericDelegator delegator)
            {
                    return new SecurityLinkInfo( "Account", "accountId", false );
            }
    */
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?