| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.kew.rule; |
| 18 | |
|
| 19 | |
import java.util.LinkedHashMap; |
| 20 | |
|
| 21 | |
import javax.persistence.CascadeType; |
| 22 | |
import javax.persistence.Column; |
| 23 | |
import javax.persistence.Entity; |
| 24 | |
import javax.persistence.FetchType; |
| 25 | |
import javax.persistence.Id; |
| 26 | |
import javax.persistence.JoinColumn; |
| 27 | |
import javax.persistence.ManyToOne; |
| 28 | |
import javax.persistence.OneToOne; |
| 29 | |
import javax.persistence.Table; |
| 30 | |
import javax.persistence.Transient; |
| 31 | |
|
| 32 | |
import org.kuali.rice.core.jpa.annotations.Sequence; |
| 33 | |
import org.kuali.rice.kew.bo.KewPersistableBusinessObjectBase; |
| 34 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
| 35 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 36 | |
import org.kuali.rice.kew.util.KEWConstants; |
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
@Entity |
| 47 | |
@Table(name="KREW_DLGN_RSP_T") |
| 48 | |
@Sequence(name="KREW_RTE_TMPL_S", property="ruleDelegationId") |
| 49 | |
public class RuleDelegation extends KewPersistableBusinessObjectBase { |
| 50 | |
|
| 51 | |
private static final long serialVersionUID = 7989203310473741293L; |
| 52 | |
@Id |
| 53 | |
@Column(name="DLGN_RULE_ID") |
| 54 | |
private Long ruleDelegationId; |
| 55 | |
@Column(name="RSP_ID", insertable=false, updatable=false) |
| 56 | |
private Long responsibilityId; |
| 57 | |
@Column(name="DLGN_RULE_BASE_VAL_ID", insertable=false, updatable=false) |
| 58 | |
private Long delegateRuleId; |
| 59 | 0 | @Column(name="DLGN_TYP") |
| 60 | |
private String delegationType = KEWConstants.DELEGATION_PRIMARY; |
| 61 | |
|
| 62 | |
@OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST}) |
| 63 | |
@JoinColumn(name="DLGN_RULE_BASE_VAL_ID") |
| 64 | |
private RuleBaseValues delegationRuleBaseValues; |
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | 0 | public RuleDelegation() { |
| 70 | 0 | } |
| 71 | |
|
| 72 | |
public Object copy(boolean preserveKeys) { |
| 73 | 0 | RuleDelegation clone = new RuleDelegation(); |
| 74 | 0 | if (ruleDelegationId != null && preserveKeys) { |
| 75 | 0 | clone.setRuleDelegationId(new Long(ruleDelegationId.longValue())); |
| 76 | |
} |
| 77 | 0 | clone.setDelegationRuleBaseValues(delegationRuleBaseValues); |
| 78 | 0 | clone.setDelegateRuleId(delegationRuleBaseValues.getRuleBaseValuesId()); |
| 79 | 0 | if (delegationType != null) { |
| 80 | 0 | clone.setDelegationType(new String(delegationType)); |
| 81 | |
} |
| 82 | 0 | return clone; |
| 83 | |
} |
| 84 | |
|
| 85 | |
public Long getDelegateRuleId() { |
| 86 | 0 | return delegateRuleId; |
| 87 | |
} |
| 88 | |
public void setDelegateRuleId(Long delegateRuleId) { |
| 89 | 0 | this.delegateRuleId = delegateRuleId; |
| 90 | 0 | } |
| 91 | |
public RuleBaseValues getDelegationRuleBaseValues() { |
| 92 | 0 | return delegationRuleBaseValues; |
| 93 | |
} |
| 94 | |
public void setDelegationRuleBaseValues(RuleBaseValues delegationRuleBaseValues) { |
| 95 | 0 | this.delegationRuleBaseValues = delegationRuleBaseValues; |
| 96 | 0 | } |
| 97 | |
public String getDelegationType() { |
| 98 | 0 | return delegationType; |
| 99 | |
} |
| 100 | |
public void setDelegationType(String delegationType) { |
| 101 | 0 | this.delegationType = delegationType; |
| 102 | 0 | } |
| 103 | |
public Long getRuleDelegationId() { |
| 104 | 0 | return ruleDelegationId; |
| 105 | |
} |
| 106 | |
public void setRuleDelegationId(Long ruleDelegationId) { |
| 107 | 0 | this.ruleDelegationId = ruleDelegationId; |
| 108 | 0 | } |
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
public RuleResponsibility getRuleResponsibility() { |
| 115 | 0 | if ( getResponsibilityId() == null ) { |
| 116 | 0 | return null; |
| 117 | |
} |
| 118 | 0 | return KEWServiceLocator.getRuleService().findRuleResponsibility(getResponsibilityId()); |
| 119 | |
} |
| 120 | |
|
| 121 | |
public DocumentType getDocumentType() { |
| 122 | 0 | return this.getDelegationRuleBaseValues().getDocumentType(); |
| 123 | |
} |
| 124 | |
|
| 125 | |
public Long getResponsibilityId() { |
| 126 | 0 | return responsibilityId; |
| 127 | |
} |
| 128 | |
public void setResponsibilityId(Long ruleResponsibilityId) { |
| 129 | 0 | this.responsibilityId = ruleResponsibilityId; |
| 130 | 0 | } |
| 131 | |
|
| 132 | |
@Override |
| 133 | |
protected LinkedHashMap toStringMapper() { |
| 134 | 0 | LinkedHashMap map = new LinkedHashMap(); |
| 135 | 0 | map.put("ruleDelegationId", ruleDelegationId); |
| 136 | 0 | map.put("responsibilityId", responsibilityId); |
| 137 | 0 | map.put("delegateRuleId", delegateRuleId); |
| 138 | 0 | map.put("delegationType", delegationType); |
| 139 | 0 | return map; |
| 140 | |
} |
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
|
| 150 | |
|
| 151 | |
|
| 152 | |
@Override |
| 153 | |
public void refresh() { |
| 154 | 0 | RuleBaseValues oldRuleBaseValues = this.getDelegationRuleBaseValues(); |
| 155 | 0 | super.refresh(); |
| 156 | 0 | if (this.getDelegationRuleBaseValues() == null) { |
| 157 | 0 | this.refreshReferenceObject("delegationRuleBaseValues"); |
| 158 | 0 | if (this.getDelegationRuleBaseValues() == null) { |
| 159 | 0 | this.setDelegationRuleBaseValues(oldRuleBaseValues); |
| 160 | |
} |
| 161 | |
} |
| 162 | 0 | } |
| 163 | |
} |
| 164 | |
|