Salome HOME
Default document types mappings are moved from application settings (my.xml) to proje...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / dto / DocumentDTO.java
1 /*****************************************************************************
2  * Company         OPEN CASCADE
3  * Application     SIMAN
4  * File            $Id$ 
5  * Creation date   14.11.2012
6  * @author         $Author$
7  * @version        $Revision$
8  * @copyright      OPEN CASCADE 2012
9  *****************************************************************************/
10
11 package org.splat.service.dto;
12
13 import java.util.ArrayList;
14 import java.util.List;
15
16 /**
17  * Document DTO. This is a container of document files.
18  */
19 public class DocumentDTO {
20         /**
21          * Document persistent id.
22          */
23         private Long _id;
24         /**
25          * Document title.
26          */
27         private String _title;
28         /**
29          * List of document files.
30          */
31         private final List<FileDTO> _files = new ArrayList<FileDTO>(); // RKV: NOPMD: Access to the collection via getter
32
33         /**
34          * Constructor with initialization.
35          * 
36          * @param index
37          *            the document persistent id
38          * @param title
39          *            the document title
40          */
41         public DocumentDTO(final long index, final String title) {
42                 _id = index;
43                 _title = title;
44         }
45         
46         /**
47          * Default constructor.
48          */
49         public DocumentDTO() {
50         }
51
52         /**
53          * Get the files.
54          * 
55          * @return the files
56          */
57         public List<FileDTO> getFiles() {
58                 return _files;
59         }
60
61         /**
62          * Get the id.
63          * 
64          * @return the id
65          */
66         public Long getId() {
67                 return _id;
68         }
69
70         /**
71          * Set the id.
72          * 
73          * @param id
74          *            the id to set
75          */
76         public void setId(final Long id) {
77                 _id = id;
78         }
79
80         /**
81          * Get the title.
82          * 
83          * @return the title
84          */
85         public String getTitle() {
86                 return _title;
87         }
88
89         /**
90          * Set the title.
91          * 
92          * @param title
93          *            the title to set
94          */
95         public void setTitle(final String title) {
96                 _title = title;
97         }
98
99         /**
100          * Add a new file DTO.
101          * 
102          * @param relativePath
103          *            relative file path
104          * @param state
105          *            file state
106          * @param processing
107          *            processing instruction: file-download or file-import
108          * @param isResult
109          *            true if the file is result
110          * @return the added file DTO
111          */
112         public FileDTO addFile(final String relativePath, final char state,
113                         final String processing, final boolean isResult) {
114                 FileDTO fileDTO = new FileDTO(relativePath, state, processing, isResult);
115                 _files.add(fileDTO);
116                 return fileDTO;
117         }
118         
119         /**
120          * Add a new file DTO.
121          * @param file the file to be added.
122          **/
123         public void addFile(final FileDTO file) {
124                 _files.add(file);
125         }
126
127         /**
128          * {@inheritDoc}
129          * 
130          * @see java.lang.Object#toString()
131          */
132         @Override
133         public String toString() {
134                 StringBuffer buf = new StringBuffer();
135                 String indent = "    ";
136                 buf.append(indent).append("Document: ").append(getTitle()).append('\n')
137                                 .append(indent).append("Document ID: ").append(getId()).append(
138                                                 '\n');
139                 for (FileDTO file : getFiles()) {
140                         buf.append(file);
141                 }
142                 return buf.toString();
143         }
144 }