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 TypeMethodDescriptionlong
count
(long userId) Returns the number of typeT
entities associated with the user.protected File
createFolder
(long userId) protected abstract com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery
Returns anActionableDynamicQuery
for typeT
.protected abstract String[]
Returns names identifying fields on the typeT
entity 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 typeT
entities related to the user.protected String
protected com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery
getActionableDynamicQuery
(long userId) Returns anActionableDynamicQuery
for typeT
.protected com.liferay.portal.kernel.zip.ZipWriter
getZipWriter
(long userId, String modelClassName, com.liferay.portal.kernel.zip.ZipWriterFactory zipWriterFactory) Returns aZipWriter
to write the data to.protected abstract String
toXmlString
(T baseModel) Converts the typeT
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 typeT
base 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, 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 typeT
entities associated with the user.- Specified by:
count
in 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:UADExporter
Returns a byte array representing the entity, ready to be written to a file.- Specified by:
export
in interfaceUADExporter<T extends com.liferay.portal.kernel.model.BaseModel>
- Parameters:
baseModel
- the typeT
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 typeT
entities related to the user.- Specified by:
exportAll
in 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 anActionableDynamicQuery
for typeT
. This can be retrieved from the service.- Returns:
- an
ActionableDynamicQuery
for typeT
-
doGetUserIdFieldNames
Returns names identifying fields on the typeT
entity 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 anActionableDynamicQuery
for 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 aZipWriter
to write the data to. Each individual typeT
entity 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
ZipWriter
where each piece of data is written
-
toXmlString
Converts the typeT
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 typeT
base model to a byte array and writes it to theZipWriter
.- Parameters:
baseModel
- the baseModel to write to the ZIPzipWriter
- theZipWriter
to write to- Throws:
Exception
- if an exception occurred
-