com.liferay.journal.internal.trash.BaseJournalTrashHandler Maven / Gradle / Ivy
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.journal.internal.trash;
import com.liferay.journal.model.JournalArticle;
import com.liferay.journal.model.JournalFolder;
import com.liferay.journal.service.JournalArticleLocalServiceUtil;
import com.liferay.journal.service.JournalFolderLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.model.ContainerModel;
import com.liferay.portal.kernel.model.TrashedModel;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.trash.BaseTrashHandler;
import java.util.ArrayList;
import java.util.List;
/**
* @author Eudaldo Alonso
*/
public abstract class BaseJournalTrashHandler extends BaseTrashHandler {
@Override
public ContainerModel getContainerModel(long containerModelId)
throws PortalException {
return JournalFolderLocalServiceUtil.getFolder(containerModelId);
}
@Override
public String getContainerModelClassName(long classPK) {
return JournalFolder.class.getName();
}
@Override
public String getContainerModelName() {
return "folder";
}
@Override
public List getContainerModels(
long classPK, long parentContainerModelId, int start, int end)
throws PortalException {
List folders = JournalFolderLocalServiceUtil.getFolders(
getGroupId(classPK), parentContainerModelId, start, end);
List containerModels = new ArrayList<>(folders.size());
for (JournalFolder curFolder : folders) {
containerModels.add(curFolder);
}
return containerModels;
}
@Override
public int getContainerModelsCount(
long classPK, long parentContainerModelId)
throws PortalException {
return JournalFolderLocalServiceUtil.getFoldersCount(
getGroupId(classPK), parentContainerModelId);
}
@Override
public List getParentContainerModels(long classPK)
throws PortalException {
List containerModels = new ArrayList<>();
ContainerModel containerModel = getParentContainerModel(classPK);
if (containerModel == null) {
return containerModels;
}
containerModels.add(containerModel);
while (containerModel.getParentContainerModelId() > 0) {
containerModel = getContainerModel(
containerModel.getParentContainerModelId());
if (containerModel == null) {
break;
}
containerModels.add(containerModel);
}
return containerModels;
}
@Override
public String getRootContainerModelName() {
return "home";
}
@Override
public String getSubcontainerModelName() {
return "folder";
}
@Override
public String getTrashContainedModelName() {
return "article";
}
@Override
public int getTrashContainedModelsCount(long classPK)
throws PortalException {
JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK);
return JournalArticleLocalServiceUtil.getArticlesCount(
folder.getGroupId(), classPK, WorkflowConstants.STATUS_IN_TRASH);
}
@Override
public String getTrashContainerModelName() {
return "folders";
}
@Override
public int getTrashContainerModelsCount(long classPK)
throws PortalException {
JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK);
return JournalFolderLocalServiceUtil.getFoldersCount(
folder.getGroupId(), classPK, WorkflowConstants.STATUS_IN_TRASH);
}
@Override
public int getTrashModelsCount(long classPK) throws PortalException {
JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK);
return JournalFolderLocalServiceUtil.getFoldersAndArticlesCount(
folder.getGroupId(), classPK, WorkflowConstants.STATUS_IN_TRASH);
}
@Override
public List getTrashModelTrashedModels(
long classPK, int start, int end,
OrderByComparator> orderByComparator)
throws PortalException {
List trashedModels = new ArrayList<>();
JournalFolder folder = JournalFolderLocalServiceUtil.getFolder(classPK);
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy