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

📄 activitycontactavailableselect.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.activity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.ofbiz.base.util.Debug;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericPK;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityExpr;
import org.ofbiz.entity.condition.EntityOperator;

import com.sourcetap.sfa.security.SecurityLinkInfo;
import com.sourcetap.sfa.security.SecurityWrapper;
import com.sourcetap.sfa.ui.UIDropDown;
import com.sourcetap.sfa.util.UserInfo;


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


    public ActivityContactAvailableSelect() {
    }

    /**
     * DOCUMENT ME!
     *
     * @param delegator 
     * @param filterValues 
     * @param userInfo 
     *
     * @return 
     */
    public List getDropDownValues(GenericDelegator delegator, Map filterValues,
        UserInfo userInfo) {
        // See if the account ID was passed in the parameter map. If so, use that account ID.  Otherwise, use the
        // account ID from the activity.
        String accountId = "";

        if (filterValues.containsKey("accountId")) {
            accountId = (String) filterValues.get("accountId");

            Debug.logVerbose(
                    "-->[ActivityContactAvailableSelect.getDropDownValues] Account ID passed in parameters: " +
                    accountId, module);
        } else {
            if (!filterValues.containsKey("activityId")) {
                Debug.logWarning(
                    "[ActivityContactAvailableSelect.getDropDownValues] Neither account ID nor activity ID are included in the query parameters. Can't get eligible contacts.", module);

                return new ArrayList();
            }

            // Get the account ID for this activity.
            String activityId = (String) filterValues.get("activityId");
            GenericPK activityPK = new GenericPK(delegator.getModelEntity(
                        "Activity"));
            activityPK.set("activityId", activityId);

            GenericValue activityGV = null;

            try {
                activityGV = delegator.findByPrimaryKey(activityPK);
            } catch (GenericEntityException e) {
                Debug.logError(
                    "[ActivityContactAvailableSelect.getDropDownValues] Error retrieving the activity: ", module);
                Debug.logError(e.getLocalizedMessage(), module);

                return new ArrayList();
            }

            accountId = (activityGV.getString("accountId") == null) ? ""
                                                                    : activityGV.getString(
                    "accountId");

            Debug.logVerbose(
                    "-->[ActivityContactAvailableSelect.getDropDownValues] Account ID from activity: " +
                    accountId, module);
        }

        // Get a list of all eligible contacts.
        ArrayList orderBy = new ArrayList();
        orderBy.add("lastName");
        orderBy.add("firstName");

		EntityCondition condition = null;
        if ((accountId != null) && (accountId.length() > 0) &&
                (!accountId.equals("null"))) {
			condition = new EntityExpr("accountId", EntityOperator.EQUALS, accountId);

            Debug.logVerbose(
                    "-->[ActivityContactAvailableSelect.getDropDownValues] Adding entity clause for account ID: " +
                    accountId, module);
        }

        try {
            return SecurityWrapper.findByCondition("Contact", condition,
                orderBy, userInfo,
                new SecurityLinkInfo("Account", "accountId", true), delegator);
        } catch (GenericEntityException e) {
            Debug.logError(
                "[ActivityContactAvailableSelect.getDropDownValues] Error retrieving the contacts: ", module);
            Debug.logError(e.getLocalizedMessage(), module);

            return new ArrayList();
        }
    }
}

⌨️ 快捷键说明

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