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

📄 accountreplicator.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.replication;

import java.util.HashMap;
import java.util.List;

import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericPK;
import org.ofbiz.entity.GenericValue;

import com.sourcetap.sfa.address.AddressHelper;
import com.sourcetap.sfa.security.EntityAccessHelper;


/**
 * This class is used for replication of the Code entity. <P>
 *
 * @author  <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
 */
public class AccountReplicator extends EntityReplicator {
	public static final String module = AccountReplicator.class.getName();

    /**
     * Populate the related entity map vector. This method is called from the constructors
     * to allow the related entities to be specified before replication begins.
     *
     * @author  <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
     */
    public void populateRelatedEntityMapVector() {
        // Add related entity maps for all entities to be replicated for each
        // replicated account.

        addRelatedEntityMap("", "AccountFile", null, false, false,
            "com.sourcetap.sfa.replication.FileReplicator");

        addRelatedEntityMap("", "Address", new HashMap(), false, false, "");

        addRelatedEntityMap("", "Contact", new HashMap(), false, false,
            "com.sourcetap.sfa.replication.ContactReplicator");

        addRelatedEntityMap("", "Activity", new HashMap(), false, false,
            "com.sourcetap.sfa.replication.ActivityReplicator");

        addRelatedEntityMap("", "Deal", new HashMap(), false, false,
            "com.sourcetap.sfa.replication.DealReplicator");

        addRelatedEntityMap("", "EntityAccess", new HashMap(), false, false,
            "com.sourcetap.sfa.replication.EntityAccessReplicator");

        addRelatedEntityMap("", "Forecast", new HashMap(), false, false, "");

        addRelatedEntityMap("", "Party", new HashMap(), false, false, "");

        addRelatedEntityMap("", "Role", new HashMap(), false, false, "");

        addRelatedEntityMap("", "Url", new HashMap(), false, false, "");

        return;
    }

    /**
     * This method finds all instances of an entity related to the main entity.
     *
     * This method overrides the ancestor to filter out instances for the SFA application.
     *
     * @author  <a href='mailto:jnutting@sourcetap.com'>John Nutting</a>
     *
     * @param mainInstance Main entity instance for which related entities will be replicated
     * @param relationTitle Relation title to be used by the entity engine to find related
     *   entity instances
     * @param relatedEntityName Name of the related entity to be replicated
     * @param filterMap HashMap containing additional filter values to be used by the entity
     *   engine when finding related entity instances
     *
     * @return List of generic values related to the main entity instance
     */
    protected List findOneRelated(GenericDelegator delegator,
        GenericValue mainInstance, String relationTitle,
        String relatedEntityName, HashMap filterMap, boolean findAll) {

        if (delegator == null) {
            Debug.logError("[findOneRelated] Delegator is required.", module);

            return null;
        }

        if (userInfo == null) {
            Debug.logError("[findOneRelated] User info object is required.", module);

            return null;
        }

        GenericPK entityPK = null;
        String entityKeyString = null;

        List relatedGVL = null;

        if (relatedEntityName.equals("EntityAccess")) {
            // Special processing for EntityAccess entity.
            return EntityAccessHelper.findRelated(getUserInfo(), delegator,
                mainInstance, relationTitle);
        } else if (relatedEntityName.equals("Address")) {
            // Special processing for Address entity.
            return AddressHelper.findRelated(getUserInfo(), delegator,
                mainInstance, relationTitle);
        } else {
            // Default processing for all other entities.
            return super.findOneRelated(delegator, mainInstance, relationTitle,
                relatedEntityName, filterMap, findAll);
        }
    }
}

⌨️ 快捷键说明

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