1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
package org.kuali.rice.edl.impl.components; |
19 | |
|
20 | |
import java.util.List; |
21 | |
|
22 | |
import org.apache.commons.lang.StringUtils; |
23 | |
import org.apache.log4j.Logger; |
24 | |
import org.kuali.rice.core.util.xml.XmlJotter; |
25 | |
import org.kuali.rice.edl.impl.EDLContext; |
26 | |
import org.kuali.rice.edl.impl.EDLModelComponent; |
27 | |
import org.kuali.rice.edl.impl.EDLXmlUtils; |
28 | |
import org.kuali.rice.edl.impl.RequestParser; |
29 | |
import org.kuali.rice.kew.api.WorkflowDocument; |
30 | |
import org.kuali.rice.kew.api.action.ActionTaken; |
31 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
32 | |
import org.kuali.rice.kim.bo.Person; |
33 | |
import org.w3c.dom.Document; |
34 | |
import org.w3c.dom.Element; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | public class AnnotationComponent implements EDLModelComponent { |
42 | 0 | private static final Logger LOG = Logger.getLogger(AnnotationComponent.class); |
43 | |
|
44 | |
public void updateDOM(Document dom, Element configElement, EDLContext edlContext) { |
45 | 0 | WorkflowDocument document = (WorkflowDocument) edlContext.getRequestParser().getAttribute( |
46 | |
RequestParser.WORKFLOW_DOCUMENT_SESSION_KEY); |
47 | |
|
48 | |
|
49 | 0 | Element currentVersion = VersioningPreprocessor.findCurrentVersion(dom); |
50 | 0 | String annotation = edlContext.getRequestParser().getParameterValue("annotation"); |
51 | 0 | if (!StringUtils.isEmpty(annotation)) { |
52 | 0 | EDLXmlUtils.createTextElementOnParent(currentVersion, "currentAnnotation", annotation); |
53 | |
} |
54 | 0 | LOG.debug("Inserting annotation: " + annotation); |
55 | |
|
56 | 0 | List<ActionTaken> actionsTaken = document.getActionsTaken(); |
57 | 0 | if (actionsTaken != null) { |
58 | |
|
59 | |
|
60 | |
|
61 | 0 | for (ActionTaken actionTaken : actionsTaken) { |
62 | 0 | if (actionTaken != null) { |
63 | 0 | annotation = actionTaken.getAnnotation(); |
64 | 0 | if (annotation != null) { |
65 | 0 | LOG.debug("Adding annotation: " + annotation); |
66 | 0 | Person person = KimApiServiceLocator.getPersonService().getPerson(actionTaken.getPrincipalId()); |
67 | 0 | EDLXmlUtils.createTextElementOnParent(currentVersion, "annotation", person.getName() + ": " |
68 | |
+ annotation); |
69 | 0 | if (LOG.isDebugEnabled()) { |
70 | 0 | LOG.debug("dom: " + XmlJotter.jotNode(dom)); |
71 | |
} |
72 | 0 | } |
73 | |
} |
74 | |
} |
75 | |
} |
76 | 0 | } |
77 | |
} |