1    package com.instantbank.lettertemplate.control.event;
2    
3    import java.io.Serializable;
4    import java.util.ArrayList;
5    
6    /**
7     *  letter Images usecase: This event is sent from the web tier to the EJB
8     *  Controller to notify the EJB Controller that an action needs to be made in
9     *  the letter Images model data.
10    *
11    * @author Instant-bank (Consuelo Franky, Jorge Cardenas)
12    * @created August 2002
13    */
14   public class ImagesRepositoryEvent extends LetterTemplateEventSupport {
15   
16     // possible operations on ImagesRepository model data:
17     /**
18      *  action constant of getting the images list of the current company
19      */
20     public static final int LIST_IMAGES_NAMES = 0;
21     /**
22      *  action constant of getting the images list of the current company
23      */
24     public static final int UPDATE_IMAGES_NAMES = 1;
25     /**
26      *  action constant of getting the images list of the current company
27      */
28     public static final int PRE_STORE_IMAGE = 2;
29     /**
30      *  action constant of getting the images list of the current company
31      */
32     public static final int STORE_IMAGE = 3;
33   
34     // attributes: necesary data for executing the operations
35     /**
36      *  action requested by the user
37      */
38     private int actionType;
39     /**
40      *  current company
41      */
42     private String companyId;
43     /**
44      *  current user
45      */
46     private Long userId;
47     /**
48      *  name of image to store
49      */
50     private String description;
51     /**
52      *  image to store
53      */
54     private byte[] image;
55     /**
56      *  items for changing the images list of the current company
57      */
58     private ArrayList items;
59   
60   
61     /**
62      *  constructor: initializes attributes
63      *
64      * @param actionType action requested by the user
65      * @param companyId current company
66      * @param userId current user
67      * @param items for changing the images list of the current company
68      * @param description name of new image
69      * @param image bytes of image
70      */
71     public ImagesRepositoryEvent(int actionType, String companyId,
72                                  Long userId, String description, byte[] image,
73                                  ArrayList items) {
74       this.actionType = actionType;
75       this.companyId = companyId;
76       this.userId = userId;
77       this.description = description;
78       this.image = image;
79       this.items = items;
80     }
81   
82   
83     /**
84      *  get method for actionType
85      *
86      * @return The actionType value
87      */
88     public int getActionType() {
89       return actionType;
90     }
91   
92   
93     /**
94      *  get method for companyId
95      *
96      * @return The companyId value
97      */
98     public String getCompanyId() {
99       return companyId;
100    }
101  
102  
103    /**
104     *  get method for userId
105     *
106     * @return The userId value
107     */
108    public Long getUserId() {
109      return userId;
110    }
111  
112  
113    /**
114     *  get method for description
115     *
116     * @return The description value
117     */
118    public String getDescription() {
119      return description;
120    }
121  
122  
123    /**
124     *  get method for image
125     *
126     * @return The image value
127     */
128    public byte[] getImage() {
129      return image;
130    }
131  
132  
133    /**
134     *  get method for items
135     *
136     * @return The items value
137     */
138    public ArrayList getItems() {
139      return items;
140    }
141  
142  
143  
144    /**
145     *  String representation of the event:
146     *
147     * @return text of event
148     */
149    public String toString() {
150      return "ImageRepositoryEvent("
151        + String.valueOf(actionType) + ", "
152        + companyId + ", "
153        + userId.toString() + ","
154        + description + ", "
155        + "an image" +
156        ")";
157    }
158  
159  
160    // JNDI name for the event: LetterTemplateController EJB registers this env variable
161    // through its J2EE descriptor
162    /**
163     *  Gets the eventName attribute of the ImagesRepositoryEvent object
164     *
165     * @return The eventName value
166     */
167    public String getEventName() {
168      return "java:comp/env/imagesRepositoryEvent";
169    }
170  }
171  
172