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.krad.bo;
017
018import org.apache.commons.lang.StringUtils;
019import org.kuali.rice.kew.api.KewApiConstants;
020import org.kuali.rice.kew.api.util.CodeTranslator;
021
022import javax.persistence.Column;
023import javax.persistence.Id;
024import javax.persistence.MappedSuperclass;
025import javax.persistence.Transient;
026import java.util.Map;
027
028
029/**
030 * TODO we should not be referencing kew constants from this class and wedding ourselves to that workflow application Ad Hoc Route
031 * Recipient Business Object
032 *
033 * @author Kuali Rice Team (rice.collab@kuali.org)
034 */
035@MappedSuperclass
036public class AdHocRouteRecipient extends PersistableBusinessObjectBase {
037    private static final long serialVersionUID = -6499610180752232494L;
038
039    private static Map actionRequestCds;
040    public static final Integer PERSON_TYPE = new Integer(0);
041    public static final Integer WORKGROUP_TYPE = new Integer(1);
042
043    @Id
044        @Column(name="RECIP_TYP_CD")
045        protected Integer type;
046
047    @Id
048        @Column(name="ACTN_RQST_CD")
049        protected String actionRequested;
050
051    @Id
052        @Column(name="ACTN_RQST_RECIP_ID")
053        protected String id; // can be networkId or group id
054
055    @Transient
056    protected String name;
057
058    @Column(name="DOC_HDR_ID")
059        protected String documentNumber;
060
061    public AdHocRouteRecipient() {
062        // set some defaults that can be overridden
063        this.actionRequested = KewApiConstants.ACTION_REQUEST_APPROVE_REQ;
064        this.versionNumber = new Long(1);
065    }
066
067    public String getActionRequested() {
068        return actionRequested;
069    }
070
071    public void setActionRequested(String actionRequested) {
072        this.actionRequested = actionRequested;
073    }
074
075    public String getId() {
076        return id;
077    }
078
079    public void setId(String id) {
080        this.id = id;
081    }
082
083    public String getName() {
084        return name;
085    }
086
087    public void setName(String name) {
088        this.name = name;
089    }
090
091    public Integer getType() {
092        return type;
093    }
094
095    public void setType(Integer type) {
096        this.type = type;
097    }
098
099    public void setdocumentNumber (String documentNumber){
100        this.documentNumber = documentNumber;
101    }
102
103    public String getdocumentNumber (){
104        return documentNumber;
105    }
106
107    public String getActionRequestedValue() {
108        String actionRequestedValue = null;
109        if (StringUtils.isNotBlank(getActionRequested())) {
110            actionRequestCds.clear();
111            actionRequestCds.putAll(CodeTranslator.arLabels);
112            actionRequestedValue = (String) actionRequestCds.get(getActionRequested());
113        }
114
115        return actionRequestedValue;
116    }
117}