001/**
002 * Copyright 2005-2016 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.List;
020
021import org.kuali.rice.kew.api.identity.Id;
022import org.kuali.rice.kew.api.identity.PrincipalName;
023import org.kuali.rice.kew.api.rule.RoleName;
024
025/**
026 * A generic Role Attribute that can be used to route to a Network ID.  Can take as configuration the
027 * label to use for the element name in the XML.  This allows for re-use of this component in different
028 * contexts.
029 * 
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032public class NetworkIdRoleAttribute extends AbstractIdRoleAttribute {
033
034    private static final long serialVersionUID = 8784036641718163820L;
035    
036    private static final String NETWORK_ID_ROLE_NAME = "networkId";
037    private static final String ATTRIBUTE_ELEMENT = "NetworkIdRoleAttribute";
038    private static final String NETWORK_ID_ELEMENT = "networkId";
039        
040    public List<RoleName> getRoleNames() {
041        List<RoleName> roleNames = new ArrayList<RoleName>();
042        roleNames.add(new RoleName(getClass().getName(), NETWORK_ID_ROLE_NAME, "Network 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 PrincipalName(id);
052    }
053    
054    protected String getIdName() {
055        return NETWORK_ID_ELEMENT;
056    }
057
058    public String getNetworkId() {
059        return getIdValue();
060    }
061
062    public void setNetworkId(String networkId) {
063        setIdValue(networkId);
064    }
065
066}