01: /*
02: *
03: * Copyright (c) 2004 SourceTap - www.sourcetap.com
04: *
05: * The contents of this file are subject to the SourceTap Public License
06: * ("License"); You may not use this file except in compliance with the
07: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
08: * Software distributed under the License is distributed on an "AS IS" basis,
09: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
10: * the specific language governing rights and limitations under the License.
11: *
12: * The above copyright notice and this permission notice shall be included
13: * in all copies or substantial portions of the Software.
14: *
15: */
16:
17: package com.sourcetap.sfa.contact;
18:
19: import java.util.ArrayList;
20: import java.util.HashMap;
21: import java.util.List;
22:
23: import org.ofbiz.base.util.Debug;
24: import org.ofbiz.base.util.UtilMisc;
25: import org.ofbiz.entity.GenericDelegator;
26: import org.ofbiz.entity.GenericEntityException;
27: import org.ofbiz.entity.condition.EntityCondition;
28: import org.ofbiz.entity.condition.EntityConditionList;
29: import org.ofbiz.entity.condition.EntityExpr;
30: import org.ofbiz.entity.condition.EntityOperator;
31: import org.ofbiz.entity.model.DynamicViewEntity;
32: import org.ofbiz.entity.model.ModelKeyMap;
33:
34: import com.sourcetap.sfa.ui.UICache;
35: import com.sourcetap.sfa.ui.UIWebScreenSection;
36: import com.sourcetap.sfa.util.EntityHelper;
37: import com.sourcetap.sfa.util.UserInfo;
38:
39: /**
40: * DOCUMENT ME!
41: *
42: */
43: public class ContactRoleSelectWSS extends UIWebScreenSection {
44: public static final String module = ContactRoleSelectWSS.class
45: .getName();
46:
47: public ContactRoleSelectWSS(UserInfo userInfo, String screenName,
48: String sectionName, GenericDelegator delegator,
49: UICache uiCache) throws GenericEntityException {
50: super (userInfo, screenName, sectionName, delegator, uiCache);
51: }
52:
53: /**
54: * DOCUMENT ME!
55: *
56: * @param useQueryParameterValueMap
57: * @param listedEntityName
58: * @param userInfo
59: * @param delegator
60: *
61: * @return
62: */
63: public List getEligibleEntityList(
64: HashMap useQueryParameterValueMap, String listedEntityName,
65: UserInfo userInfo, GenericDelegator delegator) {
66:
67: ArrayList orderBy = new ArrayList();
68: orderBy.add("description");
69:
70: // select X from roleType rt,. code c where rt.roleTypeId = c.codeId and c.codeTypeId = "ROLE_TYPE_SFA" order by description
71: DynamicViewEntity dve = EntityHelper.createDynamicViewEntity(
72: delegator, "RoleType");
73: dve.addMemberEntity("Code", "Code");
74: dve.addViewLink("RoleType", "Code", Boolean.FALSE, UtilMisc
75: .toList(new ModelKeyMap("roleTypeId", "codeId")));
76: dve
77: .addAlias("Code", "codeTypeId", null, null, null, null,
78: null);
79:
80: EntityCondition condition = new EntityConditionList(UtilMisc
81: .toList(new EntityExpr("codeTypeId",
82: EntityOperator.EQUALS, "ROLE_TYPE_SFA")),
83: EntityOperator.AND);
84:
85: try {
86: return EntityHelper.getPrimaryGVLFromDynamicGVL(delegator,
87: EntityHelper.findByCondition(delegator, dve,
88: condition, orderBy), "RoleType");
89: } catch (Exception e) {
90: Debug
91: .logError(
92: "[ContactRoleSelectWSS.getEligibleEntityList] An error occurred while getting contact role select values:",
93: module);
94: Debug.logError(e.getLocalizedMessage(), module);
95:
96: return new ArrayList();
97: }
98: }
99: }
|