01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: // Created on Dec 14, 2006
18: package edu.iu.uis.eden.edl.components;
19:
20: import org.apache.log4j.Logger;
21: import org.w3c.dom.Document;
22: import org.w3c.dom.Element;
23:
24: import edu.iu.uis.eden.clientapp.WorkflowDocument;
25: import edu.iu.uis.eden.clientapp.vo.ActionTakenVO;
26: import edu.iu.uis.eden.edl.EDLContext;
27: import edu.iu.uis.eden.edl.EDLModelComponent;
28: import edu.iu.uis.eden.edl.EDLXmlUtils;
29: import edu.iu.uis.eden.edl.RequestParser;
30: import edu.iu.uis.eden.exception.WorkflowException;
31: import edu.iu.uis.eden.util.XmlHelper;
32:
33: /**
34: * EDL pipeline component that exposes annotations from the previous array of taken actions
35: * in the EDL to render.
36: * @author Aaron Hamid (arh14 at cornell dot edu)
37: */
38: public class AnnotationComponent implements EDLModelComponent {
39: private static final Logger LOG = Logger
40: .getLogger(AnnotationComponent.class);
41:
42: public void updateDOM(Document dom, Element configElement,
43: EDLContext edlContext) {
44: WorkflowDocument document = (WorkflowDocument) edlContext
45: .getRequestParser().getAttribute(
46: RequestParser.WORKFLOW_DOCUMENT_SESSION_KEY);
47: // get the array of actions taken
48: ActionTakenVO[] actionsTaken;
49: try {
50: actionsTaken = document.getActionsTaken();
51: } catch (WorkflowException we) {
52: try {
53: LOG.error("Error retrieving actions taken on document "
54: + document.getRouteHeaderId() + " ("
55: + document.getDocumentType() + ")", we);
56: } catch (WorkflowException we2) {
57: // give me a break :/
58: LOG
59: .error("Error retrieving route header id from document");
60: }
61: return;
62: }
63: if (actionsTaken != null) {
64: // get the current version of data
65: Element currentVersion = VersioningPreprocessor
66: .findCurrentVersion(dom);
67: // for every ActionTaken, append every annotation as a child element of EDL data element
68: for (ActionTakenVO actionTaken : actionsTaken) {
69: if (actionTaken != null) {
70: String annotation = actionTaken.getAnnotation();
71: if (annotation != null) {
72: LOG.debug("Adding annotation: " + annotation);
73: EDLXmlUtils.createTextElementOnParent(
74: currentVersion, "annotation",
75: actionTaken.getUserVO()
76: .getDisplayName()
77: + ": " + annotation);
78: LOG.debug("dom: " + XmlHelper.jotNode(dom));
79: }
80: }
81: }
82: }
83: }
84: }
|