⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 codeeventprocessor.java

📁 国外的一套开源CRM
💻 JAVA
字号:
/*
 * 
 * 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.code;

import java.sql.Timestamp;
import java.util.Calendar;

import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericValue;

import com.sourcetap.sfa.event.DataMatrix;
import com.sourcetap.sfa.event.GenericEventProcessor;
import com.sourcetap.sfa.util.UserInfo;


/**
 * DOCUMENT ME!
 *
 */
public class CodeEventProcessor extends GenericEventProcessor {

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

        Timestamp now = new Timestamp(Calendar.getInstance().getTime().getTime());

        // Process each row.
        for (int row = 0;
                row < dataMatrix.getCurrentBuffer().getContents().size();
                row++) {
            GenericValue codeGV = dataMatrix.getCurrentBuffer().getGenericValue(row,
                    0);

            // Set the time stamps.
            codeGV.set("modifiedDate", now);
            codeGV.set("modifiedDate", now);

            // Store the current user's party ID in the "modified by" field.
            codeGV.set("modifiedBy", userInfo.getPartyId());
            codeGV.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) {

        Timestamp now = new Timestamp(Calendar.getInstance().getTime().getTime());

        // Process each row.
        for (int row = 0;
                row < dataMatrix.getCurrentBuffer().getContents().size();
                row++) {
            GenericValue codeGV = dataMatrix.getCurrentBuffer().getGenericValue(row,
                    0);

            // Set the time stamps.
            codeGV.set("modifiedDate", now);
            codeGV.set("modifiedDate", now);

            // Store the current user's party ID in the "modified by" field.
            codeGV.set("modifiedBy", userInfo.getPartyId());
            codeGV.set("modifiedBy", userInfo.getPartyId());
        }

        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;

        // Delete any related Codes associated with this code.  Set the allowRecursive flag to true.
        status = deleteOneRelated(userInfo, delegator, entityGV, "child",
                "Code", originatingEntityName, new GenericEventProcessor(), true);

        return status;
    }
}

⌨️ 快捷键说明

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