Class DynamicQueryUADExporter<T extends com.liferay.portal.kernel.model.BaseModel>

java.lang.Object
com.liferay.user.associated.data.exporter.DynamicQueryUADExporter<T>
All Implemented Interfaces:
UADComponent<T>, UADExporter<T>

public abstract class DynamicQueryUADExporter<T extends com.liferay.portal.kernel.model.BaseModel> extends Object implements UADExporter<T>
Provides the base implementation of UADExporter for entities generated with Service Builder. The count and batch actions are based on the ActionableDynamicQuery, which is available in the local service generated by Service Builder.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    count(long userId)
    Returns the number of type T entities associated with the user.
    protected File
    createFolder(long userId)
     
    protected abstract com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery
    Returns an ActionableDynamicQuery for type T.
    protected abstract String[]
    Returns names identifying fields on the type T entity that contain the primary key of a user.
    byte[]
    export(T baseModel)
    Returns a byte array representing the entity, ready to be written to a file.
    exportAll(long userId, com.liferay.portal.kernel.zip.ZipWriterFactory zipWriterFactory)
    Returns a file object containing the data from all type T entities related to the user.
    protected String
     
    protected com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery
    Returns an ActionableDynamicQuery for type T.
    protected com.liferay.portal.kernel.zip.ZipWriter
    getZipWriter(long userId, String modelClassName, com.liferay.portal.kernel.zip.ZipWriterFactory zipWriterFactory)
    Returns a ZipWriter to write the data to.
    protected abstract String
    toXmlString(T baseModel)
    Converts the type T base model to an XML string to be written to a file.
    protected void
    writeToZip(T baseModel, com.liferay.portal.kernel.zip.ZipWriter zipWriter)
    Converts the type T base model to a byte array and writes it to the ZipWriter.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.liferay.user.associated.data.component.UADComponent

    getTypeClass, getTypeKey

    Methods inherited from interface com.liferay.user.associated.data.exporter.UADExporter

    getExportDataCount
  • Constructor Details

    • DynamicQueryUADExporter

      public DynamicQueryUADExporter()
  • Method Details

    • count

      public long count(long userId) throws com.liferay.portal.kernel.exception.PortalException
      Description copied from interface: UADExporter
      Returns the number of type T entities associated with the user.
      Specified by:
      count in interface UADExporter<T extends com.liferay.portal.kernel.model.BaseModel>
      Parameters:
      userId - the primary key of the user whose data to count
      Returns:
      the number of entities associated with the user
      Throws:
      com.liferay.portal.kernel.exception.PortalException
    • export

      public byte[] export(T baseModel) throws com.liferay.portal.kernel.exception.PortalException
      Description copied from interface: UADExporter
      Returns a byte array representing the entity, ready to be written to a file.
      Specified by:
      export in interface UADExporter<T extends com.liferay.portal.kernel.model.BaseModel>
      Parameters:
      baseModel - the type T entity to convert into a byte array
      Returns:
      a byte array representing the given entity
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • exportAll

      public File exportAll(long userId, com.liferay.portal.kernel.zip.ZipWriterFactory zipWriterFactory) throws com.liferay.portal.kernel.exception.PortalException
      Description copied from interface: UADExporter
      Returns a file object containing the data from all type T entities related to the user.
      Specified by:
      exportAll in interface UADExporter<T extends com.liferay.portal.kernel.model.BaseModel>
      Parameters:
      userId - the primary key of the user whose data to export
      Returns:
      a file containing the exported data
      Throws:
      com.liferay.portal.kernel.exception.PortalException - if a portal exception occurred
    • createFolder

      protected File createFolder(long userId)
    • doGetActionableDynamicQuery

      protected abstract com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery doGetActionableDynamicQuery()
      Returns an ActionableDynamicQuery for type T. This can be retrieved from the service.
      Returns:
      an ActionableDynamicQuery for type T
    • doGetUserIdFieldNames

      protected abstract String[] doGetUserIdFieldNames()
      Returns names identifying fields on the type T entity that contain the primary key of a user.
      Returns:
      the fields that may contain the primary key of a user
    • formatXML

      protected String formatXML(String xml)
    • getActionableDynamicQuery

      protected com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery getActionableDynamicQuery(long userId)
      Returns an ActionableDynamicQuery for type T. It should be populated with criteria and ready for use by the service.
      Parameters:
      userId - the primary key of the user used to pre-filter the ActionableDynamicQuery
      Returns:
      a pre-filtered ActionableDynamicQuery
    • getZipWriter

      protected com.liferay.portal.kernel.zip.ZipWriter getZipWriter(long userId, String modelClassName, com.liferay.portal.kernel.zip.ZipWriterFactory zipWriterFactory)
      Returns a ZipWriter to write the data to. Each individual type T entity is written as a file in the resulting ZIP file.
      Parameters:
      userId - the the primary key of the user whose data to export
      modelClassName - the string representation of the model class name
      Returns:
      a ZipWriter where each piece of data is written
    • toXmlString

      protected abstract String toXmlString(T baseModel)
      Converts the type T base model to an XML string to be written to a file.
      Parameters:
      baseModel - the base model to be converted into an XML string
      Returns:
      an XML string representation of the base model
    • writeToZip

      protected void writeToZip(T baseModel, com.liferay.portal.kernel.zip.ZipWriter zipWriter) throws Exception
      Converts the type T base model to a byte array and writes it to the ZipWriter.
      Parameters:
      baseModel - the baseModel to write to the ZIP
      zipWriter - the ZipWriter to write to
      Throws:
      Exception - if an exception occurred