001 /*
002 * Copyright 2007-2009 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
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.identity.Id;
022 import org.kuali.rice.kew.identity.PrincipalId;
023
024 /**
025 * A generic Role Attribute that can be used to route to a Principal ID. Can
026 * take as configuration the label to use for the element name in the XML. This
027 * allows for re-use of this component in different contexts.
028 *
029 * @author Kuali Rice Team (rice.collab@kuali.org)
030 */
031 public class PrincipalIdRoleAttribute extends AbstractIdRoleAttribute {
032
033 private static final long serialVersionUID = 8784036641718163820L;
034
035 private static final String PRINCIPAL_ID_ROLE_NAME = "principalId";
036 private static final String ATTRIBUTE_ELEMENT = "PrincipalIdRoleAttribute";
037 private static final String PRINCIPAL_ID_ELEMENT = "principalId";
038
039 public List<Role> getRoleNames() {
040 List<Role> roleNames = new ArrayList<Role>();
041 roleNames.add(new Role(getClass(), PRINCIPAL_ID_ROLE_NAME, "Principal ID"));
042 return roleNames;
043 }
044
045 protected String getAttributeElementName() {
046 return ATTRIBUTE_ELEMENT;
047 }
048
049 protected Id resolveId(String id) {
050 return id == null ? null : new PrincipalId(id);
051 }
052
053 protected String getIdName() {
054 return PRINCIPAL_ID_ELEMENT;
055 }
056
057 public String getPrincipalId() {
058 return getIdValue();
059 }
060
061 public void setPrincipalId(String principalId) {
062 setIdValue(principalId);
063 }
064
065 }