| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kew.rule.bo; |
| 17 | |
|
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.HashMap; |
| 20 | |
import java.util.List; |
| 21 | |
import java.util.Map; |
| 22 | |
|
| 23 | |
import javax.persistence.Basic; |
| 24 | |
import javax.persistence.CascadeType; |
| 25 | |
import javax.persistence.Column; |
| 26 | |
import javax.persistence.Entity; |
| 27 | |
import javax.persistence.FetchType; |
| 28 | |
import javax.persistence.GeneratedValue; |
| 29 | |
import javax.persistence.Id; |
| 30 | |
import javax.persistence.Lob; |
| 31 | |
import javax.persistence.NamedQueries; |
| 32 | |
import javax.persistence.NamedQuery; |
| 33 | |
import javax.persistence.OneToMany; |
| 34 | |
import javax.persistence.Table; |
| 35 | |
import javax.persistence.Transient; |
| 36 | |
|
| 37 | |
import org.apache.commons.lang.StringUtils; |
| 38 | |
import org.hibernate.annotations.Fetch; |
| 39 | |
import org.hibernate.annotations.FetchMode; |
| 40 | |
import org.hibernate.annotations.GenericGenerator; |
| 41 | |
import org.hibernate.annotations.Parameter; |
| 42 | |
import org.kuali.rice.kew.api.KewApiConstants; |
| 43 | |
import org.kuali.rice.kew.api.extension.ExtensionDefinition; |
| 44 | |
import org.kuali.rice.kew.api.extension.ExtensionDefinitionContract; |
| 45 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; |
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
@Entity |
| 55 | |
@Table(name="KREW_RULE_ATTR_T") |
| 56 | |
|
| 57 | |
@NamedQueries({ |
| 58 | |
@NamedQuery(name="RuleAttribute.FindById", query="select ra from RuleAttribute ra where ra.ruleAttributeId = :ruleAttributeId"), |
| 59 | |
@NamedQuery(name="RuleAttribute.FindByName", query="select ra from RuleAttribute ra where ra.name = :name"), |
| 60 | |
@NamedQuery(name="RuleAttribute.FindByClassName", query="select ra from RuleAttribute ra where ra.className = :className"), |
| 61 | |
@NamedQuery(name="RuleAttribute.GetAllRuleAttributes", query="select ra from RuleAttribute ra") |
| 62 | |
}) |
| 63 | |
public class RuleAttribute extends PersistableBusinessObjectBase implements ExtensionDefinitionContract { |
| 64 | |
|
| 65 | |
private static final long serialVersionUID = 1027673603158346349L; |
| 66 | |
|
| 67 | |
@Id |
| 68 | |
@GeneratedValue(generator="KREW_RTE_TMPL_S") |
| 69 | |
@GenericGenerator(name="KREW_RTE_TMPL_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={ |
| 70 | |
@Parameter(name="sequence_name",value="KREW_RTE_TMPL_S"), |
| 71 | |
@Parameter(name="value_column",value="id") |
| 72 | |
}) |
| 73 | |
@Column(name="RULE_ATTR_ID") |
| 74 | |
private String id; |
| 75 | |
@Column(name="NM") |
| 76 | |
private String name; |
| 77 | |
@Column(name="LBL") |
| 78 | |
private String label; |
| 79 | |
@Column(name="RULE_ATTR_TYP_CD") |
| 80 | |
private String type; |
| 81 | |
@Column(name="CLS_NM") |
| 82 | |
private String resourceDescriptor; |
| 83 | |
@Column(name="DESC_TXT") |
| 84 | |
private String description; |
| 85 | |
@Lob |
| 86 | |
@Basic(fetch=FetchType.LAZY) |
| 87 | |
@Column(name="XML") |
| 88 | |
private String xmlConfigData; |
| 89 | |
|
| 90 | |
@Column(name="APPL_ID") |
| 91 | |
private String applicationId; |
| 92 | |
|
| 93 | |
@OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE}, |
| 94 | |
targetEntity=RuleTemplateAttributeBo.class, mappedBy="ruleAttribute") |
| 95 | |
@Fetch(value=FetchMode.SELECT) |
| 96 | |
private List ruleTemplateAttributes; |
| 97 | |
@Transient |
| 98 | |
private List validValues; |
| 99 | |
|
| 100 | |
|
| 101 | |
@Transient |
| 102 | |
private String returnUrl; |
| 103 | |
|
| 104 | 0 | public RuleAttribute() { |
| 105 | 0 | ruleTemplateAttributes = new ArrayList(); |
| 106 | 0 | validValues = new ArrayList(); |
| 107 | 0 | } |
| 108 | |
|
| 109 | |
public List getValidValues() { |
| 110 | 0 | return validValues; |
| 111 | |
} |
| 112 | |
public void setValidValues(List ruleAttributeValidValues) { |
| 113 | 0 | this.validValues = ruleAttributeValidValues; |
| 114 | 0 | } |
| 115 | |
public List getRuleTemplateAttributes() { |
| 116 | 0 | return ruleTemplateAttributes; |
| 117 | |
} |
| 118 | |
public void setRuleTemplateAttributes(List ruleTemplateAttributes) { |
| 119 | 0 | this.ruleTemplateAttributes = ruleTemplateAttributes; |
| 120 | 0 | } |
| 121 | |
public String getDescription() { |
| 122 | 0 | return description; |
| 123 | |
} |
| 124 | |
public void setDescription(String description) { |
| 125 | 0 | this.description = description; |
| 126 | 0 | } |
| 127 | |
public String getLabel() { |
| 128 | 0 | return label; |
| 129 | |
} |
| 130 | |
public void setLabel(String label) { |
| 131 | 0 | this.label = label; |
| 132 | 0 | } |
| 133 | |
|
| 134 | |
public String getName() { |
| 135 | 0 | return name; |
| 136 | |
} |
| 137 | |
public void setName(String name) { |
| 138 | 0 | this.name = name; |
| 139 | 0 | } |
| 140 | |
public String getId() { |
| 141 | 0 | return id; |
| 142 | |
} |
| 143 | |
public void setId(String id) { |
| 144 | 0 | this.id = id; |
| 145 | 0 | } |
| 146 | |
public String getType() { |
| 147 | 0 | return type; |
| 148 | |
} |
| 149 | |
public void setType(String type) { |
| 150 | 0 | this.type = type; |
| 151 | 0 | } |
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
public String getResourceDescriptor() { |
| 157 | 0 | return resourceDescriptor; |
| 158 | |
} |
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
public void setResourceDescriptor(String resourceDescriptor) { |
| 163 | 0 | this.resourceDescriptor = resourceDescriptor; |
| 164 | 0 | } |
| 165 | |
|
| 166 | |
public String getRuleAttributeActionsUrl() { |
| 167 | 0 | return "<a href=\"RuleAttributeReport.do?id="+ id +"\" >report</a>"; |
| 168 | |
} |
| 169 | |
|
| 170 | |
public String getReturnUrl() { |
| 171 | 0 | return returnUrl; |
| 172 | |
} |
| 173 | |
public void setReturnUrl(String returnUrl) { |
| 174 | 0 | this.returnUrl = returnUrl; |
| 175 | 0 | } |
| 176 | |
|
| 177 | |
public String getXmlConfigData() { |
| 178 | 0 | return xmlConfigData; |
| 179 | |
} |
| 180 | |
|
| 181 | |
@Override |
| 182 | |
public Map<String, String> getConfiguration() { |
| 183 | 0 | Map<String, String> config = new HashMap<String, String>(); |
| 184 | 0 | if (StringUtils.isNotBlank(getXmlConfigData())) { |
| 185 | 0 | config.put(KewApiConstants.ATTRIBUTE_XML_CONFIG_DATA, getXmlConfigData()); |
| 186 | |
} |
| 187 | 0 | return config; |
| 188 | |
} |
| 189 | |
|
| 190 | |
public void setXmlConfigData(String xmlConfigData) { |
| 191 | 0 | this.xmlConfigData = xmlConfigData; |
| 192 | 0 | } |
| 193 | |
|
| 194 | |
@Override |
| 195 | |
public String getApplicationId() { |
| 196 | 0 | return applicationId; |
| 197 | |
} |
| 198 | |
|
| 199 | |
public void setApplicationId(String applicationId) { |
| 200 | 0 | this.applicationId = applicationId; |
| 201 | 0 | } |
| 202 | |
|
| 203 | |
public static ExtensionDefinition to(RuleAttribute ruleAttribute) { |
| 204 | 0 | if (ruleAttribute == null) { |
| 205 | 0 | return null; |
| 206 | |
} |
| 207 | 0 | return ExtensionDefinition.Builder.create(ruleAttribute).build(); |
| 208 | |
} |
| 209 | |
|
| 210 | |
public static RuleAttribute from(ExtensionDefinition im) { |
| 211 | 0 | if (im == null) { |
| 212 | 0 | return null; |
| 213 | |
} |
| 214 | 0 | RuleAttribute bo = new RuleAttribute(); |
| 215 | 0 | bo.setApplicationId(im.getApplicationId()); |
| 216 | 0 | bo.setDescription(im.getDescription()); |
| 217 | 0 | bo.setResourceDescriptor(im.getResourceDescriptor()); |
| 218 | 0 | bo.setId(im.getId()); |
| 219 | 0 | bo.setLabel(im.getLabel()); |
| 220 | 0 | bo.setType(im.getType()); |
| 221 | 0 | bo.setVersionNumber(im.getVersionNumber()); |
| 222 | 0 | bo.setXmlConfigData(im.getConfiguration().get(KewApiConstants.ATTRIBUTE_XML_CONFIG_DATA)); |
| 223 | |
|
| 224 | 0 | return bo; |
| 225 | |
} |
| 226 | |
} |