001
014
015 package com.liferay.portlet.dynamicdatalists.util;
016
017 import com.liferay.portal.kernel.dao.orm.QueryUtil;
018 import com.liferay.portal.kernel.language.LanguageUtil;
019 import com.liferay.portal.kernel.util.LocaleUtil;
020 import com.liferay.portal.kernel.util.OrderByComparator;
021 import com.liferay.portal.kernel.workflow.WorkflowConstants;
022
023 import java.util.Locale;
024
025
029 public abstract class BaseDDLExporter implements DDLExporter {
030
031 @Override
032 public byte[] export(long recordSetId) throws Exception {
033 return doExport(
034 recordSetId, WorkflowConstants.STATUS_ANY, QueryUtil.ALL_POS,
035 QueryUtil.ALL_POS, null);
036 }
037
038 @Override
039 public byte[] export(long recordSetId, int status) throws Exception {
040 return doExport(
041 recordSetId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
042 }
043
044 @Override
045 public byte[] export(long recordSetId, int status, int start, int end)
046 throws Exception {
047
048 return doExport(recordSetId, status, start, end, null);
049 }
050
051 @Override
052 public byte[] export(
053 long recordSetId, int status, int start, int end,
054 OrderByComparator orderByComparator)
055 throws Exception {
056
057 return doExport(recordSetId, status, start, end, orderByComparator);
058 }
059
060 @Override
061 public Locale getLocale() {
062 if (_locale == null) {
063 _locale = LocaleUtil.getSiteDefault();
064 }
065
066 return _locale;
067 }
068
069 @Override
070 public void setLocale(Locale locale) {
071 _locale = locale;
072 }
073
074 protected abstract byte[] doExport(
075 long recordSetId, int status, int start, int end,
076 OrderByComparator orderByComparator)
077 throws Exception;
078
079 protected String getStatusMessage(int status) {
080 String statusLabel = WorkflowConstants.getStatusLabel(status);
081
082 return LanguageUtil.get(_locale, statusLabel);
083 }
084
085 private Locale _locale;
086
087 }