4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
Flier.java
Go to the documentation of this file.
1 /*
2  * Project: Server for annotations sharing
3  * Author: Ing. Jaroslav Dytrych idytrych@fit.vutbr.cz
4  * File: Flier.java
5  * Description: Class for representing flier with informations for comet handlers
6  */
7 
8 /**
9  * @file Flier.java
10  *
11  * @brief Flier with informations for comet handlers
12  */
13 
14 package cz.vutbr.fit.knot.annotations.comet;
15 
20 import java.util.ArrayList;
21 import java.util.Iterator;
22 
23 /**
24  * Class for representing flier with informations for comet handlers.
25  * It's created as part of informations about client request (class RequestInfo)
26  * and then sent to all comet handlers to process.
27  *
28  * @brief Flier with informations for comet handlers
29  * @author idytrych
30  */
31 public class Flier {
32  /** List of added annotations */
33  private ArrayList<Annotation> addedAnnotations;
34  /** List of changed annotations */
35  private ArrayList<Annotation> editedAnnotations;
36  /** List of removed annotations */
37  private ArrayList<Annotation> removedAnnotations;
38  /** List of removed nested annotations (due attribute changes) */
39  private ArrayList<Annotation> removedNestedAnnotations;
40  /** List of automatically updated annotations */
41  private ArrayList<Annotation> autoUpdatedAnnotations;
42 
43  /** List of added annotation types */
44  private ArrayList<AnnotType> addedTypes;
45  /** List of changed annotation types */
46  private ArrayList<AnnotType> editedTypes;
47  /** List of removed annotation types */
48  private ArrayList<AnnotType> removedTypes;
49 
50  /** List of annotated document text modifications */
51  private ArrayList<TextModification> textModifications;
52  /** List of annotated document reverse text modifications */
53  private ArrayList<TextModification> reverseTextModifications;
54  /** Text modification set ID */
55  private int textModificationSetID;
56 
57  /** Id of session from which this flier originated */
58  private Long CreatedInSessId = null;
59  /** Session from which this flier originated */
61  /** List of newly added subscriptions */
62  ArrayList<Subscription> newSubscriptions = null;
63  /** List of changed subscriptions */
64  ArrayList<Subscription> changedSubscriptions = null;
65  /** Array of tmp and serv uri pairs of just added annotations */
66  private ArrayList<ArrayList<String>> justAddedAnnotations;
67 
68  /**
69  * Constructor (initialize arrays)
70  */
71  public Flier() {
72  this.addedAnnotations = new ArrayList<Annotation>();
73  this.editedAnnotations = new ArrayList<Annotation>();
74  this.removedAnnotations = new ArrayList<Annotation>();
75  this.removedNestedAnnotations = new ArrayList<Annotation>();
76  this.autoUpdatedAnnotations = new ArrayList<Annotation>();
77  this.addedTypes = new ArrayList<AnnotType>();
78  this.editedTypes = new ArrayList<AnnotType>();
79  this.removedTypes = new ArrayList<AnnotType>();
80  this.textModifications = new ArrayList<TextModification>();
81  this.reverseTextModifications = new ArrayList<TextModification>();
82  this.newSubscriptions = new ArrayList<Subscription>();
83  this.changedSubscriptions = new ArrayList<Subscription>();
84  this.justAddedAnnotations = new ArrayList<ArrayList<String>>();
85  }
86 
87  /**
88  * Gets list of added annotations
89  *
90  * @return Returns list of added annotations
91  */
92  public ArrayList<Annotation> getAddedAnnotations() {
93  return addedAnnotations;
94  }
95 
96  /**
97  * Gets list of added annotation types
98  *
99  * @return Returns list of added annotation types
100  */
101  public ArrayList<AnnotType> getAddedTypes() {
102  return addedTypes;
103  }
104 
105  /**
106  * Gets list of changed annotations
107  *
108  * @return Returns list of changed annotations
109  */
110  public ArrayList<Annotation> getEditedAnnotations() {
111  return editedAnnotations;
112  }
113 
114  /**
115  * Gets list of changed annotation types
116  *
117  * @return Returns list of changed annotation types
118  */
119  public ArrayList<AnnotType> getEditedTypes() {
120  return editedTypes;
121  }
122 
123  /**
124  * Gets list of removed annotations
125  *
126  * @return Returns list of removed annotations
127  */
128  public ArrayList<Annotation> getRemovedAnnotations() {
129  return removedAnnotations;
130  }
131 
132  /**
133  * Gets list of removed nested annotations (due attribute changes)
134  *
135  * @return Returns list of removed nested annotations
136  */
137  public ArrayList<Annotation> getRemovedNestedAnnotations() {
139  }
140 
141  /**
142  * Gets list of removed annotation types
143  *
144  * @return Returns list of removed annotation types
145  */
146  public ArrayList<AnnotType> getRemovedTypes() {
147  return removedTypes;
148  }
149 
150  /**
151  * Gets list of annotated document text modifications
152  *
153  * @return Returns list of annotated document text modifications
154  */
155  public ArrayList<TextModification> getTextModifications() {
156  return textModifications;
157  }
158 
159  /**
160  * Gets list of annotated document reverse text modifications
161  *
162  * @return Returns list of annotated document reverse text modifications
163  */
164  public ArrayList<TextModification> getReverseTextModifications() {
166  }
167 
168  /**
169  * Adds added annotation to the list
170  *
171  * @param annotation Added annotation
172  */
173  public void AddAddedAnnotation(Annotation annotation) {
174  addedAnnotations.add(annotation);
175  }
176 
177  /**
178  * Sets added annotations
179  *
180  * @param annotations Added annotations in list
181  */
182  public void setAddedAnnotations(ArrayList<Annotation> annotations) {
183  addedAnnotations = annotations;
184  }
185 
186  /**
187  * Adds changed annotation to the list
188  *
189  * @param annotation Changed annotation
190  */
191  public void AddEditedAnnotation(Annotation annotation) {
192  editedAnnotations.add(annotation);
193  }
194 
195  /**
196  * Adds removed annotation to the list
197  *
198  * @param annotation Removed annotation
199  */
200  public void AddRemovedAnnotation(Annotation annotation) {
201  removedAnnotations.add(annotation);
202  }
203 
204  /**
205  * Adds removed nested annotation to the list
206  *
207  * @param annotation Removed nested annotation
208  */
209  public void AddRemovedNestedAnnotation(Annotation annotation) {
210  removedNestedAnnotations.add(annotation);
211  }
212 
213  /**
214  * Gets list of automatically updated annotations
215  *
216  * @return Returns list of automatically updated annotations
217  */
218  public ArrayList<Annotation> getAutoUpdatedAnnotations() {
219  return autoUpdatedAnnotations;
220  }
221 
222  /**
223  * Sets list of automatically updated annotations
224  *
225  * @param autoUpdatedAnnotations List of automatically updated annotations
226  */
227  public void setAutoUpdatedAnnotations(ArrayList<Annotation> autoUpdatedAnnotations) {
228  this.autoUpdatedAnnotations = autoUpdatedAnnotations;
229  }
230 
231  /**
232  * Adds automatically updated annotation to the list
233  *
234  * @param autoUpdatedAnnotation Automatically updated annotation
235  */
236  public void addAutoUpdatedAnnotation(Annotation autoUpdatedAnnotation) {
237  this.autoUpdatedAnnotations.add(autoUpdatedAnnotation);
238  }
239 
240  /**
241  * Adds added annotation type to the list
242  *
243  * @param annotType Added annotation type
244  */
245  public void AddAddedType(AnnotType annotType) {
246  addedTypes.add(annotType);
247  }
248 
249  /**
250  * Adds changed annotation type to the list
251  *
252  * @param annotType Changed annotation type
253  */
254  public void AddEditedType(AnnotType annotType) {
255  editedTypes.add(annotType);
256  }
257 
258  /**
259  * Adds removed annotation type to the list
260  *
261  * @param annotType Removed annotation type
262  */
263  public void AddRemovedType(AnnotType annotType) {
264  removedTypes.add(annotType);
265  }
266 
267  /**
268  * Adds annotated document text modification to the list
269  *
270  * @param modification Annotated document text modification
271  */
272  public void AddTextModification(TextModification modification) {
273  textModifications.add(modification);
274  }
275 
276 
277  /**
278  * Sets the list of annotated document text modifications
279  *
280  * @param textModifications List of annotated document text modifications
281  */
282  public void setTextModifications(ArrayList<TextModification> textModifications) {
283  this.textModifications = textModifications;
284  }
285 
286  /**
287  * Sets the list of annotated document reverse text modifications
288  *
289  * @param reverseTextModifications List of annotated document reverse text modifications
290  */
291  public void setReverseTextModifications(ArrayList<TextModification> reverseTextModifications) {
292  this.reverseTextModifications = reverseTextModifications;
293  }
294 
295  /**
296  * Gets id of session from which this flier originated
297  *
298  * @return Returns id of session from which this flier originated
299  */
300  public Long getCreatedInSessId() {
301  return CreatedInSessId;
302  }
303 
304  /**
305  * Sets id of session from which this flier originated
306  *
307  * @param CreatedInSessId Id of session from which this flier originated
308  */
310  this.CreatedInSessId = CreatedInSessId;
311  }
312 
313  /**
314  * Gets session from which this flier originated
315  *
316  * @return Returns session from which this flier originated
317  */
319  return CreatedInSession;
320  }
321 
322  /**
323  * Sets session from which this flier originated
324  *
325  * @param CreatedInSession Session from which this flier originated
326  */
328  this.CreatedInSession = CreatedInSession;
329  }
330 
331  /**
332  * Gets list of newly added subscriptions
333  *
334  * @return Returns list of newly added subscriptions
335  */
336  public ArrayList<Subscription> getNewSubscriptions() {
337  return newSubscriptions;
338  }
339 
340  /**
341  * Adds new subscription into list of newly added subscriptions
342  *
343  * @param newSubscription New subscription to add
344  */
345  public void addNewSubscription(Subscription newSubscription) {
346  this.newSubscriptions.add(newSubscription);
347  }
348 
349  /**
350  * Sets list of newly added subscriptions
351  *
352  * @param newSubscriptions List of newly added subscriptions
353  */
354  public void setNewSubscriptions(ArrayList<Subscription> newSubscriptions) {
355  this.newSubscriptions = newSubscriptions;
356  }
357 
358  /**
359  * Gets list of changed subscriptions.
360  *
361  * @return list of changed subscriptions
362  */
363  public ArrayList<Subscription> getChangedSubscriptions() {
364  return changedSubscriptions;
365  }
366 
367  /**
368  * Set list of changed subscriptions.
369  *
370  * @param changedSubscriptions list of changed subscriptions
371  */
372  public void setChangedSubscriptions(ArrayList<Subscription> changedSubscriptions) {
373  this.changedSubscriptions = changedSubscriptions;
374  }
375 
376  /**
377  * Adds changed subscription into list of changed subscriptions.
378  *
379  * @param changedSubscription changed suscription to add
380  */
381  public void addChangedSubscription(Subscription changedSubscription) {
382  this.changedSubscriptions.add(changedSubscription);
383  }
384 
385  /**
386  * Sets list of changed annotations
387  *
388  * @param editedAnnotations List of changed annotations
389  */
390  public void setEditedAnnotations(ArrayList<Annotation> editedAnnotations) {
391  this.editedAnnotations = editedAnnotations;
392  }
393 
394  /**
395  * Sets text modification set ID
396  *
397  * @param id Text modification set ID
398  */
399  public void setTextModificationSetID(int id){
400  this.textModificationSetID = id;
401  }
402 
403  /**
404  * Gets text modification set ID
405  *
406  * @return Returns text modification set ID
407  */
409  return this.textModificationSetID;
410  }
411 
412  /**
413  * Add pair of uris for just added annotation to list.
414  *
415  * @param tmpUri temporary uri of just added annotation
416  * @param serverUri server uri of just added annotation
417  */
418  public void addJustAddedAnnotation(String tmpUri, String serverUri){
419  ArrayList<String> justAddedAnnot = new ArrayList<String>(2);
420  justAddedAnnot.add(tmpUri);
421  justAddedAnnot.add(serverUri);
422 
423  this.justAddedAnnotations.add(justAddedAnnot);
424  }
425 
426  /**
427  * Delete pair of uris of just added annotation from list.
428  *
429  * @param serverUri server uri of searched couple
430  */
431  public void deleteTmpUri(String serverUri){
432  Iterator<ArrayList<String>> addedIt = justAddedAnnotations.iterator();
433  while(addedIt.hasNext()){
434  ArrayList<String> addedAnnot = addedIt.next();
435  if(addedAnnot.get(1).equals(serverUri)){
436  String result = addedAnnot.get(0);
437  addedIt.remove();
438  }
439  }
440  }
441 
442  /**
443  * Finds temporary uri of just added annotation according to server uri.
444  *
445  * @param serverUri server uri of searched couple
446  *
447  * @return temporary uri of annotation
448  */
449  public String getTmpUri(String serverUri){
450  Iterator<ArrayList<String>> addedIt = justAddedAnnotations.iterator();
451  while(addedIt.hasNext()){
452  ArrayList<String> addedAnnot = addedIt.next();
453  if(addedAnnot.get(1).equals(serverUri)){
454  String result = addedAnnot.get(0);
455  return result;
456  }
457  }
458 
459  return null;
460  }
461 
462  /**
463  * Tests if there is pair with given server uri.
464  *
465  * @param serverUri server uri of searched couple
466  *
467  * @return true if found, false otherwise
468  */
469  public boolean isInJustAdded(String serverUri){
470  Iterator<ArrayList<String>> addedIt = justAddedAnnotations.iterator();
471  while(addedIt.hasNext()){
472  ArrayList<String> addedAnnot = addedIt.next();
473  if(addedAnnot.get(1).equals(serverUri)){
474  return true;
475  }
476  }
477 
478  return false;
479  }
480 
481 } // class Flier
ArrayList< AnnotType > getEditedTypes()
Definition: Flier.java:119
ArrayList< Subscription > newSubscriptions
Definition: Flier.java:62
boolean isInJustAdded(String serverUri)
Definition: Flier.java:469
ArrayList< TextModification > getReverseTextModifications()
Definition: Flier.java:164
ArrayList< Annotation > removedAnnotations
Definition: Flier.java:37
ArrayList< AnnotType > addedTypes
Definition: Flier.java:44
String getTmpUri(String serverUri)
Definition: Flier.java:449
void AddRemovedNestedAnnotation(Annotation annotation)
Definition: Flier.java:209
void setAutoUpdatedAnnotations(ArrayList< Annotation > autoUpdatedAnnotations)
Definition: Flier.java:227
void setEditedAnnotations(ArrayList< Annotation > editedAnnotations)
Definition: Flier.java:390
ArrayList< ArrayList< String > > justAddedAnnotations
Definition: Flier.java:66
ArrayList< TextModification > textModifications
Definition: Flier.java:51
void AddTextModification(TextModification modification)
Definition: Flier.java:272
ArrayList< Annotation > getAutoUpdatedAnnotations()
Definition: Flier.java:218
void AddRemovedType(AnnotType annotType)
Definition: Flier.java:263
void deleteTmpUri(String serverUri)
Definition: Flier.java:431
void AddEditedType(AnnotType annotType)
Definition: Flier.java:254
ArrayList< Annotation > getEditedAnnotations()
Definition: Flier.java:110
void setChangedSubscriptions(ArrayList< Subscription > changedSubscriptions)
Definition: Flier.java:372
Class representing type of annotation.
Definition: AnnotType.java:58
ArrayList< Annotation > getAddedAnnotations()
Definition: Flier.java:92
void setTextModifications(ArrayList< TextModification > textModifications)
Definition: Flier.java:282
Class representing modification of annotated document text.
ArrayList< Subscription > getChangedSubscriptions()
Definition: Flier.java:363
void addChangedSubscription(Subscription changedSubscription)
Definition: Flier.java:381
Flier with informations for comet handlers.
Definition: Flier.java:31
ArrayList< Subscription > changedSubscriptions
Definition: Flier.java:64
void AddEditedAnnotation(Annotation annotation)
Definition: Flier.java:191
void setAddedAnnotations(ArrayList< Annotation > annotations)
Definition: Flier.java:182
void setCreatedInSession(EditorSession CreatedInSession)
Definition: Flier.java:327
ArrayList< TextModification > getTextModifications()
Definition: Flier.java:155
void addNewSubscription(Subscription newSubscription)
Definition: Flier.java:345
void setNewSubscriptions(ArrayList< Subscription > newSubscriptions)
Definition: Flier.java:354
ArrayList< AnnotType > editedTypes
Definition: Flier.java:46
void addJustAddedAnnotation(String tmpUri, String serverUri)
Definition: Flier.java:418
ArrayList< Annotation > getRemovedAnnotations()
Definition: Flier.java:128
ArrayList< Annotation > addedAnnotations
Definition: Flier.java:33
ArrayList< Annotation > autoUpdatedAnnotations
Definition: Flier.java:41
void setCreatedInSessId(long CreatedInSessId)
Definition: Flier.java:309
ArrayList< Subscription > getNewSubscriptions()
Definition: Flier.java:336
ArrayList< Annotation > editedAnnotations
Definition: Flier.java:35
ArrayList< TextModification > reverseTextModifications
Definition: Flier.java:53
ArrayList< AnnotType > getRemovedTypes()
Definition: Flier.java:146
Informations about client session.
void setReverseTextModifications(ArrayList< TextModification > reverseTextModifications)
Definition: Flier.java:291
ArrayList< AnnotType > getAddedTypes()
Definition: Flier.java:101
ArrayList< Annotation > removedNestedAnnotations
Definition: Flier.java:39
ArrayList< AnnotType > removedTypes
Definition: Flier.java:48
void AddAddedAnnotation(Annotation annotation)
Definition: Flier.java:173
void AddRemovedAnnotation(Annotation annotation)
Definition: Flier.java:200
void addAutoUpdatedAnnotation(Annotation autoUpdatedAnnotation)
Definition: Flier.java:236
void AddAddedType(AnnotType annotType)
Definition: Flier.java:245
ArrayList< Annotation > getRemovedNestedAnnotations()
Definition: Flier.java:137