Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/jbpm/workflow/log/impl/LogImpl.java


1   package org.jbpm.workflow.log.impl;
2   
3   import java.util.*;
4   import org.jbpm.workflow.definition.*;
5   import org.jbpm.workflow.execution.*;
6   import org.jbpm.workflow.log.*;
7   import org.jbpm.workflow.organisation.*;
8   
9   /**
10   * @hibernate.class table="JBPM_LOG"
11   */
12  public class LogImpl implements Log, Comparable {
13    
14    public LogImpl() {}
15  
16    public LogImpl( Date date, EventType eventType, Flow flow ) {
17      this.date = date;
18      this.eventType = eventType;
19      this.flow = flow;
20      this.details = new HashSet();
21    }
22    
23    public LogImpl( String actorId, Date date, EventType eventType, Flow flow ) {
24      this.actorId = actorId;
25      this.date = date;
26      this.eventType = eventType;
27      this.flow = flow;
28      this.details = new HashSet();
29    }
30    
31    /**
32     * @hibernate.id column="id" type="long" unsaved-value="null" generator-class="org.jbpm.util.db.IdGenerator"
33     */  
34    public Long getId() { return id; }
35    public void setId( Long id ) { this.id = id; }
36    
37    /**
38     * @hibernate.property type="string"
39     */
40    public String getActorId() { return this.actorId; }
41    public void setActorId(String actorId) { this.actorId = actorId; }
42    public Actor getActor() { return organisationUtil.getActor( actorId ); }
43  
44    /**
45     * @hibernate.many-to-one class="org.jbpm.workflow.execution.impl.FlowImpl" cascade="none"
46     */  
47    public Flow getFlow() { return this.flow; }
48    public void setFlow(Flow flow) { this.flow = flow; }
49  
50    /**
51     * @hibernate.property type="timestamp" column="date_"
52     */
53    public Date getDate() { return date; }
54    public void setDate( Date date ) { this.date = date; }
55    
56    /**
57     * @hibernate.property type="org.jbpm.workflow.definition.EventType" column="type_"
58     */
59    public EventType getEventType() { return eventType; }
60    public void setEventType( EventType eventType ) { this.eventType = eventType; }
61  
62    /**
63     * @hibernate.set lazy="true" cascade="all"
64     * @hibernate.collection-key column="log"
65     * @hibernate.collection-one-to-many class="org.jbpm.workflow.log.impl.LogDetailImpl"
66     */ 
67    public Collection getDetails() { return details; }
68    public void setDetails( Collection details ) { this.details = details; }
69    
70    public Collection getObjectReferences( String className ) { 
71      Collection objectReferences = new ArrayList();
72      Iterator iter = this.details.iterator();
73      while (iter.hasNext()) {
74        LogDetail logDetail = (LogDetail) iter.next();
75        if ( logDetail instanceof ObjectReferenceImpl ) {
76          ObjectReferenceImpl objectReference = (ObjectReferenceImpl) logDetail;
77          if ( objectReference.getClassName().indexOf( className ) != -1 ) {
78            objectReferences.add( objectReference );
79          }
80        }
81      }
82      return objectReferences;
83    }
84    
85  
86    public String toString() {
87      return "log[" + id + "|" + eventType.toString() + "|" + date + "]";
88    }
89    
90    public int compareTo(Object otherEvent) {
91      Date otherEventDate = ((LogImpl) otherEvent).getDate();
92      return (int) (date.getTime() - otherEventDate.getTime());
93    }
94    
95    private Long id = null;
96    private String actorId = null;
97    private Flow flow = null;
98    private Date date = null;
99    private EventType eventType = null;
100   private Collection details = null;
101   private static OrganisationUtil organisationUtil = OrganisationUtil.getInstance();
102 }