001/*
002 * Copyright 2007-2009 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.ole.coa.identity;
017
018import java.util.ArrayList;
019import java.util.Collections;
020import java.util.Date;
021import java.util.HashMap;
022import java.util.List;
023import java.util.Map;
024
025import org.apache.commons.lang.StringUtils;
026import org.kuali.ole.coa.businessobject.Chart;
027import org.kuali.ole.coa.businessobject.Organization;
028import org.kuali.ole.coa.service.ChartService;
029import org.kuali.ole.coa.service.OrgReviewRoleService;
030import org.kuali.ole.coa.service.OrganizationService;
031import org.kuali.ole.sys.OLEConstants;
032import org.kuali.ole.sys.OLEPropertyConstants;
033import org.kuali.ole.sys.context.SpringContext;
034import org.kuali.ole.sys.identity.OleKimAttributes;
035import org.kuali.rice.core.api.config.property.ConfigurationService;
036import org.kuali.rice.core.api.criteria.PredicateUtils;
037import org.kuali.rice.core.api.criteria.QueryByCriteria;
038import org.kuali.rice.core.api.delegation.DelegationType;
039import org.kuali.rice.core.api.membership.MemberType;
040import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
041import org.kuali.rice.core.api.util.type.KualiDecimal;
042import org.kuali.rice.kew.api.action.ActionType;
043import org.kuali.rice.kew.api.doctype.DocumentTypeService;
044import org.kuali.rice.kew.doctype.bo.DocumentType;
045import org.kuali.rice.kew.doctype.bo.DocumentTypeEBO;
046import org.kuali.rice.kim.api.KimConstants;
047import org.kuali.rice.kim.api.common.delegate.DelegateMemberContract;
048import org.kuali.rice.kim.api.identity.Person;
049import org.kuali.rice.kim.api.role.Role;
050import org.kuali.rice.kim.api.role.RoleMember;
051import org.kuali.rice.kim.api.role.RoleMemberContract;
052import org.kuali.rice.kim.api.role.RoleMemberQueryResults;
053import org.kuali.rice.kim.api.role.RoleResponsibilityAction;
054import org.kuali.rice.kim.api.services.KimApiServiceLocator;
055import org.kuali.rice.kim.api.type.KimType;
056import org.kuali.rice.kim.api.type.KimTypeAttribute;
057import org.kuali.rice.kim.framework.group.GroupEbo;
058import org.kuali.rice.kim.framework.role.RoleEbo;
059import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
060import org.kuali.rice.krad.service.KualiModuleService;
061import org.kuali.rice.krad.service.ModuleService;
062import org.kuali.rice.krad.util.KRADConstants;
063
064/**
065 * @author Kuali Rice Team (kuali-rice@googlegroups.com)
066 */
067public class OrgReviewRole extends PersistableBusinessObjectBase implements MutableInactivatable {
068
069    public static final String CACHE_NAME = OLEConstants.APPLICATION_NAMESPACE_CODE + "/" + "OrgReviewRole";
070
071    protected static final String ORR_INQUIRY_TITLE_PROPERTY = "message.inquiry.org.review.role.title";
072    protected static String INQUIRY_TITLE_VALUE = null;
073
074    private static transient OrgReviewRoleService orgReviewRoleService;
075    private static transient OrganizationService    organizationService;
076    private static transient ChartService           chartService;
077
078    //Dummy variable
079    protected String organizationTypeCode = "99";
080    private static final long serialVersionUID = 1L;
081
082    public static final String REVIEW_ROLES_INDICATOR_FIELD_NAME = "reviewRolesIndicator";
083    public static final String ROLE_NAME_FIELD_NAMESPACE_CODE = "roleMemberRoleNamespaceCode";
084    public static final String ROLE_NAME_FIELD_NAME = "roleMemberRoleName";
085    public static final String GROUP_NAME_FIELD_NAMESPACE_CODE = "groupMemberGroupNamespaceCode";
086    public static final String GROUP_NAME_FIELD_NAME = "groupMemberGroupName";
087    public static final String PRINCIPAL_NAME_FIELD_NAME = "principalMemberPrincipalName";
088    public static final String CHART_CODE_FIELD_NAME = OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE;
089    public static final String ORG_CODE_FIELD_NAME = OLEPropertyConstants.ORGANIZATION_CODE;
090    public static final String DOC_TYPE_NAME_FIELD_NAME = "financialSystemDocumentTypeCode";
091    public static final String DELEGATE_FIELD_NAME = "delegate";
092    public static final String DELEGATION_TYPE_CODE = "delegationTypeCode";
093    public static final String FROM_AMOUNT_FIELD_NAME = "fromAmount";
094    public static final String TO_AMOUNT_FIELD_NAME = "toAmount";
095    public static final String OVERRIDE_CODE_FIELD_NAME = OLEPropertyConstants.OVERRIDE_CODE;
096    public static final String ACTION_TYPE_CODE_FIELD_NAME = "actionTypeCode";
097    public static final String PRIORITY_CODE_FIELD_NAME = "priorityNumber";
098    public static final String ACTION_POLICY_CODE_FIELD_NAME = "actionPolicyCode";
099    public static final String FORCE_ACTION_FIELD_NAME = "forceAction";
100    public static final String ACTIVE_FROM_DATE = "activeFromDate";
101    public static final String ACTIVE_TO_DATE = "activeToDate";
102
103    public static final String ORIGINAL_DELEGATION_MEMBER_ID_TO_MODIFY = "ODelMId";
104    public static final String ORIGINAL_ROLE_MEMBER_ID_TO_MODIFY = "ORMId";
105
106    public static final String NEW_DELEGATION_ID_KEY_VALUE = "New";
107
108    protected String methodToCall;
109    protected String kimTypeId;
110
111    protected String orgReviewRoleMemberId;
112    protected Chart chart;
113    protected Organization organization;
114    protected boolean edit;
115    protected boolean copy;
116
117    protected RoleEbo role;
118    protected GroupEbo group;
119    protected Person person;
120
121    protected List<OleKimDocumentAttributeData> attributes = new ArrayList<OleKimDocumentAttributeData>();
122    protected List<RoleResponsibilityAction> roleRspActions = new ArrayList<RoleResponsibilityAction>();
123
124    //Identifying information for the 3 kinds of role members this document caters to
125    protected String roleMemberRoleId;
126    protected String roleMemberRoleNamespaceCode;
127    protected String roleMemberRoleName;
128
129    protected String groupMemberGroupId;
130    protected String groupMemberGroupNamespaceCode;
131    protected String groupMemberGroupName;
132
133    protected String principalMemberPrincipalId;
134    protected String principalMemberPrincipalName;
135    protected String principalMemberName;
136
137    //The role id this object corresponds to ( org review / acct review )
138    protected String roleId;
139    protected String namespaceCode;
140    protected String roleName;
141
142    //Identifying information for a single member (of any type)
143    protected String memberTypeCode;
144
145    //In case the document is dealing with delegations
146    protected String delegationTypeCode;
147
148    protected String delegationMemberId;
149    protected String roleMemberId;
150
151    protected String oDelMId;
152    protected String oRMId;
153
154    protected String financialSystemDocumentTypeCode;
155    protected DocumentTypeEBO financialSystemDocumentType;
156    protected List<String> roleNamesToConsider;
157    protected String reviewRolesIndicator;
158
159    protected String actionTypeCode;
160    protected String priorityNumber;
161    protected String actionPolicyCode;
162    protected boolean forceAction;
163    protected String chartOfAccountsCode;
164    protected String organizationCode;
165    protected KualiDecimal fromAmount;
166    protected KualiDecimal toAmount;
167    protected String overrideCode;
168    protected boolean active = true;
169    protected boolean delegate;
170
171    protected Date activeFromDate;
172    protected Date activeToDate;
173
174    /**
175     * Gets the active attribute.
176     * @return Returns the active.
177     */
178    @Override
179    public boolean isActive() {
180        return active;
181    }
182    /**
183     * Sets the active attribute value.
184     * @param active The active to set.
185     */
186    @Override
187    public void setActive(boolean active) {
188        this.active = active;
189    }
190    /**
191     * Gets the delegate attribute.
192     * @return Returns the delegate.
193     */
194    public boolean isDelegate() {
195        return delegate;
196    }
197    /**
198     * Sets the delegate attribute value.
199     * @param delegate The delegate to set.
200     */
201    public void setDelegate(boolean delegate) {
202        this.delegate = delegate;
203    }
204    /**
205     * Gets the chart attribute.
206     * @return Returns the chart.
207     */
208    public Chart getChart() {
209        if (StringUtils.isBlank(getChartOfAccountsCode())) {
210            chart = null;
211        }
212        else {
213            if (chart == null || !StringUtils.equals(getChartOfAccountsCode(), chart.getChartOfAccountsCode())) {
214                chart = getChartService().getByPrimaryId(getChartOfAccountsCode());
215            }
216        }
217        return chart;
218    }
219    /**
220     * Gets the groupMemberGroupId attribute.
221     * @return Returns the groupMemberGroupId.
222     */
223    public String getGroupMemberGroupId() {
224        if ( StringUtils.isBlank(groupMemberGroupId) ) {
225            if ( StringUtils.isNotBlank(groupMemberGroupNamespaceCode) && StringUtils.isNotBlank(groupMemberGroupName) ) {
226                getGroup();
227            }
228        }
229        return groupMemberGroupId;
230    }
231    /**
232     * Sets the groupMemberGroupId attribute value.
233     * @param groupMemberGroupId The groupMemberGroupId to set.
234     */
235    public void setGroupMemberGroupId(String groupMemberGroupId) {
236        this.groupMemberGroupId = groupMemberGroupId;
237    }
238    /**
239     * Gets the groupMemberGroupName attribute.
240     * @return Returns the groupMemberGroupName.
241     */
242    public String getGroupMemberGroupName() {
243        return groupMemberGroupName;
244    }
245    /**
246     * Sets the groupMemberGroupName attribute value.
247     * @param groupMemberGroupName The groupMemberGroupName to set.
248     */
249    public void setGroupMemberGroupName(String groupMemberGroupName) {
250        this.groupMemberGroupName = groupMemberGroupName;
251    }
252    /**
253     * Gets the groupMemberGroupNamespaceCode attribute.
254     * @return Returns the groupMemberGroupNamespaceCode.
255     */
256    public String getGroupMemberGroupNamespaceCode() {
257        return groupMemberGroupNamespaceCode;
258    }
259    /**
260     * Sets the groupMemberGroupNamespaceCode attribute value.
261     * @param groupMemberGroupNamespaceCode The groupMemberGroupNamespaceCode to set.
262     */
263    public void setGroupMemberGroupNamespaceCode(String groupMemberGroupNamespaceCode) {
264        this.groupMemberGroupNamespaceCode = groupMemberGroupNamespaceCode;
265    }
266    /**
267     * Gets the principalMemberPrincipalId attribute.
268     * @return Returns the principalMemberPrincipalId.
269     */
270    public String getPrincipalMemberPrincipalId() {
271        if ( StringUtils.isBlank(principalMemberPrincipalId) ) {
272            if ( StringUtils.isNotBlank(principalMemberPrincipalName) ) {
273                getPerson();
274            }
275        }
276        return principalMemberPrincipalId;
277    }
278    /**
279     * Sets the principalMemberPrincipalId attribute value.
280     * @param principalMemberPrincipalId The principalMemberPrincipalId to set.
281     */
282    public void setPrincipalMemberPrincipalId(String principalMemberPrincipalId) {
283        this.principalMemberPrincipalId = principalMemberPrincipalId;
284    }
285    /**
286     * Gets the principalMemberPrincipalName attribute.
287     * @return Returns the principalMemberPrincipalName.
288     */
289    public String getPrincipalMemberPrincipalName() {
290        if ( StringUtils.isBlank(principalMemberPrincipalName) ) {
291            getPerson();
292        }
293        return principalMemberPrincipalName;
294    }
295
296    public String getPrincipalMemberName() {
297        if ( StringUtils.isBlank(principalMemberName) ) {
298            getPerson();
299        }
300        return principalMemberName;
301    }
302
303    /**
304     * Sets the principalMemberPrincipalName attribute value.
305     * @param principalMemberPrincipalName The principalMemberPrincipalName to set.
306     */
307    public void setPrincipalMemberPrincipalName(String principalMemberPrincipalName) {
308        this.principalMemberPrincipalName = principalMemberPrincipalName;
309    }
310    /**
311     * Gets the roleMemberRoleId attribute.
312     * @return Returns the roleMemberRoleId.
313     */
314    public String getRoleMemberRoleId() {
315        if ( StringUtils.isBlank(roleMemberRoleId) ) {
316            if ( StringUtils.isNotBlank(roleMemberRoleName) && StringUtils.isNotBlank(roleMemberRoleName) ) {
317                getRole();
318            }
319        }
320        return roleMemberRoleId;
321    }
322    /**
323     * Sets the roleMemberRoleId attribute value.
324     * @param roleMemberRoleId The roleMemberRoleId to set.
325     */
326    public void setRoleMemberRoleId(String roleMemberRoleId) {
327        this.roleMemberRoleId = roleMemberRoleId;
328    }
329    /**
330     * Gets the roleMemberRoleName attribute.
331     * @return Returns the roleMemberRoleName.
332     */
333    public String getRoleMemberRoleName() {
334        return roleMemberRoleName;
335    }
336    /**
337     * Sets the roleMemberRoleName attribute value.
338     * @param roleMemberRoleName The roleMemberRoleName to set.
339     */
340    public void setRoleMemberRoleName(String roleMemberRoleName) {
341        this.roleMemberRoleName = roleMemberRoleName;
342    }
343    /**
344     * Gets the roleMemberRoleNamespaceCode attribute.
345     * @return Returns the roleMemberRoleNamespaceCode.
346     */
347    public String getRoleMemberRoleNamespaceCode() {
348        return roleMemberRoleNamespaceCode;
349    }
350    /**
351     * Sets the roleMemberRoleNamespaceCode attribute value.
352     * @param roleMemberRoleNamespaceCode The roleMemberRoleNamespaceCode to set.
353     */
354    public void setRoleMemberRoleNamespaceCode(String roleMemberRoleNamespaceCode) {
355        this.roleMemberRoleNamespaceCode = roleMemberRoleNamespaceCode;
356    }
357    /**
358     * Gets the organization attribute.
359     * @return Returns the organization.
360     */
361    public Organization getOrganization() {
362        if (StringUtils.isBlank(getChartOfAccountsCode()) || StringUtils.isBlank(getOrganizationCode())) {
363            organization = null;
364        }
365        else {
366            if (organization == null || !StringUtils.equals(getChartOfAccountsCode(), chart.getChartOfAccountsCode())
367                    || !StringUtils.equals(getOrganizationCode(), organization.getOrganizationCode())) {
368                organization = getOrganizationService().getByPrimaryIdWithCaching(getChartOfAccountsCode(),
369                        getOrganizationCode());
370            }
371        }
372        return organization;
373    }
374
375    /**
376     * Gets the overrideCode attribute.
377     * @return Returns the overrideCode.
378     */
379    public String getOverrideCode() {
380        return this.overrideCode;
381    }
382    /**
383     * Sets the overrideCode attribute value.
384     * @param overrideCode The overrideCode to set.
385     */
386    public void setOverrideCode(String overrideCode) {
387        this.overrideCode = overrideCode;
388    }
389
390    /**
391     * Gets the fromAmount attribute.
392     * @return Returns the fromAmount.
393     */
394    public KualiDecimal getFromAmount() {
395        return fromAmount;
396    }
397
398    public String getFromAmountStr() {
399        return fromAmount==null?null:fromAmount.toString();
400    }
401
402    /**
403     * Sets the fromAmount attribute value.
404     * @param fromAmount The fromAmount to set.
405     */
406    public void setFromAmount(KualiDecimal fromAmount) {
407        this.fromAmount = fromAmount;
408    }
409
410    public void setFromAmount(String fromAmount) {
411        if (StringUtils.isNotEmpty(fromAmount) && StringUtils.isNumeric(fromAmount)) {
412            this.fromAmount = new KualiDecimal(fromAmount);
413        }
414        else {
415            this.fromAmount = null;
416        }
417    }
418
419    /**
420     * Gets the toAmount attribute.
421     * @return Returns the toAmount.
422     */
423    public KualiDecimal getToAmount() {
424        return toAmount;
425    }
426
427    public String getToAmountStr() {
428        return toAmount==null?null:toAmount.toString();
429    }
430
431    /**
432     * Sets the toAmount attribute value.
433     * @param toAmount The toAmount to set.
434     */
435    public void setToAmount(KualiDecimal toAmount) {
436        this.toAmount = toAmount;
437    }
438
439    public void setToAmount(String toAmount) {
440        if (StringUtils.isNotEmpty(toAmount) && StringUtils.isNumeric(toAmount)) {
441            this.toAmount = new KualiDecimal(toAmount);
442        }
443        else {
444            this.toAmount = null;
445        }
446    }
447
448    /**
449     * Gets the activeFromDate attribute.
450     * @return Returns the activeFromDate.
451     */
452    public Date getActiveFromDate() {
453        return activeFromDate;
454    }
455    /**
456     * Sets the activeFromDate attribute value.
457     * @param activeFromDate The activeFromDate to set.
458     */
459    public void setActiveFromDate(java.util.Date activeFromDate) {
460        this.activeFromDate = activeFromDate;
461    }
462
463    /**
464     * Gets the activeToDate attribute.
465     * @return Returns the activeToDate.
466     */
467    public Date getActiveToDate() {
468        return activeToDate;
469    }
470    /**
471     * Sets the activeToDate attribute value.
472     * @param activeToDate The activeToDate to set.
473     */
474    public void setActiveToDate(java.util.Date activeToDate) {
475        this.activeToDate = activeToDate;
476    }
477
478    /**
479     * Gets the orgReviewRoleMemberId attribute.
480     * @return Returns the orgReviewRoleMemberId.
481     */
482    public String getOrgReviewRoleMemberId() {
483        return orgReviewRoleMemberId;
484    }
485    /**
486     * Sets the orgReviewRoleMemberId attribute value.
487     * @param orgReviewRoleMemberId The orgReviewRoleMemberId to set.
488     */
489    public void setOrgReviewRoleMemberId(String orgReviewRoleMemberId) {
490        this.orgReviewRoleMemberId = orgReviewRoleMemberId;
491    }
492
493    @Override
494    public void refresh() {}
495
496    /**
497     * Gets the financialSystemDocumentTypeCode attribute.
498     * @return Returns the financialSystemDocumentTypeCode.
499     */
500    public DocumentTypeEBO getFinancialSystemDocumentType() {
501        if ( StringUtils.isBlank( financialSystemDocumentTypeCode ) ) {
502            financialSystemDocumentType = null;
503        } else {
504            if ( financialSystemDocumentType == null || !StringUtils.equals(financialSystemDocumentTypeCode, financialSystemDocumentType.getName() ) ) {
505                org.kuali.rice.kew.api.doctype.DocumentType temp = SpringContext.getBean(DocumentTypeService.class).getDocumentTypeByName(financialSystemDocumentTypeCode);
506                if ( temp != null ) {
507                    financialSystemDocumentType = DocumentType.from( temp );
508                } else {
509                    financialSystemDocumentType = null;
510                }
511            }
512        }
513        return financialSystemDocumentType;
514    }
515
516    /**
517     * Gets the financialDocumentTypeCode attribute.
518     * @return Returns the financialDocumentTypeCode.
519     */
520    public String getFinancialSystemDocumentTypeCode() {
521        return financialSystemDocumentTypeCode;
522    }
523    /**
524     * Sets the financialDocumentTypeCode attribute value.
525     * @param financialDocumentTypeCode The financialDocumentTypeCode to set.
526     */
527    public void setFinancialSystemDocumentTypeCode(String financialSystemDocumentTypeCode) {
528        boolean isChanged = !StringUtils.equals(this.financialSystemDocumentTypeCode, financialSystemDocumentTypeCode);
529        this.financialSystemDocumentTypeCode = financialSystemDocumentTypeCode;
530        setRoleNamesAndReviewIndicator(isChanged);
531    }
532
533    private void setRoleNamesAndReviewIndicator(boolean hasFinancialSystemDocumentTypeCodeChanged){
534        if(hasFinancialSystemDocumentTypeCodeChanged){
535            //If role id is populated role names to consider have already been narrowed down
536            if(StringUtils.isNotBlank(getRoleId()) && StringUtils.isNotBlank(getRoleName())){
537                setRoleNamesToConsider(Collections.singletonList(getRoleName()));
538            } else {
539                setRoleNamesToConsider();
540            }
541            if(isBothReviewRolesIndicator()) {
542                setReviewRolesIndicatorOnDocTypeChange(OLEConstants.COAConstants.ORG_REVIEW_ROLE_ORG_ACC_BOTH_CODE);
543            } else if(isAccountingOrgReviewRoleIndicator()) {
544                setReviewRolesIndicatorOnDocTypeChange(OLEConstants.COAConstants.ORG_REVIEW_ROLE_ORG_ACC_ONLY_CODE);
545            } else if(isOrgReviewRoleIndicator()) {
546                setReviewRolesIndicatorOnDocTypeChange(OLEConstants.COAConstants.ORG_REVIEW_ROLE_ORG_ONLY_CODE);
547            }
548        }
549    }
550
551    /**
552     * Sets the financialSystemDocumentTypeCode attribute value.
553     * @param financialSystemDocumentTypeCode The financialSystemDocumentTypeCode to set.
554     */
555    public void setFinancialSystemDocumentType(DocumentTypeEBO financialSystemDocumentType) {
556        this.financialSystemDocumentType = financialSystemDocumentType;
557    }
558    /**
559     * Gets the delegationTypeCode attribute.
560     * @return Returns the delegationTypeCode.
561     */
562    public String getDelegationTypeCode() {
563        return delegationTypeCode;
564    }
565
566    public String getDelegationTypeCodeDescription() {
567        if ( getDelegationType() != null ) {
568            return getDelegationType().getLabel();
569        }
570        return "";
571    }
572
573    public DelegationType getDelegationType() {
574        return DelegationType.parseCode(delegationTypeCode);
575    }
576
577    /**
578     * Sets the delegationTypeCode attribute value.
579     * @param delegationTypeCode The delegationTypeCode to set.
580     */
581    public void setDelegationTypeCode(String delegationTypeCode) {
582        this.delegationTypeCode = delegationTypeCode;
583    }
584
585    /**
586     * Gets the memberTypeCode attribute.
587     * @return Returns the memberTypeCode.
588     */
589    public String getMemberTypeCodeDescription() {
590        return KimConstants.KimUIConstants.KIM_MEMBER_TYPES_MAP.get(memberTypeCode);
591    }
592    /**
593     * Sets the memberTypeCode attribute value.
594     * @param memberTypeCode The memberTypeCode to set.
595     */
596    public void setMemberTypeCode(String memberTypeCode) {
597        this.memberTypeCode = memberTypeCode;
598    }
599    /**
600     * Sets the attributes attribute value.
601     * @param attributes The attributes to set.
602     */
603    public void setAttributes(List<OleKimDocumentAttributeData> attributes) {
604        this.attributes = attributes;
605    }
606
607    public List<OleKimDocumentAttributeData> getAttributes() {
608        return attributes;
609    }
610
611    public String getAttributeValue(String attributeName){
612        OleKimDocumentAttributeData attributeData = getAttribute(attributeName);
613        return attributeData==null?"":attributeData.getAttrVal();
614    }
615
616    protected OleKimDocumentAttributeData getAttribute(String attributeName){
617        if(StringUtils.isNotBlank(attributeName)) {
618            for(OleKimDocumentAttributeData attribute: attributes){
619                if( attribute.getKimAttribute()!=null
620                        && StringUtils.equals(attribute.getKimAttribute().getAttributeName(),attributeName)){
621                    return attribute;
622                }
623            }
624        }
625        return null;
626    }
627
628    /**
629     * Gets the chartCode attribute.
630     * @return Returns the chartCode.
631     */
632    public String getChartOfAccountsCode() {
633        return this.chartOfAccountsCode;
634    }
635    /**
636     * Gets the organizationCode attribute.
637     * @return Returns the organizationCode.
638     */
639    public String getOrganizationCode() {
640        return this.organizationCode;
641    }
642    /**
643     * Sets the organizationCode attribute value.
644     * @param organizationCode The organizationCode to set.
645     */
646    public void setOrganizationCode(String organizationCode) {
647        this.organizationCode = organizationCode;
648    }
649    /**
650     * Sets the chartOfAccountsCode attribute value.
651     * @param chartOfAccountsCode The chartOfAccountsCode to set.
652     */
653    public void setChartOfAccountsCode(String chartOfAccountsCode) {
654        this.chartOfAccountsCode = chartOfAccountsCode;
655    }
656    /**
657     * Gets the roleNamesToConsider attribute.
658     * @return Returns the roleNamesToConsider.
659     */
660    public List<String> getRoleNamesToConsider() {
661        if(roleNamesToConsider==null && getFinancialSystemDocumentTypeCode()!=null) {
662            setRoleNamesToConsider();
663        }
664        return roleNamesToConsider;
665    }
666    public void setRoleNamesToConsider(List<String> narrowedDownRoleNames) {
667        roleNamesToConsider = new ArrayList<String>( narrowedDownRoleNames );
668    }
669    /**
670     * Sets the roleNamesToConsider attribute value.
671     * @param roleNamesToConsider The roleNamesToConsider to set.
672     */
673    public void setRoleNamesToConsider() {
674        roleNamesToConsider = getOrgReviewRoleService().getRolesToConsider(getFinancialSystemDocumentTypeCode());
675    }
676    /**
677     * Gets the accountingOrgReviewRoleIndicator attribute.
678     * @return Returns the accountingOrgReviewRoleIndicator.
679     */
680    public boolean isAccountingOrgReviewRoleIndicator() {
681        return getRoleNamesToConsider()!=null &&
682            getRoleNamesToConsider().contains(OLEConstants.SysKimApiConstants.ACCOUNTING_REVIEWER_ROLE_NAME);
683    }
684    /**
685     * Gets the bothReviewRolesIndicator attribute.
686     * @return Returns the bothReviewRolesIndicator.
687     */
688    public boolean isBothReviewRolesIndicator() {
689        return getRoleNamesToConsider()!=null &&
690            getRoleNamesToConsider().contains(OLEConstants.SysKimApiConstants.ORGANIZATION_REVIEWER_ROLE_NAME) &&
691            getRoleNamesToConsider().contains(OLEConstants.SysKimApiConstants.ACCOUNTING_REVIEWER_ROLE_NAME);
692    }
693    /**
694     * Gets the orgReviewRoleIndicator attribute.
695     * @return Returns the orgReviewRoleIndicator.
696     */
697    public boolean isOrgReviewRoleIndicator() {
698        return getRoleNamesToConsider()!=null &&
699            getRoleNamesToConsider().contains(OLEConstants.SysKimApiConstants.ORGANIZATION_REVIEWER_ROLE_NAME);
700    }
701    /**
702     * Gets the actionTypeCode attribute.
703     * @return Returns the actionTypeCode.
704     */
705    public String getActionTypeCode() {
706        return actionTypeCode;
707    }
708
709    public String getActionTypeCodeToDisplay() {
710        if(roleRspActions==null || roleRspActions.isEmpty()) {
711            return "";
712        }
713        return roleRspActions.get(0).getActionTypeCode();
714    }
715
716    /**
717     *
718     * This method fore readonlyalterdisplay
719     *
720     * @return
721     */
722    public String getActionTypeCodeDescription() {
723        ActionType at = ActionType.fromCode(getActionTypeCodeToDisplay(), true);
724        return (at==null)?"":at.getLabel();
725    }
726
727    /**
728     * Sets the actionTypeCode attribute value.
729     * @param actionTypeCode The actionTypeCode to set.
730     */
731    public void setActionTypeCode(String actionTypeCode) {
732        this.actionTypeCode = actionTypeCode;
733    }
734    /**
735     * Gets the priorityNumber attribute.
736     * @return Returns the priorityNumber.
737     */
738    public String getPriorityNumber() {
739        return priorityNumber;
740    }
741
742    public String getPriorityNumberToDisplay() {
743        if(roleRspActions==null || roleRspActions.isEmpty() ) {
744            return "";
745        }
746        return roleRspActions.get(0).getPriorityNumber()==null?"":roleRspActions.get(0).getPriorityNumber()+"";
747    }
748
749    /**
750     * Sets the priorityNumber attribute value.
751     * @param priorityNumber The priorityNumber to set.
752     */
753    public void setPriorityNumber(String priorityNumber) {
754        this.priorityNumber = priorityNumber;
755    }
756    /**
757     * Gets the actionPolicyCode attribute.
758     * @return Returns the actionPolicyCode.
759     */
760    public String getActionPolicyCode() {
761        return actionPolicyCode;
762    }
763    /**
764     * Sets the actionPolicyCode attribute value.
765     * @param actionPolicyCode The actionPolicyCode to set.
766     */
767    public void setActionPolicyCode(String actionPolicyCode) {
768        this.actionPolicyCode = actionPolicyCode;
769    }
770    /**
771     * Gets the ignorePrevious attribute.
772     * @return Returns the ignorePrevious.
773     */
774    public boolean isForceAction() {
775        return forceAction;
776    }
777    /**
778     * Sets the ignorePrevious attribute value.
779     * @param ignorePrevious The ignorePrevious to set.
780     */
781    public void setForceAction(boolean forceAction) {
782        this.forceAction = forceAction;
783    }
784
785    /**
786     * Gets the roleId attribute.
787     * @return Returns the roleId.
788     */
789    public String getRoleId() {
790        return roleId;
791    }
792    /**
793     * Sets the roleId attribute value.
794     * @param roleId The roleId to set.
795     */
796    public void setRoleId(String roleId) {
797        Role roleInfo = KimApiServiceLocator.getRoleService().getRole(roleId);
798        if ( roleInfo != null ) {
799            setNamespaceCode(roleInfo.getNamespaceCode());
800            setRoleName(roleInfo.getName());
801            setKimTypeId(roleInfo.getKimTypeId());
802        }
803        this.roleId = roleId;
804    }
805    /**
806     * Gets the reviewRolesIndicator attribute.
807     * @return Returns the reviewRolesIndicator.
808     */
809    public String getReviewRolesIndicator() {
810        return reviewRolesIndicator;
811    }
812    /**
813     * Sets the reviewRolesIndicator attribute value.
814     * @param reviewRolesIndicator The reviewRolesIndicator to set.
815     */
816    public void setReviewRolesIndicator(String reviewRolesIndicator) {
817        this.reviewRolesIndicator = reviewRolesIndicator;
818    }
819    /**
820     * Sets the reviewRolesIndicator attribute value.
821     * @param reviewRolesIndicator The reviewRolesIndicator to set.
822     */
823    private void setReviewRolesIndicatorOnDocTypeChange(String reviewRolesIndicator) {
824        this.reviewRolesIndicator = reviewRolesIndicator;
825    }
826
827
828    public boolean hasRole(){
829        getRole();
830        return StringUtils.isNotBlank(roleMemberRoleName);
831    }
832
833    public boolean hasGroup(){
834        getGroup();
835        return StringUtils.isNotBlank(groupMemberGroupName);
836    }
837
838    public boolean hasPrincipal(){
839        getPerson();
840        return StringUtils.isNotBlank(principalMemberPrincipalName);
841    }
842
843    public boolean hasAnyMember(){
844        return hasRole() || hasGroup() || hasPrincipal();
845    }
846
847    public void setRoleMember( RoleMemberContract roleMember ) {
848        memberTypeCode = roleMember.getType().getCode();
849        if(MemberType.ROLE.equals(roleMember.getType())){
850            roleMemberRoleId = roleMember.getMemberId();
851            roleMemberRoleNamespaceCode = roleMember.getMemberNamespaceCode();
852            roleMemberRoleName = roleMember.getMemberName();
853        } else if(MemberType.GROUP.equals(roleMember.getType())){
854            groupMemberGroupId = roleMember.getMemberId();
855            groupMemberGroupNamespaceCode = roleMember.getMemberNamespaceCode();
856            groupMemberGroupName = roleMember.getMemberName();
857        } else if(MemberType.PRINCIPAL.equals(roleMember.getType())){
858            principalMemberPrincipalId = roleMember.getMemberId();
859            principalMemberPrincipalName = roleMember.getMemberName();
860        }
861
862        if ( roleMember.getActiveFromDate() != null ) {
863            setActiveFromDate(roleMember.getActiveFromDate().toDate());
864        } else {
865            setActiveFromDate( null );
866        }
867        if ( roleMember.getActiveToDate() != null ) {
868            setActiveToDate(roleMember.getActiveToDate().toDate());
869        } else {
870            setActiveToDate( null );
871        }
872        setActive(roleMember.isActive());
873
874        setRoleMemberId(roleMember.getId());
875        setDelegate(false);
876        setRoleId(roleMember.getRoleId());
877
878        setRoleRspActions(KimApiServiceLocator.getRoleService().getRoleMemberResponsibilityActions(roleMember.getId()));
879
880        extractAttributesFromMap(roleMember.getAttributes());
881    }
882
883    public void extractAttributesFromMap( Map<String,String> attributes ) {
884        setAttributes(getAttributeSetAsQualifierList(attributes));
885
886
887        setChartOfAccountsCode(getAttributeValue(OleKimAttributes.CHART_OF_ACCOUNTS_CODE));
888        setOrganizationCode(getAttributeValue(OleKimAttributes.ORGANIZATION_CODE));
889        setOverrideCode(getAttributeValue(OleKimAttributes.ACCOUNTING_LINE_OVERRIDE_CODE));
890        setFromAmount(getAttributeValue(OleKimAttributes.FROM_AMOUNT));
891        setToAmount(getAttributeValue(OleKimAttributes.TO_AMOUNT));
892        setFinancialSystemDocumentTypeCode(getAttributeValue(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME));
893    }
894
895    public void setDelegateMember( RoleMemberContract roleMember, DelegateMemberContract delegateMember ) {
896        if ( roleMember == null ) {
897            roleMember = getRoleMemberFromKimRoleService( delegateMember.getRoleMemberId() );
898        }
899        setRoleId( roleMember.getRoleId() );
900        memberTypeCode = delegateMember.getType().getCode();
901        if(MemberType.ROLE.equals(delegateMember.getType())){
902            roleMemberRoleId = delegateMember.getMemberId();
903            getRole();
904        } else if(MemberType.GROUP.equals(delegateMember.getType())){
905            groupMemberGroupId = delegateMember.getMemberId();
906            getGroup();
907        } else if(MemberType.PRINCIPAL.equals(delegateMember.getType())){
908            principalMemberPrincipalId = delegateMember.getMemberId();
909            getPerson();
910        }
911
912        if ( delegateMember.getActiveFromDate() != null ) {
913            setActiveFromDate(delegateMember.getActiveFromDate().toDate());
914        }
915        if ( delegateMember.getActiveToDate() != null ) {
916            setActiveToDate(delegateMember.getActiveToDate().toDate());
917        }
918        setActive(delegateMember.isActive());
919        setDelegate(true);
920        setDelegationMemberId(delegateMember.getDelegationMemberId());
921        setRoleMemberId(roleMember.getId());
922
923        extractAttributesFromMap(delegateMember.getAttributes());
924    }
925
926    protected RoleMember getRoleMemberFromKimRoleService( String roleMemberId ) {
927        RoleMemberQueryResults roleMembers = KimApiServiceLocator.getRoleService().findRoleMembers(QueryByCriteria.Builder.fromPredicates( PredicateUtils.convertMapToPredicate(Collections.singletonMap(KimConstants.PrimaryKeyConstants.ID, roleMemberId))));
928        if ( roleMembers == null || roleMembers.getResults() == null || roleMembers.getResults().isEmpty() ) {
929            throw new IllegalArgumentException( "Unknown role member ID passed in - nothing returned from KIM RoleService: " + roleMemberId );
930        }
931        return roleMembers.getResults().get(0);
932    }
933
934    public String getMemberId() {
935        if(MemberType.ROLE.getCode().equals(memberTypeCode)){
936            return getRoleMemberRoleId();
937        } else if(MemberType.GROUP.getCode().equals(memberTypeCode)){
938            return getGroupMemberGroupId();
939        } else if(MemberType.PRINCIPAL.getCode().equals(memberTypeCode)){
940            return getPrincipalMemberPrincipalId();
941        }
942        return "";
943    }
944
945    public String getMemberName() {
946        if(MemberType.ROLE.getCode().equals(memberTypeCode)){
947            return getRoleMemberRoleName();
948        } else if(MemberType.GROUP.getCode().equals(memberTypeCode)){
949            return getGroupMemberGroupName();
950        } else if(MemberType.PRINCIPAL.getCode().equals(memberTypeCode)){
951            return getPrincipalMemberName();
952        }
953        return "";
954    }
955
956    public String getMemberNamespaceCode() {
957        if(MemberType.ROLE.getCode().equals(memberTypeCode)){
958            return getRoleMemberRoleNamespaceCode();
959        } else if(MemberType.GROUP.getCode().equals(memberTypeCode)){
960            return getGroupMemberGroupNamespaceCode();
961        } else if(MemberType.PRINCIPAL.getCode().equals(memberTypeCode)){
962            return "";
963        }
964        return "";
965    }
966
967    public String getMemberFieldName(){
968        if(MemberType.ROLE.equals(getMemberType())) {
969            return ROLE_NAME_FIELD_NAME;
970        } else if(MemberType.GROUP.equals(getMemberType())) {
971            return GROUP_NAME_FIELD_NAME;
972        } else if(MemberType.PRINCIPAL.equals(getMemberType())) {
973            return PRINCIPAL_NAME_FIELD_NAME;
974        }
975        return null;
976    }
977
978    /**
979     * Gets the memberTypeCode attribute.
980     * @return Returns the memberTypeCode.
981     */
982    public String getMemberTypeCode() {
983        return memberTypeCode;
984    }
985
986    public MemberType getMemberType() {
987        if ( StringUtils.isBlank(memberTypeCode) ) {
988            return null;
989        }
990        return MemberType.fromCode(memberTypeCode);
991    }
992
993    /**
994     * Gets the group attribute.
995     * @return Returns the group.
996     */
997    public GroupEbo getGroup() {
998        if ( (group == null || !StringUtils.equals(group.getId(), groupMemberGroupId)) && StringUtils.isNotBlank(groupMemberGroupId) ) {
999            ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(GroupEbo.class);
1000            if ( moduleService != null ) {
1001                Map<String,Object> keys = new HashMap<String, Object>(1);
1002                keys.put(KimConstants.PrimaryKeyConstants.ID, groupMemberGroupId);
1003                group = moduleService.getExternalizableBusinessObject(GroupEbo.class, keys);
1004                groupMemberGroupNamespaceCode = group.getNamespaceCode();
1005                groupMemberGroupName = group.getName();
1006            } else {
1007                throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
1008            }
1009        } else if ( StringUtils.isNotBlank(groupMemberGroupName) ) {
1010            ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(GroupEbo.class);
1011            if ( moduleService != null ) {
1012                // if we have both a namespace and a name
1013                if ( StringUtils.isNotBlank(groupMemberGroupNamespaceCode) ) {
1014                    Map<String,Object> keys = new HashMap<String, Object>(2);
1015                    keys.put(KimConstants.UniqueKeyConstants.NAMESPACE_CODE, groupMemberGroupNamespaceCode);
1016                    keys.put(KimConstants.UniqueKeyConstants.GROUP_NAME, groupMemberGroupName);
1017                    List<GroupEbo> groups = moduleService.getExternalizableBusinessObjectsList(GroupEbo.class, keys);
1018                    // this *should* only retrieve a single record
1019                    if ( groups != null && !groups.isEmpty() ) {
1020                        group = groups.get(0);
1021                        groupMemberGroupId = group.getId();
1022                    } else {
1023                        group = null;
1024                        groupMemberGroupId = "";
1025                    }
1026                } else { // if we only have the name - see if it's unique
1027                    Map<String,Object> keys = new HashMap<String, Object>(1);
1028                    keys.put(KimConstants.UniqueKeyConstants.GROUP_NAME, groupMemberGroupName);
1029                    List<GroupEbo> groups = moduleService.getExternalizableBusinessObjectsList(GroupEbo.class, keys);
1030                    // if retrieves a single record, then it's unique, we set it and the namespace
1031                    if ( groups != null && groups.size() == 1 ) {
1032                        group = groups.get(0);
1033                        groupMemberGroupId = group.getId();
1034                        groupMemberGroupNamespaceCode = group.getNamespaceCode();
1035                    } else {
1036                        group = null;
1037                        groupMemberGroupId = "";
1038                    }
1039                }
1040            } else {
1041                throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
1042            }
1043        } else {
1044            group = null;
1045        }
1046        return group;
1047    }
1048    /**
1049     * Sets the group attribute value.
1050     * @param group The group to set.
1051     */
1052    public void setGroup(GroupEbo group) {
1053        this.group = group;
1054        if ( group != null ) {
1055            groupMemberGroupNamespaceCode = group.getNamespaceCode();
1056            groupMemberGroupName = group.getName();
1057            groupMemberGroupId = group.getId();
1058        } else {
1059            groupMemberGroupNamespaceCode = "";
1060            groupMemberGroupName = "";
1061            groupMemberGroupId = "";
1062        }
1063    }
1064    /**
1065     * Gets the person attribute.
1066     * @return Returns the person.
1067     */
1068    public Person getPerson() {
1069        if( (StringUtils.isNotEmpty(principalMemberPrincipalId)
1070                || StringUtils.isNotEmpty(principalMemberPrincipalName))
1071                &&
1072                (person==null || !StringUtils.equals(person.getPrincipalId(), principalMemberPrincipalId) ) ) {
1073            if ( StringUtils.isNotEmpty(principalMemberPrincipalId) ) {
1074                person = KimApiServiceLocator.getPersonService().getPerson(principalMemberPrincipalId);
1075            } else if ( StringUtils.isNotEmpty(principalMemberPrincipalName) ) {
1076                person = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(principalMemberPrincipalName);
1077            } else {
1078                person = null;
1079            }
1080            if ( person != null ) {
1081                principalMemberPrincipalId = person.getPrincipalId();
1082                principalMemberPrincipalName = person.getPrincipalName();
1083                principalMemberName = person.getName();
1084            } else {
1085                principalMemberPrincipalId = "";
1086                principalMemberName = "";
1087            }
1088        }
1089        return person;
1090    }
1091    /**
1092     * Sets the person attribute value.
1093     * @param person The person to set.
1094     */
1095    public void setPerson(Person person) {
1096        this.person = person;
1097        if ( person != null ) {
1098            principalMemberPrincipalName = person.getPrincipalName();
1099            principalMemberPrincipalId = person.getPrincipalId();
1100            principalMemberName = person.getName();
1101        } else {
1102            principalMemberPrincipalId = "";
1103            principalMemberPrincipalName = "";
1104            principalMemberName = "";
1105        }
1106    }
1107
1108    /**
1109     * Gets the role attribute.
1110     * @return Returns the role.
1111     */
1112    public RoleEbo getRole() {
1113        if ( (role == null || !StringUtils.equals(role.getId(), roleMemberRoleId)) && StringUtils.isNotBlank(roleMemberRoleId) ) {
1114            ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(RoleEbo.class);
1115            if ( moduleService != null ) {
1116                Map<String,Object> keys = new HashMap<String, Object>(1);
1117                keys.put(KimConstants.PrimaryKeyConstants.ROLE_ID, roleMemberRoleId);
1118                role = moduleService.getExternalizableBusinessObject(RoleEbo.class, keys);
1119                roleMemberRoleNamespaceCode = role.getNamespaceCode();
1120                roleMemberRoleName = role.getName();
1121            } else {
1122                throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
1123            }
1124        } else if ( StringUtils.isNotBlank(roleMemberRoleName) ) {
1125            ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(RoleEbo.class);
1126            if ( moduleService != null ) {
1127                // if we have both a namespace and a name
1128                if ( StringUtils.isNotBlank(roleMemberRoleNamespaceCode) ) {
1129                    Map<String,Object> keys = new HashMap<String, Object>(2);
1130                    keys.put(KimConstants.UniqueKeyConstants.NAMESPACE_CODE, roleMemberRoleNamespaceCode);
1131                    keys.put(KimConstants.UniqueKeyConstants.NAME, roleMemberRoleName);
1132                    List<RoleEbo> roles = moduleService.getExternalizableBusinessObjectsList(RoleEbo.class, keys);
1133                    // this *should* only retrieve a single record
1134                    if ( roles != null && !roles.isEmpty() ) {
1135                        role = roles.get(0);
1136                        roleMemberRoleId = role.getId();
1137                    } else {
1138                        role = null;
1139                        roleMemberRoleId = "";
1140                    }
1141                } else { // if we only have the name - see if it's unique
1142                    Map<String,Object> keys = new HashMap<String, Object>(1);
1143                    keys.put(KimConstants.UniqueKeyConstants.NAME, roleMemberRoleName);
1144                    List<RoleEbo> roles = moduleService.getExternalizableBusinessObjectsList(RoleEbo.class, keys);
1145                    // if retrieves a single record, then it's unique, we set it and the namespace
1146                    if ( roles != null && roles.size() == 1 ) {
1147                        role = roles.get(0);
1148                        roleMemberRoleId = role.getId();
1149                        roleMemberRoleNamespaceCode = role.getNamespaceCode();
1150                    } else {
1151                        role = null;
1152                        roleMemberRoleId = "";
1153                    }
1154                }
1155            } else {
1156                throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
1157            }
1158        } else {
1159            role = null;
1160        }
1161        return role;
1162    }
1163
1164    public void setRole( RoleEbo role ) {
1165        this.role = role;
1166        if ( role != null ) {
1167            roleMemberRoleNamespaceCode = role.getNamespaceCode();
1168            roleMemberRoleName = role.getName();
1169            roleMemberRoleId = role.getId();
1170        } else {
1171            roleMemberRoleNamespaceCode = "";
1172            roleMemberRoleName = "";
1173            roleMemberRoleId = "";
1174        }
1175    }
1176
1177    /**
1178     * Gets the copy attribute.
1179     * @return Returns the copy.
1180     */
1181    public boolean isCopy() {
1182        return copy || KRADConstants.MAINTENANCE_COPY_METHOD_TO_CALL.equalsIgnoreCase(methodToCall);
1183    }
1184    /**
1185     * Sets the copy attribute value.
1186     * @param copy The copy to set.
1187     */
1188    public void setCopy(boolean copy) {
1189        this.copy = copy;
1190    }
1191    /**
1192     * Gets the edit attribute.
1193     * @return Returns the edit.
1194     */
1195    public boolean isEdit() {
1196        return edit || KRADConstants.MAINTENANCE_EDIT_METHOD_TO_CALL.equalsIgnoreCase(methodToCall);
1197    }
1198    /**
1199     * Sets the edit attribute value.
1200     * @param edit The edit to set.
1201     */
1202    public void setEdit(boolean edit) {
1203        this.edit = edit;
1204    }
1205    /**
1206     * Gets the oDelMId attribute.
1207     * @return Returns the oDelMId.
1208     */
1209    public String getODelMId() {
1210        return oDelMId;
1211    }
1212    /**
1213     * Sets the oDelMId attribute value.
1214     * @param delMId The oDelMId to set.
1215     */
1216    public void setODelMId(String delMId) {
1217        oDelMId = delMId;
1218    }
1219    /**
1220     * Gets the oRMId attribute.
1221     * @return Returns the oRMId.
1222     */
1223    public String getORMId() {
1224        return oRMId;
1225    }
1226    /**
1227     * Sets the oRMId attribute value.
1228     * @param id The oRMId to set.
1229     */
1230    public void setORMId(String id) {
1231        oRMId = id;
1232    }
1233    /**
1234     * Gets the delegationMemberId attribute.
1235     * @return Returns the delegationMemberId.
1236     */
1237    public String getDelegationMemberId() {
1238        return delegationMemberId;
1239    }
1240    /**
1241     * Sets the delegationMemberId attribute value.
1242     * @param delegationMemberId The delegationMemberId to set.
1243     */
1244    public void setDelegationMemberId(String delegationMemberId) {
1245        this.delegationMemberId = delegationMemberId;
1246    }
1247    /**
1248     * Gets the roleMemberId attribute.
1249     * @return Returns the roleMemberId.
1250     */
1251    public String getRoleMemberId() {
1252        return roleMemberId;
1253    }
1254    /**
1255     * Sets the roleMemberId attribute value.
1256     * @param roleMemberId The roleMemberId to set.
1257     */
1258    public void setRoleMemberId(String roleMemberId) {
1259        this.roleMemberId = roleMemberId;
1260    }
1261    /**
1262     * Gets the methodToCall attribute.
1263     * @return Returns the methodToCall.
1264     */
1265    public String getMethodToCall() {
1266        return methodToCall;
1267    }
1268    /**
1269     * Sets the methodToCall attribute value.
1270     * @param methodToCall The methodToCall to set.
1271     */
1272    public void setMethodToCall(String methodToCall) {
1273        this.methodToCall = methodToCall;
1274    }
1275
1276    public boolean isEditDelegation(){
1277        return isEdit() && isDelegate();
1278    }
1279
1280    public boolean isEditRoleMember(){
1281        return isEdit() && !isDelegate();
1282    }
1283
1284    public boolean isCopyDelegation(){
1285        return isCopy() && isDelegate();
1286    }
1287
1288    public boolean isCopyRoleMember(){
1289        return isCopy() && !isDelegate();
1290    }
1291
1292    public boolean isCreateDelegation(){
1293        return NEW_DELEGATION_ID_KEY_VALUE.equals(getODelMId()) || (isEditDelegation() && StringUtils.isBlank(getDelegationMemberId()));
1294    }
1295
1296    public boolean isCreateRoleMember(){
1297        return StringUtils.isEmpty(methodToCall);
1298    }
1299
1300    public String getOrganizationTypeCode() {
1301        return "99";
1302    }
1303    public void setOrganizationTypeCode(String organizationTypeCode) {
1304    }
1305    public String getRoleName() {
1306        return roleName;
1307    }
1308    public void setRoleName(String roleName) {
1309        this.roleName = roleName;
1310        setRoleNamesToConsider( Collections.singletonList(roleName) );
1311    }
1312    public String getNamespaceCode() {
1313        return namespaceCode;
1314    }
1315    public void setNamespaceCode(String namespaceCode) {
1316        this.namespaceCode = namespaceCode;
1317    }
1318
1319    @Override
1320    public Long getVersionNumber(){
1321        return 1L;
1322    }
1323
1324    public String getKimTypeId() {
1325        return kimTypeId;
1326    }
1327    public void setKimTypeId(String kimTypeId) {
1328        this.kimTypeId = kimTypeId;
1329    }
1330
1331    public Map<String,String> getQualifierAsAttributeSet(List<OleKimDocumentAttributeData> qualifiers) {
1332        Map<String,String> m = new HashMap<String,String>();
1333        for(OleKimDocumentAttributeData data: qualifiers){
1334            m.put(data.getKimAttribute().getAttributeName(), data.getAttrVal());
1335        }
1336        return m;
1337    }
1338
1339    public List<OleKimDocumentAttributeData> getAttributeSetAsQualifierList( Map<String,String> qualifiers) {
1340        KimType kimTypeInfo = KimApiServiceLocator.getKimTypeInfoService().getKimType(kimTypeId);
1341        List<OleKimDocumentAttributeData> attributesList = new ArrayList<OleKimDocumentAttributeData>();
1342        OleKimDocumentAttributeData attribData;
1343        for(String key: qualifiers.keySet()){
1344            KimTypeAttribute attribInfo = kimTypeInfo.getAttributeDefinitionByName(key);
1345            attribData = new OleKimDocumentAttributeData();
1346            attribData.setKimAttribute(attribInfo.getKimAttribute());
1347            attribData.setKimTypId(kimTypeInfo.getId());
1348            attribData.setKimAttrDefnId(attribInfo.getId());
1349            //attribData.setAttrDataId(attrDataId) - Not Available
1350            attribData.setAttrVal(qualifiers.get(key));
1351            attributesList.add(attribData);
1352        }
1353        return attributesList;
1354    }
1355    /**
1356     * Gets the roleRspActions attribute.
1357     * @return Returns the roleRspActions.
1358     */
1359    public List<RoleResponsibilityAction> getRoleRspActions() {
1360        if ( roleRspActions == null ) {
1361            roleRspActions = new ArrayList<RoleResponsibilityAction>(1);
1362        }
1363        return roleRspActions;
1364    }
1365    /**
1366     * Sets the roleRspActions attribute value.
1367     * @param roleRspActions The roleRspActions to set.
1368     */
1369    public void setRoleRspActions(List<RoleResponsibilityAction> roleRspActions) {
1370        this.roleRspActions = roleRspActions;
1371    }
1372
1373    public String getOrgReviewRoleInquiryTitle() {
1374        if ( INQUIRY_TITLE_VALUE == null ) {
1375            INQUIRY_TITLE_VALUE = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(ORR_INQUIRY_TITLE_PROPERTY);
1376        }
1377        return INQUIRY_TITLE_VALUE;
1378    }
1379
1380    @Override
1381    public void refreshNonUpdateableReferences() {
1382        // do nothing
1383    }
1384
1385    @Override
1386    public void refreshReferenceObject(String referenceObjectName) {
1387        // do nothing
1388    }
1389
1390    protected static OrgReviewRoleService getOrgReviewRoleService() {
1391        if ( orgReviewRoleService == null ) {
1392            orgReviewRoleService = SpringContext.getBean(OrgReviewRoleService.class);
1393        }
1394        return orgReviewRoleService;
1395    }
1396
1397    protected static ChartService getChartService() {
1398        if (chartService == null) {
1399            chartService = SpringContext.getBean(ChartService.class);
1400        }
1401        return chartService;
1402    }
1403
1404    protected static OrganizationService getOrganizationService() {
1405        if (organizationService == null) {
1406            organizationService = SpringContext.getBean(OrganizationService.class);
1407        }
1408        return organizationService;
1409    }
1410}