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