Package org.compiere.model
Class MAttachment
java.lang.Object
org.compiere.model.PO
org.compiere.model.X_AD_Attachment
org.compiere.model.MAttachment
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparator<Object>
,I_AD_Attachment
,I_Persistent
,Evaluatee
Attachment Model.
One Attachment can have multiple entries (usually stored as zip files).
- Version:
- $Id: MAttachment.java,v 1.4 2006/07/30 00:58:37 jjanke Exp $
- Author:
- Jorg Janke, Silvano Trinchero
- BF [ 2992291] MAttachment.addEntry not closing streams if an exception occur https://sourceforge.net/p/adempiere/bugs/2392/
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfinal String
string replaces the attachment root in stored xml file to allow the changing of the attachment root.List of Entry Datastatic final String
Indicator for no datastatic final String
Indicator for xml data (store on file system)static final String
Indicator for zip dataFields inherited from class org.compiere.model.PO
ACCESSLEVEL_ALL, ACCESSLEVEL_CLIENT, ACCESSLEVEL_CLIENTORG, ACCESSLEVEL_ORG, ACCESSLEVEL_SYSTEM, ACCESSLEVEL_SYSTEMCLIENT, ENTITYTYPE_Dictionary, ENTITYTYPE_UserMaintained, I_ZERO, LOCAL_TRX_PREFIX, log, p_ctx, p_info, UUID_NEW_RECORD, XML_ATTRIBUTE_AD_Table_ID, XML_ATTRIBUTE_Record_ID
Fields inherited from interface org.compiere.model.I_AD_Attachment
accessLevel, COLUMNNAME_AD_Attachment_ID, COLUMNNAME_AD_Attachment_UU, COLUMNNAME_AD_Client_ID, COLUMNNAME_AD_Org_ID, COLUMNNAME_AD_StorageProvider_ID, COLUMNNAME_AD_Table_ID, COLUMNNAME_BinaryData, COLUMNNAME_Created, COLUMNNAME_CreatedBy, COLUMNNAME_IsActive, COLUMNNAME_Record_ID, COLUMNNAME_Record_UU, COLUMNNAME_TextMsg, COLUMNNAME_Title, COLUMNNAME_Updated, COLUMNNAME_UpdatedBy, Model, Table_ID, Table_Name
-
Constructor Summary
ConstructorDescriptionMAttachment
(Properties ctx, int AD_Table_ID, int Record_ID, String trxName) Deprecated.MAttachment
(Properties ctx, int AD_Table_ID, int Record_ID, String Record_UU, String trxName) MAttachment
(Properties ctx, int AD_Attachment_ID, String trxName) Standard ConstructorMAttachment
(Properties ctx, String AD_Attachment_UU, String trxName) UUID based ConstructorMAttachment
(Properties ctx, ResultSet rs, String trxName) Load ConstructorMAttachment
(MAttachment copy) Copy constructor -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add new item to attachmentboolean
Add new item to attachmentboolean
addEntry
(MAttachmentEntry item) Add item to attachmentvoid
addTextMsg
(String added) Add to Text Msgprotected boolean
beforeSave
(boolean newRecord) Before Saveboolean
deleteEntry
(int index) Delete Entryvoid
Dump Entry Names to standard outstatic MAttachment
get
(Properties ctx, int AD_Table_ID, int Record_ID) static MAttachment
get
(Properties ctx, int AD_Table_ID, int Record_ID, String trxName) Get Attachment (if there are more than one attachment, it gets the first in no specific order)static MAttachment
get
(Properties ctx, int AD_Table_ID, int Record_ID, String Record_UU, String trxName) Get Attachment (if there are more than one attachment, it gets the first in no specific order)Get Attachment Entries as arraygetEntry
(int index) Get Attachment Entryint
Get Entry Countbyte[]
getEntryData
(int index) Get Entry DatagetEntryFile
(int index, File file) Get Entry File with namegetEntryFile
(int index, String fileName) Get Entry File with namegetEntryName
(int index) Get Entry Namestatic int
Deprecated.UsegetID(int, int, String)
insteadstatic int
IDEMPIERE-530 Get the attachment ID based on table_id and record_uuGet Text Msgprotected boolean
Ask storage provider to remove attachment contentSave attachment as zip filevoid
setClientOrg
(int AD_Client_ID, int AD_Org_ID) Set Client Orgvoid
Set Storage Provider.toString()
String Representationboolean
updateEntry
(int i, byte[] data) Update existing entryboolean
updateEntry
(int i, File file) Update existing entryMethods inherited from class org.compiere.model.X_AD_Attachment
get_AccessLevel, getAD_Attachment_ID, getAD_Attachment_UU, getAD_StorageProvider, getAD_StorageProvider_ID, getAD_Table, getAD_Table_ID, getBinaryData, getKeyNamePair, getRecord_ID, getRecord_UU, getTitle, initPO, setAD_Attachment_ID, setAD_Attachment_UU, setAD_StorageProvider_ID, setAD_Table_ID, setBinaryData, setRecord_ID, setRecord_UU, setTextMsg, setTitle
Methods inherited from class org.compiere.model.PO
afterDelete, afterSave, beforeDelete, buildInsertSQL, checkImmutable, clearCrossTenantSafe, clone, columnExists, columnExists, compare, copyPO, copyValues, copyValues, createAttachment, delete, delete, delete_Accounting, delete_Tree, deleteEx, deleteEx, dump, dump, equals, get_Attribute, get_Attributes, get_ColumnCount, get_ColumnDescription, get_ColumnDisplayType, get_ColumnIndex, get_ColumnLabel, get_ColumnLookup, get_ColumnName, get_DisplayValue, get_HashMap, get_ID, get_IDOld, get_KeyColumns, get_Logger, get_OptimisticLockingColumns, get_Table_ID, get_TableName, get_Translation, get_Translation, get_Translation, get_Translation, get_Translation, get_TrxName, get_UUID, get_Value, get_Value, get_ValueAsBoolean, get_ValueAsInt, get_ValueAsInt, get_ValueAsString, get_ValueAsString, get_ValueDifference, get_ValueDifference, get_ValueE, get_ValueOfColumn, get_ValueOld, get_ValueOld, get_ValueOldAsInt, get_WhereClause, get_WhereClause, get_xmlDocument, get_xmlString, getAD_Client_ID, getAD_Org_ID, getAllIDs, getAttachment, getAttachment, getAttachmentData, getCreated, getCreatedBy, getCtx, getDoc, getFindParameter, getPdfAttachment, getUpdated, getUpdatedBy, getUUIDColumnName, getUUIDColumnName, hashCode, insert_Accounting, insert_Tree, insert_Tree, is_Changed, is_Immutable, is_new, is_UseOptimisticLocking, is_ValueChanged, is_ValueChanged, isActive, isAttachment, isColumnMandatory, isColumnUpdateable, isMandatoryOK, isPdfAttachment, isReplication, load, load, load, load, loadByUU, loadComplete, loadDefaults, loadPO, loadSpecial, lock, makeImmutable, retrieveIdOfParentValue, retrieveIdOfParentValue, save, save, saveCrossTenantSafe, saveCrossTenantSafeEx, saveCrossTenantSafeEx, saveEx, saveEx, saveNew_afterSetID, saveNew_getID, saveNewSpecial, saveReplica, saveUpdate, set_Attribute, set_ColumnUpdateable, set_CustomColumn, set_CustomColumnReturningBoolean, set_OptimisticLockingColumns, set_TrxName, set_TrxName, set_UseOptimisticLocking, set_Value, set_Value, set_Value, set_Value, set_ValueE, set_ValueNoCheck, set_ValueNoCheckE, set_ValueOfColumn, set_ValueOfColumn, set_ValueOfColumnReturningBoolean, set_ValueOfColumnReturningBoolean, setAD_Client_ID, setAD_Org_ID, setClientOrg, setCrossTenantSafe, setDoc, setDocWorkflowMgr, setIsActive, setProcessedOn, setReplication, setStandardDefaults, setUpdateable, setUpdatedBy, toInsertSQL, unlock, update_Tree, validForeignKeys
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
Methods inherited from interface org.compiere.model.I_AD_Attachment
getAD_Client_ID, getAD_Org_ID, getCreated, getCreatedBy, getUpdated, getUpdatedBy, isActive, setAD_Org_ID, setIsActive
Methods inherited from interface org.compiere.model.I_Persistent
save
-
Field Details
-
NONE
Indicator for no data- See Also:
-
ZIP
Indicator for zip data- See Also:
-
XML
Indicator for xml data (store on file system)- See Also:
-
m_items
List of Entry Data -
ATTACHMENT_FOLDER_PLACEHOLDER
string replaces the attachment root in stored xml file to allow the changing of the attachment root.- See Also:
-
-
Constructor Details
-
MAttachment
UUID based Constructor- Parameters:
ctx
- ContextAD_Attachment_UU
- UUID keytrxName
- Transaction
-
MAttachment
Standard Constructor- Parameters:
ctx
- contextAD_Attachment_ID
- idtrxName
- transaction
-
MAttachment
Deprecated.- Parameters:
ctx
- contextAD_Table_ID
- tableRecord_ID
- recordtrxName
- transaction
-
MAttachment
public MAttachment(Properties ctx, int AD_Table_ID, int Record_ID, String Record_UU, String trxName) - Parameters:
ctx
- contextAD_Table_ID
- tableRecord_ID
- recordRecord_UU
- record UUIDtrxName
- transaction
-
MAttachment
Load Constructor- Parameters:
ctx
- contextrs
- result settrxName
- transaction
-
MAttachment
Copy constructor- Parameters:
copy
-
-
-
Method Details
-
get
- Parameters:
ctx
-AD_Table_ID
-Record_ID
-- Returns:
- attachment or null
-
get
Get Attachment (if there are more than one attachment, it gets the first in no specific order)- Parameters:
ctx
- contextAD_Table_ID
- tableRecord_ID
- recordtrxName
-- Returns:
- attachment or null
-
get
public static MAttachment get(Properties ctx, int AD_Table_ID, int Record_ID, String Record_UU, String trxName) Get Attachment (if there are more than one attachment, it gets the first in no specific order)- Parameters:
ctx
- contextAD_Table_ID
- tableRecord_ID
- recordRecord_UU
- record UUIDtrxName
-- Returns:
- attachment or null
-
setClientOrg
public void setClientOrg(int AD_Client_ID, int AD_Org_ID) Set Client Org- Overrides:
setClientOrg
in classPO
- Parameters:
AD_Client_ID
- clientAD_Org_ID
- org
-
addTextMsg
Add to Text Msg- Parameters:
added
- text
-
getTextMsg
Get Text Msg- Specified by:
getTextMsg
in interfaceI_AD_Attachment
- Overrides:
getTextMsg
in classX_AD_Attachment
- Returns:
- trimmed message
-
toString
String Representation- Overrides:
toString
in classX_AD_Attachment
- Returns:
- info
-
addEntry
Add new item to attachment- Parameters:
file
- file content of new item- Returns:
- true if added
-
addEntry
Add new item to attachment- Parameters:
name
- name of new itemdata
- data content of new item- Returns:
- true if added
-
addEntry
Add item to attachment- Parameters:
item
- attachment entry- Returns:
- true if added
-
getEntry
Get Attachment Entry- Parameters:
index
- index of the item- Returns:
- Entry or null
-
getEntries
Get Attachment Entries as array- Returns:
- array of attachment item or null
-
deleteEntry
public boolean deleteEntry(int index) Delete Entry- Parameters:
index
- index of item to delete- Returns:
- true if deleted
-
getEntryCount
public int getEntryCount()Get Entry Count- Returns:
- number of entries
-
getEntryName
Get Entry Name- Parameters:
index
- index of item- Returns:
- name or null
-
dumpEntryNames
public void dumpEntryNames()Dump Entry Names to standard out -
getEntryData
public byte[] getEntryData(int index) Get Entry Data- Parameters:
index
- index of item- Returns:
- data or null
-
getEntryFile
Get Entry File with name- Parameters:
index
- index of itemfileName
- optional file name- Returns:
- file or null
-
getEntryFile
Get Entry File with name- Parameters:
index
- index of itemfile
- file- Returns:
- file or null
-
beforeSave
protected boolean beforeSave(boolean newRecord) Before Save- Overrides:
beforeSave
in classPO
- Parameters:
newRecord
- new- Returns:
- true if can be saved
-
postDelete
protected boolean postDelete()Ask storage provider to remove attachment content- Overrides:
postDelete
in classPO
- Returns:
- true if saved
-
updateEntry
Update existing entry- Parameters:
i
- index of itemfile
- file content of item- Returns:
- true if success, false otherwise
-
updateEntry
public boolean updateEntry(int i, byte[] data) Update existing entry- Parameters:
i
- index of itemdata
- byte[] content of item- Returns:
- true if success, false otherwise
-
getID
Deprecated.UsegetID(int, int, String)
insteadIDEMPIERE-530 Get the attachment ID based on table_id and record_id- Parameters:
Table_ID
-Record_ID
-- Returns:
- AD_Attachment_ID
-
getID
IDEMPIERE-530 Get the attachment ID based on table_id and record_uu- Parameters:
Table_ID
-Record_ID
-Record_UU
- record UUID- Returns:
- AD_Attachment_ID
-
saveAsZip
Save attachment as zip file- Returns:
- zip file
-
setStorageProvider
Set Storage Provider. Used temporarily by the storage migration process to migrate storage provider.- Parameters:
p
- Storage provider
-
MAttachment(Properties, int, int, String, String)
instead