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