Class QMenuItemDownloadFile

java.lang.Object
com.kingsrook.qqq.backend.core.model.metadata.menus.items.QMenuItemBase
com.kingsrook.qqq.backend.core.model.metadata.menus.items.QMenuItemDownloadFile
All Implemented Interfaces:
QMenuItemInterface, QMetaDataObject, Serializable, Cloneable

public class QMenuItemDownloadFile extends QMenuItemBase
Menu item that triggers a file download from a field in the current record.

This menu item type is used to provide download functionality for file fields (BLOB fields) or URL fields in a table. When selected, it will download the file content from the specified field.

The label for this menu item can be automatically derived from the field's metadata if not explicitly set.

See Also:
  • Constructor Details

    • QMenuItemDownloadFile

      public QMenuItemDownloadFile()
      Default constructor.
    • QMenuItemDownloadFile

      public QMenuItemDownloadFile(String fieldName)
      Constructor that initializes the download file item with a field name.

      This constructor assumes the field belongs to the table that contains this menu item.

      Parameters:
      fieldName - the name of the field containing the file to download
    • QMenuItemDownloadFile

      public QMenuItemDownloadFile(QTableMetaData table, String fieldName)
      Constructor that initializes the download file item with a table and field name.
      Parameters:
      table - the table metadata containing the field (can be null if field is in the same table as the menu)
      fieldName - the name of the field containing the file to download
  • Method Details

    • getItemType

      public String getItemType()
      Returns the item type identifier for download file menu items.
      Returns:
      always returns "DOWNLOAD_FILE"
    • getValues

      public Map<String,Serializable> getValues()
      Returns the values map containing the field name for the download.
      Returns:
      a map containing the field name under the key "fieldName"
    • getLabel

      public String getLabel()
      Returns the label for this menu item, automatically deriving it from the field's metadata if not explicitly set.

      If no label has been set on this menu item, this method attempts to retrieve the label from the field's metadata and sets it automatically.

      Specified by:
      getLabel in interface QMenuItemInterface
      Overrides:
      getLabel in class QMenuItemBase
      Returns:
      the label for this menu item
      See Also:
    • validate

      public void validate(QInstanceValidator validator, QInstance qInstance, QMetaDataObject parentObject)
      Validates that the download file menu item has a valid field name and that the field exists in the table.

      Ensures that:

      • A label is set (either explicitly or derived from the field)
      • A field name is specified
      • The field exists in the table (if parent is a QTableMetaData)
      Parameters:
      validator - the validator instance to use for reporting errors
      qInstance - the QQQ instance being validated
      parentObject - the parent metadata object containing this menu item
    • getFieldName

      public String getFieldName()
      Getter for fieldName
      See Also:
    • setFieldName

      public void setFieldName(String fieldName)
      Setter for fieldName
      See Also:
    • withFieldName

      public QMenuItemDownloadFile withFieldName(String fieldName)
      Fluent setter for fieldName
      Parameters:
      fieldName - The field on the table holding this menu, that is either a BLOB, or a URL, which is what should be downloaded.
      Returns:
      this
    • clone

      public QMenuItemDownloadFile clone()
      Creates and returns a shallow copy of this download file menu item.
      Specified by:
      clone in interface QMenuItemInterface
      Overrides:
      clone in class QMenuItemBase
      Returns:
      a clone of this menu item