OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Rev 182 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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