OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
149 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.core.edm;
15
 
16
import org.openconcerto.sql.model.SQLRowValues;
17
 
18
import java.io.Serializable;
19
 
20
public class Attachment implements Serializable {
21
    private final int id;
22
    private String name;
23
    private String mimeType;
24
    private String fileName;
25
    private int fileSize;
26
    private String storagePath;
27
    private String storageFileName;
28
    private String sourceTable;
29
    private int sourceId;
30
    private int parentId;
31
 
32
    public static final String MIMETYPE_FOLDER = "inode/directory";
33
 
34
    public Attachment(SQLRowValues rowAttachment) {
35
        this.id = rowAttachment.getID();
36
        this.name = rowAttachment.getString("NAME");
37
        this.mimeType = rowAttachment.getString("MIMETYPE");
38
        this.fileName = rowAttachment.getString("FILENAME");
39
        this.fileSize = rowAttachment.getInt("FILESIZE");
40
        this.storagePath = rowAttachment.getString("STORAGE_PATH");
41
        this.storageFileName = rowAttachment.getString("STORAGE_FILENAME");
42
        this.sourceTable = rowAttachment.getString("SOURCE_TABLE");
43
        this.sourceId = rowAttachment.getInt("SOURCE_ID");
44
        this.parentId = rowAttachment.getInt("ID_PARENT");
45
    }
46
 
47
    public int getId() {
48
        return id;
49
    }
50
 
51
    public String getName() {
52
        return name;
53
    }
54
 
55
    public void setName(String newName) {
56
        this.name = newName;
57
    }
58
 
59
    public String getMimeType() {
60
        return mimeType;
61
    }
62
 
63
    public String getFileName() {
64
        return fileName;
65
    }
66
 
67
    public int getFileSize() {
68
        return fileSize;
69
    }
70
 
71
    public String getStorageFileName() {
72
        return storageFileName;
73
    }
74
 
75
    public String getStoragePath() {
76
        return storagePath;
77
    }
78
 
79
    public String getSourceTable() {
80
        return sourceTable;
81
    }
82
 
83
    public int getSourceId() {
84
        return sourceId;
85
    }
86
 
87
    public int getParentId() {
88
        return parentId;
89
    }
90
 
91
    public boolean isFolder() {
92
        return this.mimeType.equals(MIMETYPE_FOLDER);
93
    }
94
 
95
    @Override
96
    public String toString() {
97
        return super.toString() + " attachment id:" + this.getId() + " name:" + this.getName();
98
    }
99
 
100
    @Override
101
    public boolean equals(Object obj) {
102
        if (obj == null)
103
            return false;
104
 
105
        if (this.getClass() != obj.getClass())
106
            return false;
107
 
108
        return this.getId() == ((Attachment) obj).getId();
109
    }
110
 
111
    @Override
112
    public int hashCode() {
113
        return getId();
114
    }
115
}