Salome HOME
Copyrights update 2015.
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / dto / FileDTO.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-2015
9  *****************************************************************************/
10
11 package org.splat.service.dto;
12
13 /**
14  * Document's file DTO.
15  */
16 public class FileDTO {
17
18         /**
19          * File persistent id.
20          */
21         private Long _id;
22         /**
23          * True if the file is a result file for a document.
24          */
25         private boolean _isResult; // RKV: NOPMD: isResult method is used as getter
26         /**
27          * File state: "Y" - actual, "O" - outdated, "N" - taken from other study.
28          */
29         private char _state;
30         /**
31          * Automatic processing instruction: "file-import", "file-download", etc.
32          */
33         private String _processing;
34         /**
35          * File path from the repository root.
36          */
37         private String _path;
38
39         /**
40          * Constructor with initialization.
41          * 
42          * @param id
43          *            file persistent id
44          * @param relativePath
45          *            relative file path
46          * @param state
47          *            file state
48          * @param processing
49          *            processing instruction: file-download or file-import
50          * @param isResult
51          *            true if the file is result
52          */
53         public FileDTO(final long id, final String relativePath, final char state,
54                         final String processing, final boolean isResult) {
55                 _id = id;
56                 _path = relativePath;
57                 _state = state;
58                 _processing = processing;
59                 _isResult = isResult;
60         }
61
62         /**
63          * Constructor with partial initialization.
64          * 
65          * @param relativePath
66          *            relative file path
67          */
68         public FileDTO(final String relativePath) {
69                 _path = relativePath;
70         }
71
72         /**
73          * Get the isResult.
74          * 
75          * @return the isResult
76          */
77         public boolean isResult() {
78                 return _isResult;
79         }
80
81         /**
82          * Set the isResult.
83          * 
84          * @param isResult
85          *            the isResult to set
86          */
87         public void setResult(final boolean isResult) {
88                 _isResult = isResult;
89         }
90
91         /**
92          * Get the state.
93          * 
94          * @return the state
95          */
96         public char getState() {
97                 return _state;
98         }
99
100         /**
101          * Set the state.
102          * 
103          * @param state
104          *            the state to set
105          */
106         public void setState(final char state) {
107                 _state = state;
108         }
109
110         /**
111          * Get the processing.
112          * 
113          * @return the processing
114          */
115         public String getProcessing() {
116                 return _processing;
117         }
118
119         /**
120          * Set the processing.
121          * 
122          * @param processing
123          *            the processing to set
124          */
125         public void setProcessing(final String processing) {
126                 _processing = processing;
127         }
128
129         /**
130          * Get the path.
131          * 
132          * @return the path
133          */
134         public String getPath() {
135                 return _path;
136         }
137
138         /**
139          * Set the path.
140          * 
141          * @param path
142          *            the path to set
143          */
144         public void setPath(final String path) {
145                 _path = path;
146         }
147
148         /**
149          * {@inheritDoc}
150          * 
151          * @see java.lang.Object#toString()
152          */
153         @Override
154         public String toString() {
155                 StringBuffer buf = new StringBuffer();
156                 String indent = "        ";
157                 String ftype = "Source";
158                 if (isResult()) {
159                         ftype = "Result";
160                 }
161                 String fstate = "file-actual";
162                 if (getState() == 'O') {
163                         fstate = "file-outdated";
164                 }
165                 buf.append(indent).append(ftype).append(" file: ").append(getPath())
166                                 .append('\n').append(indent).append("    File ID: ").append(
167                                                 getId()).append('\n').append(indent).append(
168                                                 "    Automatic processing: ").append(getProcessing())
169                                 .append('\n').append(indent).append("    State: ").append(
170                                                 fstate).append('\n');
171                 return buf.toString();
172         }
173
174         /**
175          * Get the id.
176          * 
177          * @return the id
178          */
179         public Long getId() {
180                 return _id;
181         }
182
183         /**
184          * Set the id.
185          * 
186          * @param id
187          *            the id to set
188          */
189         public void setId(final Long id) {
190                 _id = id;
191         }
192 }