1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.xml; |
18 | |
|
19 | |
import org.apache.commons.lang.BooleanUtils; |
20 | |
import org.apache.commons.lang.StringUtils; |
21 | |
import org.jdom.Attribute; |
22 | |
import org.jdom.Document; |
23 | |
import org.jdom.Element; |
24 | |
import org.jdom.JDOMException; |
25 | |
import org.kuali.rice.core.util.RiceConstants; |
26 | |
import org.kuali.rice.core.util.xml.XmlException; |
27 | |
import org.kuali.rice.core.util.xml.XmlHelper; |
28 | |
import org.kuali.rice.kew.rule.RuleBaseValues; |
29 | |
import org.kuali.rice.kew.rule.RuleDelegation; |
30 | |
import org.kuali.rice.kew.rule.RuleTemplateOption; |
31 | |
import org.kuali.rice.kew.rule.bo.RuleAttribute; |
32 | |
import org.kuali.rice.kew.rule.bo.RuleTemplate; |
33 | |
import org.kuali.rice.kew.rule.bo.RuleTemplateAttribute; |
34 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
35 | |
import org.kuali.rice.kew.util.KEWConstants; |
36 | |
import org.xml.sax.SAXException; |
37 | |
|
38 | |
import javax.xml.parsers.ParserConfigurationException; |
39 | |
import java.io.IOException; |
40 | |
import java.io.InputStream; |
41 | |
import java.sql.Timestamp; |
42 | |
import java.text.ParseException; |
43 | |
import java.util.ArrayList; |
44 | |
import java.util.Collection; |
45 | |
import java.util.Iterator; |
46 | |
import java.util.List; |
47 | |
|
48 | |
import static org.kuali.rice.core.api.impex.xml.XmlConstants.*; |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | 0 | public class RuleTemplateXmlParser { |
57 | |
|
58 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(RuleTemplateXmlParser.class); |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
private static final boolean DEFAULT_ATTRIBUTE_REQUIRED = true; |
64 | |
private static final boolean DEFAULT_ATTRIBUTE_ACTIVE = true; |
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
private static final String DUMMY_DOCUMENT_TYPE = "dummyDocumentType"; |
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | 0 | private int templateAttributeCounter = 0; |
75 | |
|
76 | |
public List<RuleTemplate> parseRuleTemplates(InputStream input) throws IOException, XmlException { |
77 | |
|
78 | |
try { |
79 | 0 | Document doc = XmlHelper.trimSAXXml(input); |
80 | 0 | Element root = doc.getRootElement(); |
81 | 0 | return parseRuleTemplates(root); |
82 | 0 | } catch (JDOMException e) { |
83 | 0 | throw new XmlException("Parse error.", e); |
84 | 0 | } catch (SAXException e) { |
85 | 0 | throw new XmlException("Parse error.", e); |
86 | 0 | } catch (ParserConfigurationException e) { |
87 | 0 | throw new XmlException("Parse error.", e); |
88 | |
} |
89 | |
} |
90 | |
|
91 | |
public List<RuleTemplate> parseRuleTemplates(Element element) throws XmlException { |
92 | 0 | List<RuleTemplate> ruleTemplates = new ArrayList<RuleTemplate>(); |
93 | |
|
94 | |
|
95 | 0 | Collection<Element> ruleTemplatesElements = XmlHelper.findElements(element, RULE_TEMPLATES); |
96 | 0 | Iterator ruleTemplatesIterator = ruleTemplatesElements.iterator(); |
97 | 0 | while (ruleTemplatesIterator.hasNext()) { |
98 | 0 | Element ruleTemplatesElement = (Element) ruleTemplatesIterator.next(); |
99 | 0 | Collection<Element> ruleTemplateElements = XmlHelper.findElements(ruleTemplatesElement, RULE_TEMPLATE); |
100 | 0 | for (Iterator iterator = ruleTemplateElements.iterator(); iterator.hasNext();) { |
101 | 0 | ruleTemplates.add(parseRuleTemplate((Element) iterator.next(), ruleTemplates)); |
102 | |
} |
103 | 0 | } |
104 | 0 | return ruleTemplates; |
105 | |
} |
106 | |
|
107 | |
private RuleTemplate parseRuleTemplate(Element element, List<RuleTemplate> ruleTemplates) throws XmlException { |
108 | 0 | String name = element.getChildText(NAME, RULE_TEMPLATE_NAMESPACE); |
109 | 0 | String description = element.getChildText(DESCRIPTION, RULE_TEMPLATE_NAMESPACE); |
110 | 0 | Attribute allowOverwriteAttrib = element.getAttribute("allowOverwrite"); |
111 | |
|
112 | 0 | boolean allowOverwrite = false; |
113 | 0 | if (allowOverwriteAttrib != null) { |
114 | 0 | allowOverwrite = Boolean.valueOf(allowOverwriteAttrib.getValue()).booleanValue(); |
115 | |
} |
116 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(name)) { |
117 | 0 | throw new XmlException("RuleTemplate must have a name"); |
118 | |
} |
119 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(description)) { |
120 | 0 | throw new XmlException("RuleTemplate must have a description"); |
121 | |
} |
122 | |
|
123 | |
|
124 | 0 | RuleTemplate ruleTemplate = KEWServiceLocator.getRuleTemplateService().findByRuleTemplateName(name); |
125 | |
|
126 | 0 | if (ruleTemplate == null) { |
127 | |
|
128 | 0 | ruleTemplate = new RuleTemplate(); |
129 | |
} else { |
130 | |
|
131 | 0 | if (!allowOverwrite) { |
132 | 0 | throw new RuntimeException("Attempting to overwrite template " + name + " without allowOverwrite set"); |
133 | |
} |
134 | |
|
135 | |
|
136 | 0 | assert(name.equals(ruleTemplate.getName())) : "Existing template definition name does not match incoming definition name"; |
137 | |
} |
138 | |
|
139 | |
|
140 | 0 | ruleTemplate.setName(name); |
141 | 0 | ruleTemplate.setDescription(description); |
142 | |
|
143 | |
|
144 | 0 | updateDelegationTemplate(element, ruleTemplate, ruleTemplates); |
145 | |
|
146 | |
|
147 | 0 | updateRuleTemplateAttributes(element, ruleTemplate); |
148 | |
|
149 | |
|
150 | |
|
151 | 0 | KEWServiceLocator.getRuleTemplateService().save(ruleTemplate); |
152 | |
|
153 | |
|
154 | 0 | updateRuleTemplateDefaultOptions(element, ruleTemplate); |
155 | |
|
156 | 0 | KEWServiceLocator.getRuleTemplateService().save(ruleTemplate); |
157 | |
|
158 | 0 | return ruleTemplate; |
159 | |
} |
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
protected void updateRuleTemplateDefaultOptions(Element ruleTemplateElement, RuleTemplate updatedRuleTemplate) throws XmlException { |
180 | 0 | Element defaultsElement = ruleTemplateElement.getChild(RULE_DEFAULTS, RULE_TEMPLATE_NAMESPACE); |
181 | |
|
182 | |
|
183 | 0 | boolean isDelegation = updateRuleDefaults(defaultsElement, updatedRuleTemplate); |
184 | |
|
185 | |
|
186 | 0 | updateRuleTemplateOptions(defaultsElement, updatedRuleTemplate, isDelegation); |
187 | |
|
188 | 0 | } |
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
protected void updateRuleTemplateOptions(Element defaultsElement, RuleTemplate updatedRuleTemplate, boolean isDelegation) throws XmlException { |
196 | |
|
197 | |
|
198 | |
|
199 | 0 | String defaultActionRequested = null; |
200 | 0 | Boolean supportsComplete = null; |
201 | 0 | Boolean supportsApprove = null; |
202 | 0 | Boolean supportsAcknowledge = null; |
203 | 0 | Boolean supportsFYI = null; |
204 | |
|
205 | |
|
206 | |
|
207 | 0 | updatedRuleTemplate.removeNonDefaultOptions(); |
208 | |
|
209 | |
|
210 | 0 | if (defaultsElement != null) { |
211 | |
|
212 | 0 | defaultActionRequested = defaultsElement.getChildText(DEFAULT_ACTION_REQUESTED, RULE_TEMPLATE_NAMESPACE); |
213 | 0 | supportsComplete = BooleanUtils.toBooleanObject(defaultsElement.getChildText(SUPPORTS_COMPLETE, RULE_TEMPLATE_NAMESPACE)); |
214 | 0 | supportsApprove = BooleanUtils.toBooleanObject(defaultsElement.getChildText(SUPPORTS_APPROVE, RULE_TEMPLATE_NAMESPACE)); |
215 | 0 | supportsAcknowledge = BooleanUtils.toBooleanObject(defaultsElement.getChildText(SUPPORTS_ACKNOWLEDGE, RULE_TEMPLATE_NAMESPACE)); |
216 | 0 | supportsFYI = BooleanUtils.toBooleanObject(defaultsElement.getChildText(SUPPORTS_FYI, RULE_TEMPLATE_NAMESPACE)); |
217 | |
} |
218 | |
|
219 | 0 | if (!isDelegation) { |
220 | |
|
221 | |
|
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
|
228 | |
|
229 | 0 | updateOrDeleteRuleTemplateOption(updatedRuleTemplate, KEWConstants.ACTION_REQUEST_DEFAULT_CD, defaultActionRequested); |
230 | 0 | updateOrDeleteRuleTemplateOption(updatedRuleTemplate, KEWConstants.ACTION_REQUEST_APPROVE_REQ, supportsApprove); |
231 | 0 | updateOrDeleteRuleTemplateOption(updatedRuleTemplate, KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, supportsAcknowledge); |
232 | 0 | updateOrDeleteRuleTemplateOption(updatedRuleTemplate, KEWConstants.ACTION_REQUEST_FYI_REQ, supportsFYI); |
233 | 0 | updateOrDeleteRuleTemplateOption(updatedRuleTemplate, KEWConstants.ACTION_REQUEST_COMPLETE_REQ, supportsComplete); |
234 | |
} |
235 | |
|
236 | 0 | } |
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
protected boolean updateRuleDefaults(Element defaultsElement, RuleTemplate updatedRuleTemplate) throws XmlException { |
246 | |
|
247 | |
|
248 | 0 | if (updatedRuleTemplate.getRuleTemplateId() != null) { |
249 | 0 | RuleBaseValues ruleDefaults = KEWServiceLocator.getRuleService().findDefaultRuleByRuleTemplateId(updatedRuleTemplate.getRuleTemplateId()); |
250 | 0 | if (ruleDefaults != null) { |
251 | 0 | List ruleDelegationDefaults = KEWServiceLocator.getRuleDelegationService().findByDelegateRuleId(ruleDefaults.getRuleBaseValuesId()); |
252 | |
|
253 | 0 | KEWServiceLocator.getRuleService().delete(ruleDefaults.getRuleBaseValuesId()); |
254 | |
|
255 | 0 | for (Iterator iterator = ruleDelegationDefaults.iterator(); iterator.hasNext();) { |
256 | 0 | RuleDelegation ruleDelegation = (RuleDelegation) iterator.next(); |
257 | 0 | KEWServiceLocator.getRuleDelegationService().delete(ruleDelegation.getRuleDelegationId()); |
258 | 0 | } |
259 | |
} |
260 | |
} |
261 | |
|
262 | 0 | boolean isDelegation = false; |
263 | |
|
264 | 0 | if (defaultsElement != null) { |
265 | 0 | String delegationType = defaultsElement.getChildText(DELEGATION_TYPE, RULE_TEMPLATE_NAMESPACE); |
266 | 0 | isDelegation = !org.apache.commons.lang.StringUtils.isEmpty(delegationType); |
267 | |
|
268 | 0 | String description = defaultsElement.getChildText(DESCRIPTION, RULE_TEMPLATE_NAMESPACE); |
269 | |
|
270 | |
|
271 | 0 | if (description == null) { |
272 | 0 | throw new XmlException("Description must be specified in rule defaults"); |
273 | |
} |
274 | |
|
275 | 0 | String fromDate = defaultsElement.getChildText(FROM_DATE, RULE_TEMPLATE_NAMESPACE); |
276 | 0 | String toDate = defaultsElement.getChildText(TO_DATE, RULE_TEMPLATE_NAMESPACE); |
277 | |
|
278 | 0 | Boolean forceAction = BooleanUtils.toBooleanObject(defaultsElement.getChildText(FORCE_ACTION, RULE_TEMPLATE_NAMESPACE)); |
279 | 0 | Boolean active = BooleanUtils.toBooleanObject(defaultsElement.getChildText(ACTIVE, RULE_TEMPLATE_NAMESPACE)); |
280 | |
|
281 | 0 | if (isDelegation && !KEWConstants.DELEGATION_PRIMARY.equals(delegationType) && !KEWConstants.DELEGATION_SECONDARY.equals(delegationType)) { |
282 | 0 | throw new XmlException("Invalid delegation type '" + delegationType + "'." + " Expected one of: " |
283 | |
+ KEWConstants.DELEGATION_PRIMARY + "," + KEWConstants.DELEGATION_SECONDARY); |
284 | |
} |
285 | |
|
286 | |
|
287 | 0 | RuleBaseValues ruleDefaults = new RuleBaseValues(); |
288 | |
|
289 | |
|
290 | 0 | ruleDefaults.setRuleTemplate(updatedRuleTemplate); |
291 | 0 | ruleDefaults.setDocTypeName(DUMMY_DOCUMENT_TYPE); |
292 | 0 | ruleDefaults.setTemplateRuleInd(Boolean.TRUE); |
293 | 0 | ruleDefaults.setCurrentInd(Boolean.TRUE); |
294 | 0 | ruleDefaults.setVersionNbr(new Integer(0)); |
295 | 0 | ruleDefaults.setDescription(description); |
296 | |
|
297 | |
|
298 | 0 | ruleDefaults.setForceAction(Boolean.valueOf(BooleanUtils.isTrue(forceAction))); |
299 | 0 | ruleDefaults.setActiveInd(Boolean.valueOf(BooleanUtils.isTrue(active))); |
300 | |
|
301 | 0 | if (ruleDefaults.getActivationDate() == null) { |
302 | 0 | ruleDefaults.setActivationDate(new Timestamp(System.currentTimeMillis())); |
303 | |
} |
304 | |
|
305 | 0 | ruleDefaults.setFromDate(formatDate("fromDate",fromDate)); |
306 | 0 | ruleDefaults.setToDate(formatDate("toDate", toDate)); |
307 | |
|
308 | |
|
309 | |
|
310 | 0 | RuleDelegation ruleDelegationDefaults = null; |
311 | 0 | if (isDelegation) { |
312 | 0 | ruleDelegationDefaults = new RuleDelegation(); |
313 | 0 | ruleDelegationDefaults.setDelegationRuleBaseValues(ruleDefaults); |
314 | 0 | ruleDelegationDefaults.setDelegationType(delegationType); |
315 | 0 | ruleDelegationDefaults.setResponsibilityId(new Long(-1)); |
316 | |
} |
317 | |
|
318 | |
|
319 | 0 | KEWServiceLocator.getRuleTemplateService().saveRuleDefaults(ruleDelegationDefaults, ruleDefaults); |
320 | |
} else { |
321 | |
|
322 | |
} |
323 | |
|
324 | 0 | return isDelegation; |
325 | |
} |
326 | |
|
327 | |
|
328 | |
|
329 | |
|
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
protected void updateOrDeleteRuleTemplateOption(RuleTemplate updatedRuleTemplate, String key, Object value) { |
335 | 0 | if (value != null) { |
336 | |
|
337 | 0 | RuleTemplateOption option = updatedRuleTemplate.getRuleTemplateOption(key); |
338 | 0 | if (option != null) { |
339 | 0 | option.setValue(value.toString()); |
340 | |
} else { |
341 | 0 | updatedRuleTemplate.getRuleTemplateOptions().add(new RuleTemplateOption(key, value.toString())); |
342 | |
} |
343 | 0 | } else { |
344 | |
|
345 | 0 | Iterator<RuleTemplateOption> options = updatedRuleTemplate.getRuleTemplateOptions().iterator(); |
346 | 0 | while (options.hasNext()) { |
347 | 0 | RuleTemplateOption opt = options.next(); |
348 | 0 | if (key.equals(opt.getKey())) { |
349 | 0 | options.remove(); |
350 | 0 | break; |
351 | |
} |
352 | 0 | } |
353 | |
} |
354 | 0 | } |
355 | |
|
356 | |
|
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | |
|
363 | |
protected void updateDelegationTemplate(Element ruleTemplateElement, RuleTemplate updatedRuleTemplate, List<RuleTemplate> parsedRuleTemplates) throws XmlException { |
364 | 0 | String delegateTemplateName = ruleTemplateElement.getChildText(DELEGATION_TEMPLATE, RULE_TEMPLATE_NAMESPACE); |
365 | |
|
366 | 0 | if (delegateTemplateName != null) { |
367 | |
|
368 | |
|
369 | 0 | RuleTemplate delegateTemplate = KEWServiceLocator.getRuleTemplateService().findByRuleTemplateName(delegateTemplateName); |
370 | |
|
371 | |
|
372 | 0 | if (delegateTemplate == null) { |
373 | 0 | for (RuleTemplate rt: parsedRuleTemplates) { |
374 | 0 | if (delegateTemplateName.equalsIgnoreCase(rt.getName())) { |
375 | |
|
376 | 0 | Long ruleTemplateId = KEWServiceLocator.getRuleTemplateService().getNextRuleTemplateId(); |
377 | 0 | rt.setRuleTemplateId(ruleTemplateId); |
378 | 0 | delegateTemplate = rt; |
379 | 0 | break; |
380 | |
} |
381 | |
} |
382 | |
} |
383 | |
|
384 | 0 | if (delegateTemplate == null) { |
385 | 0 | throw new XmlException("Cannot find delegation template " + delegateTemplateName); |
386 | |
} |
387 | |
|
388 | 0 | updatedRuleTemplate.setDelegationTemplateId(delegateTemplate.getDelegationTemplateId()); |
389 | 0 | updatedRuleTemplate.setDelegationTemplate(delegateTemplate); |
390 | |
} else { |
391 | |
|
392 | |
} |
393 | 0 | } |
394 | |
|
395 | |
|
396 | |
|
397 | |
|
398 | |
|
399 | |
|
400 | |
|
401 | |
protected void updateRuleTemplateAttributes(Element ruleTemplateElement, RuleTemplate updatedRuleTemplate) throws XmlException { |
402 | |
|
403 | |
|
404 | |
|
405 | |
|
406 | |
|
407 | 0 | Element attributesElement = ruleTemplateElement.getChild(ATTRIBUTES, RULE_TEMPLATE_NAMESPACE); |
408 | 0 | List<RuleTemplateAttribute> incomingAttributes = new ArrayList<RuleTemplateAttribute>(); |
409 | 0 | if (attributesElement != null) { |
410 | 0 | incomingAttributes.addAll(parseRuleTemplateAttributes(attributesElement, updatedRuleTemplate)); |
411 | |
} |
412 | |
|
413 | |
|
414 | 0 | for (RuleTemplateAttribute currentRuleTemplateAttribute: updatedRuleTemplate.getRuleTemplateAttributes()) { |
415 | 0 | String ruleAttributeName = (currentRuleTemplateAttribute.getRuleAttribute() != null) ? currentRuleTemplateAttribute.getRuleAttribute().getName() : "(null)"; |
416 | 0 | LOG.debug("Inactivating rule template attribute with id " + currentRuleTemplateAttribute.getRuleTemplateAttributeId() + " and rule attribute with name " + ruleAttributeName); |
417 | 0 | currentRuleTemplateAttribute.setActive(Boolean.FALSE); |
418 | 0 | } |
419 | |
|
420 | |
|
421 | |
|
422 | 0 | for (RuleTemplateAttribute ruleTemplateAttribute: incomingAttributes) { |
423 | 0 | RuleTemplateAttribute potentialExistingTemplateAttribute = updatedRuleTemplate.getRuleTemplateAttribute(ruleTemplateAttribute); |
424 | 0 | if (potentialExistingTemplateAttribute != null) { |
425 | |
|
426 | 0 | potentialExistingTemplateAttribute.setActive(ruleTemplateAttribute.getActive()); |
427 | 0 | potentialExistingTemplateAttribute.setRequired(ruleTemplateAttribute.getRequired()); |
428 | |
} else { |
429 | |
|
430 | 0 | updatedRuleTemplate.getRuleTemplateAttributes().add(ruleTemplateAttribute); |
431 | |
} |
432 | 0 | } |
433 | 0 | } |
434 | |
|
435 | |
|
436 | |
|
437 | |
|
438 | |
|
439 | |
|
440 | |
|
441 | |
|
442 | |
private List<RuleTemplateAttribute> parseRuleTemplateAttributes(Element attributesElement, RuleTemplate ruleTemplate) throws XmlException { |
443 | 0 | List<RuleTemplateAttribute> ruleTemplateAttributes = new ArrayList<RuleTemplateAttribute>(); |
444 | 0 | Collection<Element> attributeElements = XmlHelper.findElements(attributesElement, ATTRIBUTE); |
445 | 0 | for (Iterator iterator = attributeElements.iterator(); iterator.hasNext();) { |
446 | 0 | ruleTemplateAttributes.add(parseRuleTemplateAttribute((Element) iterator.next(), ruleTemplate)); |
447 | |
} |
448 | 0 | return ruleTemplateAttributes; |
449 | |
} |
450 | |
|
451 | |
|
452 | |
|
453 | |
|
454 | |
|
455 | |
|
456 | |
|
457 | |
|
458 | |
private RuleTemplateAttribute parseRuleTemplateAttribute(Element element, RuleTemplate ruleTemplate) throws XmlException { |
459 | 0 | String attributeName = element.getChildText(NAME, RULE_TEMPLATE_NAMESPACE); |
460 | 0 | String requiredValue = element.getChildText(REQUIRED, RULE_TEMPLATE_NAMESPACE); |
461 | 0 | String activeValue = element.getChildText(ACTIVE, RULE_TEMPLATE_NAMESPACE); |
462 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(attributeName)) { |
463 | 0 | throw new XmlException("Attribute name must be non-empty"); |
464 | |
} |
465 | 0 | boolean required = DEFAULT_ATTRIBUTE_REQUIRED; |
466 | 0 | if (requiredValue != null) { |
467 | 0 | required = Boolean.parseBoolean(requiredValue); |
468 | |
} |
469 | 0 | boolean active = DEFAULT_ATTRIBUTE_ACTIVE; |
470 | 0 | if (activeValue != null) { |
471 | 0 | active = Boolean.parseBoolean(activeValue); |
472 | |
} |
473 | 0 | RuleAttribute ruleAttribute = KEWServiceLocator.getRuleAttributeService().findByName(attributeName); |
474 | 0 | if (ruleAttribute == null) { |
475 | 0 | throw new XmlException("Could not locate rule attribute for name '" + attributeName + "'"); |
476 | |
} |
477 | 0 | RuleTemplateAttribute templateAttribute = new RuleTemplateAttribute(); |
478 | 0 | templateAttribute.setRuleAttribute(ruleAttribute); |
479 | 0 | templateAttribute.setRuleAttributeId(ruleAttribute.getRuleAttributeId()); |
480 | 0 | templateAttribute.setRuleTemplate(ruleTemplate); |
481 | 0 | templateAttribute.setRequired(Boolean.valueOf(required)); |
482 | 0 | templateAttribute.setActive(Boolean.valueOf(active)); |
483 | 0 | templateAttribute.setDisplayOrder(new Integer(templateAttributeCounter++)); |
484 | 0 | return templateAttribute; |
485 | |
} |
486 | |
|
487 | |
public Timestamp formatDate(String dateLabel, String dateString) throws XmlException { |
488 | 0 | if (StringUtils.isBlank(dateString)) { |
489 | 0 | return null; |
490 | |
} |
491 | |
try { |
492 | 0 | return new Timestamp(RiceConstants.getDefaultDateFormat().parse(dateString).getTime()); |
493 | 0 | } catch (ParseException e) { |
494 | 0 | throw new XmlException(dateLabel + " is not in the proper format. Should have been: " + RiceConstants.DEFAULT_DATE_FORMAT_PATTERN); |
495 | |
} |
496 | |
} |
497 | |
|
498 | |
} |