Package com.sourcetap.sfa.contact

Source Code of com.sourcetap.sfa.contact.ContactRoleSelectWSS

/*
*
* 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.contact;

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

import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.condition.EntityCondition;
import org.ofbiz.entity.condition.EntityConditionList;
import org.ofbiz.entity.condition.EntityExpr;
import org.ofbiz.entity.condition.EntityOperator;
import org.ofbiz.entity.model.DynamicViewEntity;
import org.ofbiz.entity.model.ModelKeyMap;

import com.sourcetap.sfa.ui.UICache;
import com.sourcetap.sfa.ui.UIWebScreenSection;
import com.sourcetap.sfa.util.EntityHelper;
import com.sourcetap.sfa.util.UserInfo;


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

    public ContactRoleSelectWSS(UserInfo userInfo, String screenName,
        String sectionName, GenericDelegator delegator, UICache uiCache)
        throws GenericEntityException {
        super(userInfo, screenName, sectionName, delegator, uiCache);
    }

    /**
     * DOCUMENT ME!
     *
     * @param useQueryParameterValueMap
     * @param listedEntityName
     * @param userInfo
     * @param delegator
     *
     * @return
     */
    public List getEligibleEntityList(HashMap useQueryParameterValueMap,
        String listedEntityName, UserInfo userInfo, GenericDelegator delegator) {

        ArrayList orderBy = new ArrayList();
        orderBy.add("description");

    // select X from roleType rt,. code c where rt.roleTypeId = c.codeId and c.codeTypeId = "ROLE_TYPE_SFA" order by description    
    DynamicViewEntity dve = EntityHelper.createDynamicViewEntity( delegator, "RoleType");
    dve.addMemberEntity("Code", "Code");
    dve.addViewLink("RoleType", "Code", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("roleTypeId", "codeId")));
    dve.addAlias("Code", "codeTypeId", null, null, null, null, null);
    
    EntityCondition condition = new EntityConditionList(UtilMisc.toList(
        new EntityExpr("codeTypeId", EntityOperator.EQUALS, "ROLE_TYPE_SFA")),
        EntityOperator.AND);
       
        try {
            return EntityHelper.getPrimaryGVLFromDynamicGVL(delegator, EntityHelper.findByCondition( delegator, dve, condition, orderBy ), "RoleType");
        } catch (Exception e) {
            Debug.logError(
                "[ContactRoleSelectWSS.getEligibleEntityList] An error occurred while getting contact role select values:", module);
            Debug.logError(e.getLocalizedMessage(), module);

            return new ArrayList();
        }
    }
}
TOP

Related Classes of com.sourcetap.sfa.contact.ContactRoleSelectWSS

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.