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
public class MAttachment extends X_AD_Attachment
Attachment Model. One Attachment can have multiple entries- 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description StringATTACHMENT_FOLDER_PLACEHOLDERstring replaces the attachment root in stored xml file to allow the changing of the attachment root.ArrayList<MAttachmentEntry>m_itemsList of Entry Datastatic StringNONEIndicator for no datastatic StringXMLIndicator for xml data (store on file system)static StringZIPIndicator for zip data-
Fields 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, 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_TextMsg, COLUMNNAME_Title, COLUMNNAME_Updated, COLUMNNAME_UpdatedBy, Model, Table_ID, Table_Name
-
-
Constructor Summary
Constructors Constructor Description MAttachment(Properties ctx, int AD_Table_ID, int Record_ID, String trxName)New ConstructorMAttachment(Properties ctx, int AD_Attachment_ID, String trxName)Standard ConstructorMAttachment(Properties ctx, ResultSet rs, String trxName)Load ConstructorMAttachment(MAttachment copy)Copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddEntry(File file)Add new Data EntrybooleanaddEntry(String name, byte[] data)Add new Data EntrybooleanaddEntry(MAttachmentEntry item)Add EntryvoidaddTextMsg(String added)Add to Text Msgprotected booleanbeforeSave(boolean newRecord)Before SavebooleandeleteEntry(int index)Delete EntryvoiddumpEntryNames()Dump Entry Namesstatic MAttachmentget(Properties ctx, int AD_Table_ID, int Record_ID)static MAttachmentget(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)MAttachmentEntry[]getEntries()Get Attachment Entries as arrayMAttachmentEntrygetEntry(int index)Get Attachment EntryintgetEntryCount()Get Entry Countbyte[]getEntryData(int index)Get Entry DataFilegetEntryFile(int index, File file)Get Entry File with nameFilegetEntryFile(int index, String fileName)Get Entry File with nameStringgetEntryName(int index)Get Entry Namestatic intgetID(int Table_ID, int Record_ID)IDEMPIERE-530 Get the attachment ID based on table_id and record_idStringgetTextMsg()Get Text Msgstatic voidmain(String[] args)Testprotected booleanpostDelete()Delete Entry Data in Zip File formatFilesaveAsZip()voidsetClientOrg(int AD_Client_ID, int AD_Org_ID)Set Client OrgvoidsetStorageProvider(MStorageProvider p)Set Storage Provider Used temporarily for the process to migrate storage providerStringtoString()String RepresentationbooleanupdateEntry(int i, byte[] data)Update existing entrybooleanupdateEntry(int i, File file)Update existing entry-
Methods 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, getTitle, initPO, setAD_Attachment_ID, setAD_Attachment_UU, setAD_StorageProvider_ID, setAD_Table_ID, setBinaryData, setRecord_ID, setTextMsg, setTitle
-
Methods inherited from class org.compiere.model.PO
afterDelete, afterSave, beforeDelete, 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_Value, get_Value, get_ValueAsBoolean, get_ValueAsInt, get_ValueAsInt, 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, load, loadByUU, loadComplete, loadDefaults, loadSpecial, lock, makeImmutable, retrieveIdOfParentValue, retrieveIdOfParentValue, save, save, 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, 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 Detail
-
NONE
public static final String NONE
Indicator for no data- See Also:
- Constant Field Values
-
ZIP
public static final String ZIP
Indicator for zip data- See Also:
- Constant Field Values
-
XML
public static final String XML
Indicator for xml data (store on file system)- See Also:
- Constant Field Values
-
m_items
public ArrayList<MAttachmentEntry> m_items
List of Entry Data
-
ATTACHMENT_FOLDER_PLACEHOLDER
public final String ATTACHMENT_FOLDER_PLACEHOLDER
string replaces the attachment root in stored xml file to allow the changing of the attachment root.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MAttachment
public MAttachment(Properties ctx, int AD_Attachment_ID, String trxName)
Standard Constructor- Parameters:
ctx- contextAD_Attachment_ID- idtrxName- transaction
-
MAttachment
public MAttachment(Properties ctx, int AD_Table_ID, int Record_ID, String trxName)
New Constructor- Parameters:
ctx- contextAD_Table_ID- tableRecord_ID- recordtrxName- transaction
-
MAttachment
public MAttachment(Properties ctx, ResultSet rs, String trxName)
Load Constructor- Parameters:
ctx- contextrs- result settrxName- transaction
-
MAttachment
public MAttachment(MAttachment copy)
Copy constructor- Parameters:
copy-
-
-
Method Detail
-
get
public static MAttachment get(Properties ctx, int AD_Table_ID, int Record_ID)
- Parameters:
ctx-AD_Table_ID-Record_ID-- Returns:
- attachment or null
-
get
public 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)- Parameters:
ctx- contextAD_Table_ID- tableRecord_ID- recordtrxName-- Returns:
- attachment or null
-
setClientOrg
public void setClientOrg(int AD_Client_ID, int AD_Org_ID)Set Client Org- Overrides:
setClientOrgin classPO- Parameters:
AD_Client_ID- clientAD_Org_ID- org
-
addTextMsg
public void addTextMsg(String added)
Add to Text Msg- Parameters:
added- text
-
getTextMsg
public String getTextMsg()
Get Text Msg- Specified by:
getTextMsgin interfaceI_AD_Attachment- Overrides:
getTextMsgin classX_AD_Attachment- Returns:
- trimmed message
-
toString
public String toString()
String Representation- Overrides:
toStringin classX_AD_Attachment- Returns:
- info
-
addEntry
public boolean addEntry(File file)
Add new Data Entry- Parameters:
file- file- Returns:
- true if added
-
addEntry
public boolean addEntry(String name, byte[] data)
Add new Data Entry- Parameters:
name- namedata- data- Returns:
- true if added
-
addEntry
public boolean addEntry(MAttachmentEntry item)
Add Entry- Parameters:
item- attachment entry- Returns:
- true if added
-
getEntry
public MAttachmentEntry getEntry(int index)
Get Attachment Entry- Parameters:
index- index of the item- Returns:
- Entry or null
-
getEntries
public MAttachmentEntry[] getEntries()
Get Attachment Entries as array- Returns:
- array or null
-
deleteEntry
public boolean deleteEntry(int index)
Delete Entry- Parameters:
index- index- Returns:
- true if deleted
-
getEntryCount
public int getEntryCount()
Get Entry Count- Returns:
- number of entries
-
getEntryName
public String getEntryName(int index)
Get Entry Name- Parameters:
index- index- Returns:
- name or null
-
dumpEntryNames
public void dumpEntryNames()
Dump Entry Names
-
getEntryData
public byte[] getEntryData(int index)
Get Entry Data- Parameters:
index- index- Returns:
- data or null
-
getEntryFile
public File getEntryFile(int index, String fileName)
Get Entry File with name- Parameters:
index- indexfileName- optional file name- Returns:
- file
-
getEntryFile
public File getEntryFile(int index, File file)
Get Entry File with name- Parameters:
index- indexfile- file- Returns:
- file
-
beforeSave
protected boolean beforeSave(boolean newRecord)
Before Save- Overrides:
beforeSavein classPO- Parameters:
newRecord- new- Returns:
- true if can be saved
-
postDelete
protected boolean postDelete()
Delete Entry Data in Zip File format- Overrides:
postDeletein classPO- Returns:
- true if saved
-
main
public static void main(String[] args)
Test- Parameters:
args- ignored
-
updateEntry
public boolean updateEntry(int i, File file)Update existing entry- Parameters:
i-file-- Returns:
- true if success, false otherwise
-
updateEntry
public boolean updateEntry(int i, byte[] data)Update existing entry- Parameters:
i-data-- Returns:
- true if success, false otherwise
-
getID
public static int getID(int Table_ID, int Record_ID)IDEMPIERE-530 Get the attachment ID based on table_id and record_id- Parameters:
Table_ID-Record_ID-- Returns:
- AD_Attachment_ID
-
saveAsZip
public File saveAsZip()
-
setStorageProvider
public void setStorageProvider(MStorageProvider p)
Set Storage Provider Used temporarily for the process to migrate storage provider- Parameters:
p- Storage provider
-
-