Class MAttachment

    • Constructor Detail

      • MAttachment

        public MAttachment​(Properties ctx,
                           int AD_Attachment_ID,
                           String trxName)
        Standard Constructor
        Parameters:
        ctx - context
        AD_Attachment_ID - id
        trxName - transaction
      • MAttachment

        public MAttachment​(Properties ctx,
                           int AD_Table_ID,
                           int Record_ID,
                           String trxName)
        New Constructor
        Parameters:
        ctx - context
        AD_Table_ID - table
        Record_ID - record
        trxName - transaction
      • MAttachment

        public MAttachment​(Properties ctx,
                           ResultSet rs,
                           String trxName)
        Load Constructor
        Parameters:
        ctx - context
        rs - result set
        trxName - 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 - context
        AD_Table_ID - table
        Record_ID - record
        trxName -
        Returns:
        attachment or null
      • setClientOrg

        public void setClientOrg​(int AD_Client_ID,
                                 int AD_Org_ID)
        Set Client Org
        Overrides:
        setClientOrg in class PO
        Parameters:
        AD_Client_ID - client
        AD_Org_ID - org
      • addTextMsg

        public void addTextMsg​(String added)
        Add to Text Msg
        Parameters:
        added - text
      • 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 - name
        data - 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 - index
        fileName - optional file name
        Returns:
        file
      • getEntryFile

        public File getEntryFile​(int index,
                                 File file)
        Get Entry File with name
        Parameters:
        index - index
        file - file
        Returns:
        file
      • beforeSave

        protected boolean beforeSave​(boolean newRecord)
        Before Save
        Overrides:
        beforeSave in class PO
        Parameters:
        newRecord - new
        Returns:
        true if can be saved
      • postDelete

        protected boolean postDelete()
        Delete Entry Data in Zip File format
        Overrides:
        postDelete in class PO
        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