001: /*
002: * This file is part of the WfMOpen project.
003: * Copyright (C) 2001-2005 Danet GmbH (www.danet.de), BU BTS.
004: * All rights reserved.
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * $Id: EventWrapper.java,v 1.5 2006/09/29 12:32:11 drmlipp Exp $
021: *
022: * $Log: EventWrapper.java,v $
023: * Revision 1.5 2006/09/29 12:32:11 drmlipp
024: * Consistently using WfMOpen as projct name now.
025: *
026: * Revision 1.4 2006/09/06 09:31:06 drmlipp
027: * Cleaned up event display.
028: *
029: * Revision 1.3 2005/10/24 15:30:49 drmlipp
030: * Implemented context data change display.
031: *
032: * Revision 1.2 2005/10/21 15:05:51 drmlipp
033: * Continued audit event display and cleaned up some things.
034: *
035: * Revision 1.1 2005/10/20 13:52:17 drmlipp
036: * Implementation of audit event display continued.
037: *
038: */
039: package de.danet.an.workflow.clients.mgmtportlets.process;
040:
041: import java.io.Serializable;
042: import java.util.ArrayList;
043: import java.util.Date;
044: import java.util.HashSet;
045: import java.util.Iterator;
046: import java.util.List;
047: import java.util.Set;
048: import java.util.TreeSet;
049:
050: import javax.faces.context.FacesContext;
051: import javax.faces.model.DataModel;
052:
053: import de.danet.an.workflow.omgcore.ProcessData;
054: import de.danet.an.workflow.omgcore.WfAuditEvent;
055: import de.danet.an.workflow.omgcore.WfDataAuditEvent;
056: import de.danet.an.workflow.omgcore.WfStateAuditEvent;
057:
058: /**
059: * @author lipp
060: *
061: */
062: public class EventWrapper implements Serializable {
063:
064: private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
065: .getLog(EventWrapper.class);
066:
067: private WfAuditEvent event;
068:
069: /**
070: * Create a new instance, backed by the given event.
071: * @param event the event
072: */
073: public EventWrapper(WfAuditEvent event) {
074: this .event = event;
075: }
076:
077: /* (non-Javadoc)
078: * @see de.danet.an.workflow.omgcore.WfAuditEvent#activityKey()
079: */
080: public String getActivityKey() {
081: return event.activityKey();
082: }
083:
084: /* (non-Javadoc)
085: * @see de.danet.an.workflow.omgcore.WfAuditEvent#activityName()
086: */
087: public String getActivityName() {
088: return event.activityName();
089: }
090:
091: /* (non-Javadoc)
092: * @see de.danet.an.workflow.omgcore.WfAuditEvent#eventType()
093: */
094: public String getEventType() {
095: return event.eventType();
096: }
097:
098: /* (non-Javadoc)
099: * @see de.danet.an.workflow.omgcore.WfAuditEvent#processKey()
100: */
101: public String getProcessKey() {
102: return event.processKey();
103: }
104:
105: /* (non-Javadoc)
106: * @see de.danet.an.workflow.omgcore.WfAuditEvent#processMgrName()
107: */
108: public String getProcessMgrName() {
109: return event.processMgrName();
110: }
111:
112: /* (non-Javadoc)
113: * @see de.danet.an.workflow.omgcore.WfAuditEvent#processMgrVersion()
114: */
115: public String getProcessMgrVersion() {
116: return event.processMgrVersion();
117: }
118:
119: /* (non-Javadoc)
120: * @see de.danet.an.workflow.omgcore.WfAuditEvent#processName()
121: */
122: public String getProcessName() {
123: return event.processName();
124: }
125:
126: /* (non-Javadoc)
127: * @see de.danet.an.workflow.omgcore.WfAuditEvent#timeStamp()
128: */
129: public Date getTimeStamp() {
130: return event.timeStamp();
131: }
132:
133: public boolean isStateAuditEvent() {
134: return event instanceof WfStateAuditEvent;
135: }
136:
137: /* (non-Javadoc)
138: * @see WfStateAuditEvent#oldState
139: */
140: public String getOldState() {
141: if (isStateAuditEvent()) {
142: return ((WfStateAuditEvent) event).oldState();
143: }
144: throw new UnsupportedOperationException();
145: }
146:
147: /* (non-Javadoc)
148: * @see #getOldState
149: */
150: public String getOldStateName() {
151: return StateNameMapper.mapState(getOldState());
152: }
153:
154: /* (non-Javadoc)
155: * @see WfStateAuditEvent#newState
156: */
157: public String getNewState() {
158: if (isStateAuditEvent()) {
159: return ((WfStateAuditEvent) event).newState();
160: }
161: throw new UnsupportedOperationException();
162: }
163:
164: /* (non-Javadoc)
165: * @see #getNewState
166: */
167: public String getNewStateName() {
168: return StateNameMapper.mapState(getNewState());
169: }
170:
171: public boolean isDataAuditEvent() {
172: return event instanceof WfDataAuditEvent;
173: }
174:
175: public String showDetail() {
176: if (isDataAuditEvent()) {
177: if (logger.isDebugEnabled()) {
178: logger.debug("Setting data changes for " + event);
179: }
180: List changes = new ArrayList();
181: Set items = new TreeSet();
182: ProcessData oldData = ((WfDataAuditEvent) event).oldData();
183: ProcessData newData = ((WfDataAuditEvent) event).newData();
184: items.addAll(oldData.keySet());
185: items.addAll(newData.keySet());
186: for (Iterator i = items.iterator(); i.hasNext();) {
187: String item = (String) i.next();
188: changes.add(new ContextChangeWrapper(item, oldData
189: .get(item), newData.get(item)));
190: }
191: FacesContext fc = FacesContext.getCurrentInstance();
192: ((ProcessSelection) fc.getExternalContext().getSessionMap()
193: .get("processSelection"))
194: .setAuditEventDataChangesData(changes);
195: return null;
196: }
197: logger.warn("Show detail called, but " + event
198: + " has no details");
199: return null;
200: }
201: }
|