001/** 002 * Copyright 2005-2014 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.rice.kew.rule; 017 018import java.util.ArrayList; 019import java.util.Collections; 020import java.util.List; 021 022import org.kuali.rice.kew.api.identity.PrincipalId; 023import org.kuali.rice.kew.api.rule.RoleName; 024import org.kuali.rice.kew.engine.RouteContext; 025 026/** 027 * RoleAttribute that exposes a document's user who routed the document 028 * 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 */ 031public class RoutedByUserRoleAttribute extends UnqualifiedRoleAttribute { 032 private static final long serialVersionUID = -7099014184598851664L; 033 private static final String ROUTED_BY_USER_ROLE_KEY = "ROUTED_BY_USER"; 034 private static final String ROUTED_BY_USER_ROLE_LABEL = "Routed By User"; 035 036 private static final RoleName ROLE = new RoleName(RoutedByUserRoleAttribute.class.getName(), ROUTED_BY_USER_ROLE_KEY, ROUTED_BY_USER_ROLE_LABEL); 037 private static final List<RoleName> ROLES; 038 static { 039 ArrayList<RoleName> roles = new ArrayList<RoleName>(1); 040 roles.add(ROLE); 041 ROLES = Collections.unmodifiableList(roles); 042 } 043 044 public RoutedByUserRoleAttribute() { 045 super(ROLES); 046 } 047 048 public ResolvedQualifiedRole resolveRole(RouteContext routeContext, String roleName) { 049 // sounds like the role label should be specified as the first parameter here, 050 // but I'll follow AccountAttribute's lead and specify the role key 051 List members = new ArrayList(1); 052 //members.add(routeContext.getDocument().getRoutedByPrincipal().getPrincipalId()); 053 members.add(new PrincipalId(routeContext.getDocument().getRoutedByUserWorkflowId())); 054 return new ResolvedQualifiedRole(ROUTED_BY_USER_ROLE_LABEL, members); 055 } 056}