View Javadoc

1   /**
2    * 
3    */
4   package org.itracker.web.ptos;
5   
6   import java.util.ArrayList;
7   import java.util.Collections;
8   import java.util.List;
9   
10  import org.itracker.model.IssueAttachment;
11  
12  /**
13   * Class represents ListAttachmentsPTO.
14   * 
15   * @author Anton Kozak
16   */
17  public class ListAttachmentsPTO {
18  	boolean hasAttachments = false;
19      long sizeOfAllAttachments = 0;
20      List<IssueAttachment> attachments = new ArrayList<IssueAttachment>();
21      
22      /**
23  	 * @return the hasAttachments
24  	 */
25  	public boolean isHasAttachments() {
26  		return hasAttachments;
27  	}
28  	/**
29  	 * @param hasAttachments the hasAttachments to set
30  	 */
31  	public void setHasAttachments(boolean hasAttachments) {
32  		this.hasAttachments = hasAttachments;
33  	}
34  	/**
35  	 * @return the sizeOfAllAttachments
36  	 */
37  	public long getSizeOfAllAttachments() {
38  		return sizeOfAllAttachments;
39  	}
40  	/**
41  	 * @param sizeOfAllAttachments the sizeOfAllAttachments to set
42  	 */
43  	public void setSizeOfAllAttachments(long sizeOfAllAttachments) {
44  		this.sizeOfAllAttachments = sizeOfAllAttachments;
45  	}
46  	/**
47  	 * @return the attachments
48  	 */
49  	public List<IssueAttachment> getAttachments() {
50  		return attachments;
51  	}
52  	/**
53  	 * @param attachments the attachments to set
54  	 */
55  	public void setAttachments(List<IssueAttachment> attachments) {
56  		this.attachments = attachments;
57          if( attachments.size() > 0 ) {
58              hasAttachments = true;
59              Collections.sort(attachments, IssueAttachment.ID_COMPARATOR);
60              for (IssueAttachment issueAttachment : attachments) {
61                  sizeOfAllAttachments += issueAttachment.getSize();
62              }
63          }
64  	}
65  
66      
67  }