Skip to content

Commit

Permalink
LPD-44142 Provide FDS bulk action list serializers for system data se…
Browse files Browse the repository at this point in the history
…ts, with unit tests. Custom data sets don't yet support definition of bulk actions so we provide a placeholder implementation to facilitate reference handling in the renderer
  • Loading branch information
dsanz committed Jan 17, 2025
1 parent 7c0068c commit 24755a9
Show file tree
Hide file tree
Showing 4 changed files with 406 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* SPDX-FileCopyrightText: (c) 2025 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.frontend.data.set.action;

import com.liferay.frontend.data.set.model.FDSActionDropdownItem;
import com.liferay.frontend.data.set.serializer.FDSSerializer;

import java.util.List;

/**
* @author Daniel Sanz
*/
public interface FDSBulkActionListSerializer
extends FDSSerializer<List<FDSActionDropdownItem>> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* SPDX-FileCopyrightText: (c) 2025 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.frontend.data.set.internal.action;

import com.liferay.frontend.data.set.action.FDSBulkActionListSerializer;
import com.liferay.frontend.data.set.constants.FDSTypes;
import com.liferay.frontend.data.set.model.FDSActionDropdownItem;

import java.util.Collections;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.osgi.service.component.annotations.Component;

/**
* @author Daniel Sanz
*/
@Component(
property = "dataset.type=" + FDSTypes.CUSTOM,
service = FDSBulkActionListSerializer.class
)
public class CustomFDSBulkActionListSerializerImpl
implements FDSBulkActionListSerializer {

@Override
public List<FDSActionDropdownItem> serialize(
String fdsName, HttpServletRequest httpServletRequest) {

// TODO: add support for bulk actions in the DSM

return Collections.emptyList();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* SPDX-FileCopyrightText: (c) 2024 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.frontend.data.set.internal.action;

import com.liferay.frontend.data.set.action.FDSBulkActionList;
import com.liferay.frontend.data.set.action.FDSBulkActionListRegistry;
import com.liferay.frontend.data.set.action.FDSBulkActionListSerializer;
import com.liferay.frontend.data.set.constants.FDSTypes;
import com.liferay.frontend.data.set.model.FDSActionDropdownItem;

import java.util.Collections;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
* @author Daniel Sanz
*/
@Component(
property = "dataset.type=" + FDSTypes.SYSTEM,
service = FDSBulkActionListSerializer.class
)
public class SystemFDSBulkActionListSerializerImpl
implements FDSBulkActionListSerializer {

@Override
public List<FDSActionDropdownItem> serialize(
String fdsName, HttpServletRequest httpServletRequest) {

FDSBulkActionList fdsBulkActionList =
_fdsBulkActionListRegistry.getFDSBulkActionList(fdsName);

if (fdsBulkActionList == null) {
return Collections.emptyList();
}

return fdsBulkActionList.getFDSActionDropdownItems(httpServletRequest);
}

@Reference
private FDSBulkActionListRegistry _fdsBulkActionListRegistry;

}
Loading

0 comments on commit 24755a9

Please sign in to comment.