Dépôt officiel du code source de l'ERP OpenConcerto
Rev 156 | Rev 182 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.erp.core.edm;
import org.openconcerto.sql.model.SQLRowValues;
import java.io.File;
import java.io.Serializable;
public class Attachment implements Serializable {
private final int id;
private String name;
private String mimeType;
private String fileName;
private int fileSize;
private String storagePath;
private String storageFileName;
private String sourceTable;
private int sourceId;
private int parentId;
private boolean encrypted;
public static final String MIMETYPE_FOLDER = "inode/directory";
public Attachment(SQLRowValues rowAttachment) {
this.id = rowAttachment.getID();
this.name = rowAttachment.getString("NAME");
this.mimeType = rowAttachment.getString("MIMETYPE");
this.fileName = rowAttachment.getString("FILENAME");
this.fileSize = rowAttachment.getInt("FILESIZE");
this.storagePath = rowAttachment.getString("STORAGE_PATH").replace('\\', File.separatorChar);
this.storageFileName = rowAttachment.getString("STORAGE_FILENAME");
this.sourceTable = rowAttachment.getString("SOURCE_TABLE");
this.sourceId = rowAttachment.getInt("SOURCE_ID");
this.parentId = rowAttachment.getInt("ID_PARENT");
this.encrypted = rowAttachment.getBoolean("ENCRYPTED");
}
public int getId() {
return this.id;
}
public String getName() {
return this.name;
}
public void setName(String newName) {
this.name = newName;
}
public String getMimeType() {
return this.mimeType;
}
public String getFileName() {
return this.fileName;
}
public int getFileSize() {
return this.fileSize;
}
public String getStorageFileName() {
return this.storageFileName;
}
public String getStoragePath() {
return this.storagePath;
}
public String getSourceTable() {
return this.sourceTable;
}
public int getSourceId() {
return this.sourceId;
}
public int getParentId() {
return this.parentId;
}
public boolean isFolder() {
return this.mimeType.equals(MIMETYPE_FOLDER);
}
public boolean isEncrypted() {
return this.encrypted;
}
@Override
public String toString() {
return super.toString() + " attachment id:" + this.getId() + " name:" + this.getName();
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (this.getClass() != obj.getClass())
return false;
return this.getId() == ((Attachment) obj).getId();
}
@Override
public int hashCode() {
return getId();
}
}