001 /**
002 * Copyright 2005-2012 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 */
016 package org.kuali.rice.kew.rule;
017
018 import java.util.ArrayList;
019 import java.util.List;
020
021 import org.kuali.rice.kew.api.identity.Id;
022 import org.kuali.rice.kew.api.identity.PrincipalId;
023 import org.kuali.rice.kew.api.rule.RoleName;
024
025 /**
026 * A generic Role Attribute that can be used to route to a Principal ID. Can
027 * take as configuration the label to use for the element name in the XML. This
028 * allows for re-use of this component in different contexts.
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032 public class PrincipalIdRoleAttribute extends AbstractIdRoleAttribute {
033
034 private static final long serialVersionUID = 8784036641718163820L;
035
036 private static final String PRINCIPAL_ID_ROLE_NAME = "principalId";
037 private static final String ATTRIBUTE_ELEMENT = "PrincipalIdRoleAttribute";
038 private static final String PRINCIPAL_ID_ELEMENT = "principalId";
039
040 public List<RoleName> getRoleNames() {
041 List<RoleName> roleNames = new ArrayList<RoleName>();
042 roleNames.add(new RoleName(getClass().getName(), PRINCIPAL_ID_ROLE_NAME, "Principal ID"));
043 return roleNames;
044 }
045
046 protected String getAttributeElementName() {
047 return ATTRIBUTE_ELEMENT;
048 }
049
050 protected Id resolveId(String id) {
051 return id == null ? null : new PrincipalId(id);
052 }
053
054 protected String getIdName() {
055 return PRINCIPAL_ID_ELEMENT;
056 }
057
058 public String getPrincipalId() {
059 return getIdValue();
060 }
061
062 public void setPrincipalId(String principalId) {
063 setIdValue(principalId);
064 }
065
066 }