Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kew.actionrequest;
 
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;


A factory to aid in creating the ever-so-gnarly ActionRequestValue object.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 public class ActionRequestFactory {
 
 	private static final Logger LOG = Logger.getLogger(ActionRequestFactory.class);
 
 	private static RoleService roleService;
 	private static IdentityService identityService;
     private static GroupService groupService;
 	
 
 	public ActionRequestFactory() {
 	}
 
 		this. = document;
 	}
 
 		this. = document;
 		this. = routeNode;
 	}
    public ActionRequestFactory(RouteContext routeContext) {
        this(routeContext.getDocument(), routeContext.getNodeInstance());
    }

Constructs ActionRequestValue using default priority and 0 as responsibility

Parameters:
actionRequested
recipient
description
forceAction
annotation
Returns:
ActionRequestValue
	public ActionRequestValue createActionRequest(String actionRequestedRecipient recipientString descriptionBoolean forceActionString annotation) {
		return createActionRequest(actionRequestednew Integer(0), recipientdescription.forceActionannotation);
	}
	public ActionRequestValue createActionRequest(String actionRequestedInteger priorityRecipient recipientString descriptionString responsibilityIdBoolean forceActionString annotation) {
    	return createActionRequest(actionRequestedpriorityrecipientdescriptionresponsibilityIdforceActionnullnullannotation);
    }
	public ActionRequestValue createActionRequest(String actionRequestedInteger priorityRecipient recipientString descriptionString responsibilityIdBoolean forceActionString approvePolicyString ruleIdString annotation) {
		return createActionRequest(actionRequestedpriorityrecipientdescriptionresponsibilityIdforceActionapprovePolicyruleIdannotationnull);
	}
	public ActionRequestValue createActionRequest(String actionRequestedInteger priorityRecipient recipientString descriptionString responsibilityIdBoolean forceActionString approvePolicyString ruleIdString annotationString requestLabel) {
		ActionRequestValue actionRequest = new ActionRequestValue();
        actionRequest.setActionRequested(actionRequested);
        actionRequest.setDocVersion(.getDocVersion());
        actionRequest.setPriority(priority);
        actionRequest.setRouteHeader();
        actionRequest.setDocumentId(.getDocumentId());
        actionRequest.setRouteLevel(.getDocRouteLevel());
    	actionRequest.setNodeInstance();
    	actionRequest.setResponsibilityId(responsibilityId);
    	actionRequest.setResponsibilityDesc(description);
    	actionRequest.setApprovePolicy(approvePolicy);
    	actionRequest.setForceAction(forceAction);
    	actionRequest.setRuleBaseValuesId(ruleId);
    	actionRequest.setAnnotation(annotation);
    	actionRequest.setRequestLabel(requestLabel);
    	setDefaultProperties(actionRequest);
    	resolveRecipient(actionRequestrecipient);
        return actionRequest;
	}
		if ( != null) {
		}
		return request;
	}
    public ActionRequestValue createNotificationRequest(String actionRequestCodePrincipalContract principalString reasonActionCodePrincipalContract reasonActionUserString responsibilityDesc) {
    	ActionRequestValue request = createActionRequest(actionRequestCodenew KimPrincipalRecipient(principal), responsibilityDesc.null);
    	String annotation = generateNotificationAnnotation(reasonActionUseractionRequestCodereasonActionCoderequest);
    	request.setAnnotation(annotation);
    	return request;
    }
    //unify these 2 methods if possible
    public List<ActionRequestValuegenerateNotifications(List requestsPrincipalContract principalRecipient delegator,
            String notificationRequestCodeString actionTakenCode)
    {
        String groupName =  CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(.,
                ..,
        
        
        Group notifyExclusionWorkgroup = null;
        if(!StringUtils.isBlank(groupName)){
        	notifyExclusionWorkgroup = getGroupService().getGroupByNamespaceCodeAndName(
                    Utilities.parseGroupNamespaceCode(groupName), Utilities.parseGroupName(groupName));
        }
        
 
        
        return generateNotifications(nullgetActionRequestService().getRootRequests(requests), principaldelegatornotificationRequestCodeactionTakenCodenotifyExclusionWorkgroup);
    }

    
Generates a notification request for each action request specified, filtering out the specified principal and delegator, and exclusion workgroup members from notification list

Parameters:
parentRequest if non-null, attaches generated notification requests to this parent action request
requests list of ActionRequestValues for which to generate corresponding notification requests
principal principal to exclude from notifications
delegator delegator to exclude from notifications
notificationRequestCode the actionrequest code of generated notifications
actionTakenCode the actiontaken code to display as the cause of the notification generation
notifyExclusionWorkgroup workgroup whose members should not be sent notifications
Returns:
a list of generated notification requests
            List requestsPrincipalContract principalRecipient delegatorString notificationRequestCode,
            String actionTakenCodeGroup notifyExclusionWorkgroup)
    {
        List<ActionRequestValuenotificationRequests = new ArrayList<ActionRequestValue>();
        for (Iterator iter = requests.iterator(); iter.hasNext();) 
        {
            ActionRequestValue actionRequest = (ActionRequestValueiter.next();
            if (!(actionRequest.isRecipientRoutedRequest(principal.getPrincipalId()) || actionRequest.isRecipientRoutedRequest(delegator)))
            {
                // skip user requests to system users
                if ((notifyExclusionWorkgroup != null) &&
                        (isRecipientInGroup(notifyExclusionWorkgroupactionRequest.getRecipient())))
                {
                    continue;
                }
                ActionRequestValue notificationRequest = createNotificationRequest(actionRequestprincipalnotificationRequestCodeactionTakenCode);
                notificationRequests.add(notificationRequest);
                if (parentRequest != null)
                {
                    notificationRequest.setParentActionRequest(parentRequest);
                    parentRequest.getChildrenRequests().add(notificationRequest);
                }
                notificationRequests.addAll(generateNotifications(notificationRequestactionRequest.getChildrenRequests(), principaldelegatornotificationRequestCodeactionTakenCodenotifyExclusionWorkgroup));
            }
        }
        return notificationRequests;
    }
    private boolean isRecipientInGroup(Group groupRecipient recipient)
    {
        boolean isMember = false;
        if(recipient instanceof KimPrincipalRecipient)
        {
            String principalId = ((KimPrincipalRecipientrecipient).getPrincipalId();
            String groupId = group.getId();
            isMember = getGroupService().isMemberOfGroup(principalIdgroupId);
        }
        else if (recipient instanceof KimGroupRecipient)
        {
            String kimRecipientId = ((KimGroupRecipientrecipient).getGroup().getId();
            isMember = getGroupService().isGroupMemberOfGroup(kimRecipientIdgroup.getId() );
        }
        return isMember;
    }
    private ActionRequestValue createNotificationRequest(ActionRequestValue actionRequestPrincipalContract reasonPrincipalString notificationRequestCodeString actionTakenCode) {
    	String annotation = generateNotificationAnnotation(reasonPrincipalnotificationRequestCodeactionTakenCodeactionRequest);
        ActionRequestValue request = createActionRequest(notificationRequestCodeactionRequest.getPriority(), actionRequest.getRecipient(), actionRequest.getResponsibilityDesc(), ..annotation);
        request.setDocVersion(actionRequest.getDocVersion());
        request.setApprovePolicy(actionRequest.getApprovePolicy());
        request.setRoleName(actionRequest.getRoleName());
        request.setQualifiedRoleName(actionRequest.getQualifiedRoleName());
        request.setQualifiedRoleNameLabel(actionRequest.getQualifiedRoleNameLabel());
        request.setDelegationType(actionRequest.getDelegationType());
        return request;
    }
    private void setDefaultProperties(ActionRequestValue actionRequest) {
    	if (actionRequest.getApprovePolicy() == null) {
    	}
        actionRequest.setCreateDate(new Timestamp(System.currentTimeMillis()));
        actionRequest.setCurrentIndicator(.);
        if (actionRequest.getForceAction() == null) {
        	actionRequest.setForceAction(.);
        }
        if ( != null) {
        	actionRequest.setNodeInstance();
        }
        actionRequest.setJrfVerNbr(new Integer(0));
        actionRequest.setStatus(..getCode());
        actionRequest.setRouteHeader();
        actionRequest.setDocumentId(.getDocumentId());
    }
    private static void resolveRecipient(ActionRequestValue actionRequestRecipient recipient) {
    	if (recipient instanceof KimPrincipalRecipient) {
    		actionRequest.setPrincipalId(((KimPrincipalRecipient)recipient).getPrincipal().getPrincipalId());
    	}  else if (recipient instanceof KimGroupRecipient) {
    		KimGroupRecipient kimGroupRecipient = (KimGroupRecipient)recipient;
    		actionRequest.setGroupId(kimGroupRecipient.getGroup().getId());
    	} else if (recipient instanceof RoleRecipient){
    		RoleRecipient role = (RoleRecipient)recipient;
    		actionRequest.setRecipientTypeCd(..getCode());
    		actionRequest.setRoleName(role.getRoleName());
    		actionRequest.setQualifiedRoleName(role.getQualifiedRoleName());
    		ResolvedQualifiedRole qualifiedRole = role.getResolvedQualifiedRole();
    		if (qualifiedRole != null) {
    			actionRequest.setAnnotation(qualifiedRole.getAnnotation() == null ? "" : qualifiedRole.getAnnotation());
    			actionRequest.setQualifiedRoleNameLabel(qualifiedRole.getQualifiedRoleLabel());
    		}
    		Recipient targetRecipient = role.getTarget();
    		if (role.getTarget() != null) {
    			if (targetRecipient instanceof RoleRecipient) {
    				throw new WorkflowRuntimeException("Role Cannot Target a role problem activating request for document " + actionRequest.getDocumentId());
    			}
    			resolveRecipient(actionRequestrole.getTarget());
    		}
    	} else if (recipient instanceof KimRoleResponsibilityRecipient) {
    		KimRoleResponsibilityRecipient roleResponsibilityRecipient = (KimRoleResponsibilityRecipient)recipient;
    		actionRequest.setRecipientTypeCd(..getCode());
    		actionRequest.setRoleName(roleResponsibilityRecipient.getResponsibilities().get(0).getRoleId());
    		actionRequest.setQualifiedRoleName(
                    roleResponsibilityRecipient.getResponsibilities().get(0).getResponsibilityName());
    		// what about qualified role name label?
//    		actionRequest.setAnnotation(roleRecipient.getResponsibilities().get(0).getResponsibilityName());
    		Recipient targetRecipient = roleResponsibilityRecipient.getTarget();
    		if (targetRecipient != null) {
    			if (targetRecipient instanceof RoleRecipient) {
    				throw new WorkflowRuntimeException("Role Cannot Target a role problem activating request for document " + actionRequest.getDocumentId());
    			}
    			resolveRecipient(actionRequestroleResponsibilityRecipient.getTarget());
    		}
    	} else if (recipient instanceof KimRoleRecipient) {
            KimRoleRecipient roleRecipient = (KimRoleRecipient)recipient;
            actionRequest.setRecipientTypeCd(..getCode());
            Role role = roleRecipient.getRole();
            actionRequest.setRoleName(role.getId());
            actionRequest.setQualifiedRoleNameLabel(role.getName());
            Recipient targetRecipient = roleRecipient.getTarget();
    		if (targetRecipient != null) {
    			if (targetRecipient instanceof RoleRecipient) {
    				throw new WorkflowRuntimeException("Role Cannot Target a role problem activating request for document " + actionRequest.getDocumentId());
    			}
    			resolveRecipient(actionRequesttargetRecipient);
    		}
        }
    }

    
Creates a root Role Request

Parameters:
role
actionRequested
approvePolicy
priority
responsibilityId
forceAction
description
ruleId
Returns:
the created root role request
    public ActionRequestValue addRoleRequest(RoleRecipient roleString actionRequestedString approvePolicyInteger priorityString responsibilityIdBoolean forceActionString descriptionString ruleId) {
    	ActionRequestValue requestGraph = createActionRequest(actionRequestedpriorityroledescriptionresponsibilityIdforceActionapprovePolicyruleIdnull);
    	if (role != null && role.getResolvedQualifiedRole() != null && role.getResolvedQualifiedRole().getRecipients() != null) {
    	    int legitimateTargets = 0;
            for (Iterator<Iditer = role.getResolvedQualifiedRole().getRecipients().iterator(); iter.hasNext();) {
                Id recipientId = (Iditer.next();
                if (recipientId.isEmpty())
                {
                    throw new WorkflowRuntimeException("Failed to resolve id of type " + recipientId.getClass().getName() + " returned from role '" + role.getRoleName() + "'.  Id returned contained a null or empty value.");
                }
                if (recipientId instanceof UserId)
                {
                    Principal principal = getIdentityHelperService().getPrincipal((UserIdrecipientId);
                    if(ObjectUtils.isNotNull(principal)) {
                        role.setTarget(new KimPrincipalRecipient(principal));
                    }
                } else if (recipientId instanceof GroupId)
                {
                    role.setTarget(new KimGroupRecipient(getIdentityHelperService().getGroup((GroupIdrecipientId)));
                } else
                {
                    throw new WorkflowRuntimeException("Could not process the given type of id: " + recipientId.getClass());
                }
                if (role.getTarget() != null)
                {
                    legitimateTargets++;
                    ActionRequestValue request = createActionRequest(actionRequestedpriorityroledescriptionresponsibilityIdforceActionnullruleIdnull);
                    request.setParentActionRequest(requestGraph);
                    requestGraph.getChildrenRequests().add(request);
                }
            }
    	if (legitimateTargets == 0) {
            .warn("Role did not yield any legitimate recipients");
        }
    	} else {
    		.warn("Didn't create action requests for action request description '" + description + "' because of null role or null part of role object graph.");
    	}
    	.add(requestGraph);
    	return requestGraph;
    }

    
Generates an ActionRequest graph for the given KIM Responsibilities. This graph includes any associated delegations.

Parameters:
responsibilities
approvePolicy
    public void addRoleResponsibilityRequest(List<ResponsibilityActionresponsibilitiesString approvePolicy) {
    	if (responsibilities == null || responsibilities.isEmpty()) {
    		.warn("Didn't create action requests for action request description because no responsibilities were defined.");
    		return;
    	}
    	// it's assumed the that all in the list have the same action type code, priority number, etc.
    	String actionTypeCode = responsibilities.get(0).getActionTypeCode();
    	Integer priority = responsibilities.get(0).getPriorityNumber();
    	boolean forceAction = responsibilities.get(0).isForceAction();
    	KimRoleResponsibilityRecipient roleResponsibilityRecipient = new KimRoleResponsibilityRecipient(responsibilities);
    	// Creation of a parent graph entry for ????
    	ActionRequestValue requestGraph = null;
    	StringBuffer parentAnnotation = null;
    	// set to allow for suppression of duplicate annotations on the parent action request
    	Set<StringuniqueChildAnnotations = null;
    	if ( responsibilities.size() > 1 ) {
	    	requestGraph = createActionRequest(
	    	        actionTypeCode
	    	        priorityroleResponsibilityRecipient,
	    	        ""// description 
	    	        forceAction
	    	        approvePolicy
	    	        null// ruleId
	    	        null );// annotation
	    	.add(requestGraph);
	    	parentAnnotation = new StringBuffer();
	    	uniqueChildAnnotations = new HashSet<String>( responsibilities.size() );
    	}
    	StringBuffer annotation = new StringBuffer();
    	for (ResponsibilityAction responsibility : responsibilities) {
    		if ( .isDebugEnabled() ) {
    			.debug"Processing Responsibility for action request: " + responsibility );
    		}
        	// KFSMI-2381 - pull information from KIM to populate annotation
    		annotation.setLength( 0 );
    		Role role = getRoleService().getRole(responsibility.getRoleId());
    		annotation.appendrole.getNamespaceCode() ).append' ' ).appendrole.getName() ).append' ' );
    		Map<StringStringqualifier = responsibility.getQualifier();
    		if ( qualifier != null ) {
	    		for ( String key : qualifier.keySet() ) {
	        		annotation.appendqualifier.getkey ) ).append' ' );
	    		}
    		}
			if (responsibility.getPrincipalId() != null) {
				roleResponsibilityRecipient.setTarget(new KimPrincipalRecipient(responsibility.getPrincipalId()));
else if (responsibility.getGroupId() != null) {
				roleResponsibilityRecipient.setTarget(new KimGroupRecipient(responsibility.getGroupId()));
else {
				throw new RiceRuntimeException("Failed to identify a group or principal on the given ResponsibilityResolutionInfo:" + responsibility);
			}
			String annotationStr = annotation.toString();
			        responsibility.getActionTypeCode(), 
			        responsibility.getPriorityNumber(), roleResponsibilityRecipient,
			        responsibility.getParallelRoutingGroupingCode(), // description
			        responsibility.getResponsibilityId(), 
			        responsibility.isForceAction(), 
			        // If not nested in a parent action request, ensure that the request
			        // is first approve so delegations of this request do not require 
			        // ALL_APPROVE as well
			        (responsibilities.size() == 1)?..getCode():approvePolicy
			        null// ruleId
			        annotationStr);
			// if there is only a single request, don't create the nesting structure
			if ( responsibilities.size() > 1 ) {
				request.setParentActionRequest(requestGraph);
				requestGraph.getChildrenRequests().add(request);
				if ( !uniqueChildAnnotations.contains(annotationStr) ) {
					parentAnnotation.appendannotationStr ).append" -- " );
					uniqueChildAnnotations.add(annotationStr);
				}
else {
			}
            generateKimRoleDelegationRequests(responsibility.getDelegates(), request);
	    }
    	if ( responsibilities.size() > 1 ) {
	    	requestGraph.setAnnotation( StringUtils.chompparentAnnotation.toString(), " -- " ) );
    	}
    }
    private String generateRoleResponsibilityDelegateAnnotation(DelegateMember memberboolean isPrincipalboolean isGroupActionRequestValue parentRequest) {
    	StringBuffer annotation = new StringBuffer"Delegation of: " );
    	annotation.appendparentRequest.getAnnotation() );
    	annotation.append" to " );
    	if (isPrincipal) {
    		annotation.append"principal " );
    		Principal principal = getIdentityService().getPrincipal(member.getMemberId());
    		if ( principal != null ) {
    			annotation.appendprincipal.getPrincipalName() );
    		} else {
    			annotation.appendmember.getMemberId() );
    		}
    	} else if (isGroup) {
    		annotation.append"group " );
    		Group group = getGroupService().getGroupmember.getMemberId() );
    		if ( group != null ) {
    			annotation.appendgroup.getNamespaceCode() ).append'/' ).appendgroup.getName() );
    		} else {
    			annotation.appendmember.getMemberId() );
    		}
    	} else {
    		annotation.append"?????? '" );
			annotation.appendmember.getMemberId() );
    		annotation.append"'" );
    	}
    	return annotation.toString();
    }
    public ActionRequestValue addDelegationRoleRequest(ActionRequestValue parentRequestString approvePolicyRoleRecipient roleString responsibilityIdBoolean forceActionDelegationType delegationTypeString descriptionString ruleId) {
    	Recipient parentRecipient = parentRequest.getRecipient();
    	if (parentRecipient instanceof RoleRecipient) {
    		throw new WorkflowRuntimeException("Cannot delegate on Role Request.  It must be a request to a person or workgroup, although that request may be in a role");
    	}
    	if (! relatedToRoot(parentRequest)) {
    		throw new WorkflowRuntimeException("The parent request is not related to any request managed by this factory");
    	}
    	ActionRequestValue delegationRoleRequest = createActionRequest(parentRequest.getActionRequested(), parentRequest.getPriority(), roledescriptionresponsibilityIdforceActionapprovePolicyruleIdnull);
    	delegationRoleRequest.setDelegationType(delegationType);
    	int count = 0;
    	for (Iterator<Iditer = role.getResolvedQualifiedRole().getRecipients().iterator(); iter.hasNext(); count++) {
    		//repeat of createRoleRequest code
    		Id recipientId = iter.next();
    		if (recipientId.isEmpty()) {
				throw new WorkflowRuntimeException("Failed to resolve id of type " + recipientId.getClass().getName() + " returned from role '" + role.getRoleName() + "'.  Id returned contained a null or empty value.");
			}
			if (recipientId instanceof UserId) {
else if (recipientId instanceof GroupId) {
else {
				throw new WorkflowRuntimeException("Could not process the given type of id: " + recipientId.getClass());
			}
			ActionRequestValue request = createActionRequest(parentRequest.getActionRequested(), parentRequest.getPriority(), roledescriptionresponsibilityIdforceActionnullruleIdnull);
			request.setDelegationType(delegationType);
			//end repeat
			request.setParentActionRequest(delegationRoleRequest);
			delegationRoleRequest.getChildrenRequests().add(request);
    	}
    	//put this mini graph in the larger graph
    	if (count > 0) {
    		parentRequest.getChildrenRequests().add(delegationRoleRequest);
    		delegationRoleRequest.setParentActionRequest(parentRequest);
    	}
    	return delegationRoleRequest;
    }
    public ActionRequestValue addDelegationRequest(ActionRequestValue parentRequestRecipient recipientString responsibilityIdBoolean forceActionDelegationType delegationTypeString annotationString ruleId) {
    	if (! relatedToRoot(parentRequest)) {
    		throw new WorkflowRuntimeException("The parent request is not related to any request managed by this factory");
    	}
    	ActionRequestValue delegationRequest = createActionRequest(parentRequest.getActionRequested(), parentRequest.getPriority(), recipientparentRequest.getResponsibilityDesc(), responsibilityIdforceActionnullruleIdannotation);
    	delegationRequest.setDelegationType(delegationType);
    	
        parentRequest.getChildrenRequests().add(delegationRequest); 
        delegationRequest.setParentActionRequest(parentRequest);
    	return delegationRequest;
    }
    //could probably base behavior off of recipient type
    public ActionRequestValue addRootActionRequest(String actionRequestedInteger priorityRecipient recipientString descriptionString responsibilityIdBoolean forceActionString approvePolicyString ruleId) {
    	ActionRequestValue requestGraph = createActionRequest(actionRequestedpriorityrecipientdescriptionresponsibilityIdforceActionapprovePolicyruleIdnull);
    	.add(requestGraph);
    	return requestGraph;
    }

    
Generates an ActionRequest graph for the given KIM Responsibilities. This graph includes any associated delegations.
    public void addKimRoleRequest(String actionRequestedCodeInteger priorityRole role,
            List<RoleMembershipmembershipsString descriptionString responsibilityIdboolean forceAction,
            String actionRequestPolicyCodeString requestLabel) {
    	if (CollectionUtils.isEmpty(memberships)) {
    		.warn("Didn't create action requests for action request description because no role members were defined for role id " + role.getId());
    		return;
    	}
    	
        KimRoleRecipient roleRecipient = new KimRoleRecipient(role);
    	// Creation of a parent graph entry for ????
    	ActionRequestValue requestGraph = null;
    	if ( memberships.size() > 1 ) {
	    	requestGraph = createActionRequest(
	    	        actionRequestedCode,
	    	        priority,
                    roleRecipient,
	    	        ""// description
	    	        responsibilityId,
	    	        forceAction,
	    	        actionRequestPolicyCode,
	    	        null// ruleId
	    	        null );// annotation
	    	.add(requestGraph);
    	}
    	for (RoleMembership membership : memberships) {
    		if ( .isDebugEnabled() ) {
    			.debug"Processing RoleMembership for action request: " + membership );
    		}
			if (..equals(membership.getType())) {
				roleRecipient.setTarget(new KimPrincipalRecipient(membership.getMemberId()));
else if (..equals(membership.getType())) {
				roleRecipient.setTarget(new KimGroupRecipient(membership.getMemberId()));
else {
				throw new RiceRuntimeException("Failed to identify a group or principal on the given RoleMembership:" + membership);
			}
			        actionRequestedCode,
			        priority,
                    roleRecipient,
                    ""// description
			        responsibilityId,
			        forceAction,
			        // If not nested in a parent action request, ensure that the request
			        // is first approve so delegations of this request do not require
			        // ALL_APPROVE as well
			        (memberships.size() == 1) ? ..getCode() : actionRequestPolicyCode,
			        null// ruleId
			        null); // annotation
			// if there is only a single request, don't create the nesting structure
			if ( memberships.size() > 1 ) {
				request.setParentActionRequest(requestGraph);
				requestGraph.getChildrenRequests().add(request);
else {
			}
            generateKimRoleDelegationRequests(membership.getDelegates(), request);
	    }
    }
     private void generateKimRoleDelegationRequests(List<DelegateTypedelegatesActionRequestValue parentRequest) {
    	for (DelegateType delegate : delegates) {
            for (DelegateMember member : delegate.getMembers()) {
    		    Recipient recipient;
    		    boolean isPrincipal = ..equals(member.getType());
                boolean isGroup = ..equals(member.getType());
    		    if (isPrincipal) {
    			    recipient = new KimPrincipalRecipient(member.getMemberId());
    		    } else if (isGroup) {
    			    recipient = new KimGroupRecipient(member.getMemberId());
    		    } else {
    			    throw new RiceRuntimeException("Invalid DelegateInfo memberTypeCode encountered, was '" + member.getType() + "'");
    		    }
    		    String delegationAnnotation = generateRoleResponsibilityDelegateAnnotation(memberisPrincipalisGroupparentRequest);
    		    addDelegationRequest(parentRequestrecipientdelegate.getDelegationId(), parentRequest.getForceAction(), delegate.getDelegationType(), delegationAnnotationnull);
    	    }
        }
    }
    //return true if requestGraph (root) is in this requests' parents
    public boolean relatedToRoot(ActionRequestValue request) {
    	int i = 0;
    	while(i < 3) {
    		if (.contains(request)) {
    			return true;
    		} else if (request == null) {
    			return false;
    		}
    		i++;
    		request = request.getParentActionRequest();
    	}
    	return false;
    }
		//clean up all the trailing role requests with no children -
	}
        for (ActionRequestValue aChildren : children)
        {
            if (aChildren.isRoleRequest())
            {
                if (aChildren.getChildrenRequests().isEmpty())
                {
                    requestsToRemove.add(aChildren);
                } else
                {
                    Collection<ActionRequestValuechildRequestsToRemove = cleanUpChildren(aChildren.getChildrenRequests());
                    aChildren.getChildrenRequests().removeAll(childRequestsToRemove);
				}
			}                                                                                 
		}
		return requestsToRemove;
	}
    private String generateNotificationAnnotation(PrincipalContract principalString notificationRequestCodeString actionTakenCodeActionRequestValue request) {
    	String notification = "Action " + CodeTranslator.getActionRequestLabel(notificationRequestCode) + " generated by Workflow because " + principal.getPrincipalName() + " took action "
				+ CodeTranslator.getActionTakenLabel(actionTakenCode);
    	// FIXME: KULRICE-5201 switched rsp_id to a varchar, so the comparison below is no longer valid
//    	if (request.getResponsibilityId() != null && request.getResponsibilityId() != 0) {
    	// TODO: KULRICE-5329 Verify that this code below makes sense and is sufficient
    		notification += " Responsibility " + request.getResponsibilityId();
    	}
    	if (request.getRuleBaseValuesId() != null) {
    		notification += " Rule Id " + request.getRuleBaseValuesId();
    	}
    	if (request.getAnnotation() != null && request.getAnnotation().length()!=0){
    		notification += " " + request.getAnnotation();
    	}
    	return notification;
	}
    protected static ActionRequestService getActionRequestService() {
		if (  == null ) {
		}
    }

Returns:
the roleService
    protected static RoleService getRoleService() {
		if (  == null ) {
			 = KimApiServiceLocator.getRoleService();
		}
		return ;
	}

Returns:
the identityHelperService
    protected static IdentityHelperService getIdentityHelperService() {
		if (  == null ) {
		}
	}

Returns:
the identityService
    protected static IdentityService getIdentityService() {
		if (  == null ) {
			 = KimApiServiceLocator.getIdentityService();
		}
	}
    protected static GroupService getGroupService() {
		if (  == null ) {
			 = KimApiServiceLocator.getGroupService();
		}
		return ;
	}
New to GrepCode? Check out our FAQ X