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 -
Method Summary
Modifier and TypeMethodDescriptionlongcount(long userId) Returns the number of typeTentities associated with the user.protected FilecreateFolder(long userId) protected abstract com.liferay.portal.kernel.dao.orm.ActionableDynamicQueryReturns anActionableDynamicQueryfor typeT.protected abstract String[]Returns names identifying fields on the typeTentity that contain the primary key of a user.byte[]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 typeTentities related to the user.protected Stringprotected com.liferay.portal.kernel.dao.orm.ActionableDynamicQuerygetActionableDynamicQuery(long userId) Returns anActionableDynamicQueryfor typeT.protected com.liferay.portal.kernel.zip.ZipWritergetZipWriter(long userId, String modelClassName, com.liferay.portal.kernel.zip.ZipWriterFactory zipWriterFactory) Returns aZipWriterto write the data to.protected abstract StringtoXmlString(T baseModel) Converts the typeTbase model to an XML string to be written to a file.protected voidwriteToZip(T baseModel, com.liferay.portal.kernel.zip.ZipWriter zipWriter) Converts the typeTbase model to a byte array and writes it to theZipWriter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.liferay.user.associated.data.component.UADComponent
getTypeClass, getTypeKeyMethods 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:UADExporterReturns the number of typeTentities associated with the user.- Specified by:
countin interfaceUADExporter<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
Description copied from interface:UADExporterReturns a byte array representing the entity, ready to be written to a file.- Specified by:
exportin interfaceUADExporter<T extends com.liferay.portal.kernel.model.BaseModel>- Parameters:
baseModel- the typeTentity 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:UADExporterReturns a file object containing the data from all typeTentities related to the user.- Specified by:
exportAllin interfaceUADExporter<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
-
doGetActionableDynamicQuery
protected abstract com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery doGetActionableDynamicQuery()Returns anActionableDynamicQueryfor typeT. This can be retrieved from the service.- Returns:
- an
ActionableDynamicQueryfor typeT
-
doGetUserIdFieldNames
Returns names identifying fields on the typeTentity that contain the primary key of a user.- Returns:
- the fields that may contain the primary key of a user
-
formatXML
-
getActionableDynamicQuery
protected com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery getActionableDynamicQuery(long userId) Returns anActionableDynamicQueryfor typeT. 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 theActionableDynamicQuery- 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 aZipWriterto write the data to. Each individual typeTentity is written as a file in the resulting ZIP file.- Parameters:
userId- the the primary key of the user whose data to exportmodelClassName- the string representation of the model class name- Returns:
- a
ZipWriterwhere each piece of data is written
-
toXmlString
Converts the typeTbase 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 typeTbase model to a byte array and writes it to theZipWriter.- Parameters:
baseModel- the baseModel to write to the ZIPzipWriter- theZipWriterto write to- Throws:
Exception- if an exception occurred
-