source: contrib/MailArchiver/sources/src/serpro/mailarchiver/service/dto/TFolder.java @ 6785

Revision 6785, 4.4 KB checked in by rafaelraymundo, 12 years ago (diff)

Ticket #2946 - Liberado codigo do MailArchiver?. Documentação na subpasta DOCS.

Line 
1/**
2 * MailArchiver is an application that provides services for storing and managing e-mail messages through a Web Services SOAP interface.
3 * Copyright (C) 2012  Marcio Andre Scholl Levien and Fernando Alberto Reuter Wendt and Jose Ronaldo Nogueira Fonseca Junior
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/******************************************************************************\
20*
21*  This product was developed by
22*
23*        SERVIÇO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO),
24*
25*  a government company established under Brazilian law (5.615/70),
26*  at Department of Development of Porto Alegre.
27*
28\******************************************************************************/
29
30package serpro.mailarchiver.service.dto;
31
32import javax.xml.bind.annotation.XmlRootElement;
33
34import serpro.mailarchiver.domain.metaarchive.Folder;
35import serpro.mailarchiver.domain.metaarchive.Message;
36
37@XmlRootElement(name="Folder")
38public class TFolder implements Identifiable {
39
40    private String id;
41    @Override
42    public String getId() { return id; }
43    @Override
44    public void setId(String id) { this.id = id; }
45
46    //--------------------------------------------------------------------------
47    private String name;
48    public String getName() { return name; }
49    public void setName(String name) { this.name = name; }
50
51    //--------------------------------------------------------------------------
52    private String path;
53    public String getPath() { return path; }
54    public void setPath(String path) { this.path = path; }
55
56    //--------------------------------------------------------------------------
57    private String parentId;
58    public String getParentId() { return parentId; }
59    public void setParentId(String parentId) { this.parentId = parentId; }
60
61    //--------------------------------------------------------------------------
62    private int folderCount;
63    public int getFolderCount() { return folderCount; }
64    public void setFolderCount(int folderCount) { this.folderCount = folderCount; }
65
66    //--------------------------------------------------------------------------
67    private int messageCount;
68    public int getMessageCount() { return messageCount; }
69    public void setMessageCount(int messageCount) { this.messageCount = messageCount; }
70
71    //--------------------------------------------------------------------------
72    private int unseenCount;
73    public int getUnseenCount() { return unseenCount; }
74    public void setUnseenCount(int unseenCount) { this.unseenCount = unseenCount; }
75
76    //==========================================================================
77    public TFolder() {}
78
79    public TFolder(Folder folder) {
80
81        id = folder.getExternalOid();
82
83        Folder parent = folder.getParent();
84        parentId = (parent != null) ? parent.getExternalOid() : null;
85
86        name = folder.getName();
87        path = folder.getRelativePath().toString().replace('\\', '/');
88        folderCount = folder.getChildren().size();
89        messageCount = folder.getMessages().size();
90
91        unseenCount = 0;
92        for(Message message : folder.getMessages()) {
93            if(message.isUnseen()) {
94                ++unseenCount;
95            }
96        }
97
98        //DEBUG
99        //System.out.println(toString());
100    }
101
102    @Override
103    public String toString() {
104        return String.format(
105                "TFolder%n"
106              + "%1$sid: %2$s%n"
107              + "%1$sname: %3$s%n"
108              + "%1$spath: %4$s%n"
109              + "%1$sparentId: %5$s%n"
110              + "%1$sfolderCount: %6$d%n"
111              + "%1$smessageCount: %7$d%n"
112              + "%1$sunseenCount: %8$d"
113              , "    "
114              , id
115              , name
116              , path
117              , parentId
118              , folderCount
119              , messageCount
120              , unseenCount);
121    }
122}
Note: See TracBrowser for help on using the repository browser.