/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.dynamic.data.lists.exporter.impl; import aQute.bnd.annotation.ProviderType; import com.liferay.dynamic.data.lists.exporter.DDLExporter; import com.liferay.dynamic.data.lists.model.DDLRecord; import com.liferay.dynamic.data.mapping.model.DDMFormField; import com.liferay.dynamic.data.mapping.model.DDMStructure; import com.liferay.portal.kernel.dao.orm.QueryUtil; import com.liferay.portal.kernel.language.LanguageUtil; import com.liferay.portal.kernel.util.LocaleUtil; import com.liferay.portal.kernel.util.OrderByComparator; import com.liferay.portal.kernel.workflow.WorkflowConstants; import java.util.ArrayList; import java.util.List; import java.util.Locale; /** * @author Marcellus Tavares * @author Manuel de la Peña * @deprecated As of 1.1.0, with no direct replacement */ @Deprecated @ProviderType public abstract class BaseDDLExporter implements DDLExporter { @Override public byte[] export(long recordSetId) throws Exception { return doExport( recordSetId, WorkflowConstants.STATUS_ANY, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } @Override public byte[] export(long recordSetId, int status) throws Exception { return doExport( recordSetId, status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } @Override public byte[] export(long recordSetId, int status, int start, int end) throws Exception { return doExport(recordSetId, status, start, end, null); } @Override public byte[] export( long recordSetId, int status, int start, int end, OrderByComparator<DDLRecord> orderByComparator) throws Exception { return doExport(recordSetId, status, start, end, orderByComparator); } @Override public Locale getLocale() { if (_locale == null) { _locale = LocaleUtil.getSiteDefault(); } return _locale; } @Override public void setLocale(Locale locale) { _locale = locale; } protected abstract byte[] doExport( long recordSetId, int status, int start, int end, OrderByComparator<DDLRecord> orderByComparator) throws Exception; protected List<DDMFormField> getDDMFormFields(DDMStructure ddmStructure) throws Exception { List<DDMFormField> ddmFormFields = new ArrayList<>(); for (DDMFormField ddmFormField : ddmStructure.getDDMFormFields(false)) { ddmFormFields.add(ddmFormField); } return ddmFormFields; } protected String getStatusMessage(int status) { String statusLabel = WorkflowConstants.getStatusLabel(status); return LanguageUtil.get(_locale, statusLabel); } private Locale _locale; }