Object List Operations

Content Type: Module
Categories: Utility

Overview

Enhance and streamline list manipulation within your Mendix applications with the Mendix List Operations module. This module provides a suite of Java actions designed to handle sorting, filtering, and modifying lists with ease and efficiency.

 

Java Actions

Sorting Actions

  • JA_List_MoveObjectToIndex - Moves an object to a specified index within the list.
  • JA_List_PerformSortingAction - Performs a sorting action on a specified object in the list.
  • JA_List_SanitizeSorting - Prepares a list for sorting actions by setting a numeric order.

Filtering Actions

  • JA_List_FilterChanged - Filters the list for objects that have been modified.
  • JA_List_FilterIfAttributeHasChanged - Filters the list for objects where specified attributes have changed.

List Manipulation Actions

  • JA_List_FlatListAssociations - Flattens hierarchical associations into a single list.
  • JA_List_GetObjectByIndex - Retrieves an object from the list based on its index.
  • JA_List_GetRandomObject - Randomly selects an object from the list.
  • JA_List_InsertObjectAtIndex - Inserts an object at a specified index within the list.
  • JA_List_JoinAttributeToASingleString - Compiles a string from the values of a specified attribute for each object in the list.
  • JA_List_Reverse - Reverses the order of the objects in the list.
  • JA_List_Shuffle - Randomly shuffles the positions of objects within the list.

Documentation

 

Mendix List Operations Module

Enhance and streamline list manipulation within your Mendix applications with the Mendix List Operations module. This module provides a suite of Java actions designed to handle sorting, filtering, and modifying lists with ease and efficiency.

 

Java Actions

Sorting Actions

  • JA_List_MoveObjectToIndex - Moves an object to a specified index within the list.
  • JA_List_PerformSortingAction - Performs a sorting action on a specified object in the list.
  • JA_List_SanitizeSorting - Prepares a list for sorting actions by setting a numeric order.

Filtering Actions

  • JA_List_FilterChanged - Filters the list for objects that have been modified.
  • JA_List_FilterIfAttributeHasChanged - Filters the list for objects where specified attributes have changed.

List Manipulation Actions

  • JA_List_FlatListAssociations - Flattens hierarchical associations into a single list.
  • JA_List_GetObjectByIndex - Retrieves an object from the list based on its index.
  • JA_List_GetRandomObject - Randomly selects an object from the list.
  • JA_List_InsertObjectAtIndex - Inserts an object at a specified index within the list.
  • JA_List_JoinAttributeToASingleString - Compiles a string from the values of a specified attribute for each object in the list.
  • JA_List_Reverse - Reverses the order of the objects in the list.
  • JA_List_Shuffle - Randomly shuffles the positions of objects within the list.

How to Update Deprecated Java Actions

If you're transitioning from older sorting Java actions that are now deprecated to the updated ones, please note that this process requires manual intervention for each use case. Here's a guide to help you through the update:

Identify Deprecated Actions: First, identify all instances where deprecated sorting Java actions are used within your Mendix projects.

  1. Understand the Changes: Familiarize yourself with the updates. Notably, a new "Starting index" parameter has been added to the Sanitize sorting action. Additionally, all updated sorting Java actions now return a list of changed objects, which is a change from the previous behavior.
  2. Plan the Update: Before making changes, plan how you'll integrate the new parameters and handle the returned list of changed objects. Consider how these changes will impact your current workflow and data handling.
  3. Manual Replacement: Replace each instance of the deprecated action with the updated action manually. Ensure that you:
  4. Adjust for the new "Starting index" parameter in the Sanitize sorting action. Modify your microflows or logic to handle the list of changed objects returned by the sorting actions.
  5. Testing: After updating the actions, thoroughly test your application to ensure that the new actions are functioning as expected and that your application still behaves correctly.

Please take these differences into consideration when updating your actions to a newer version. This careful approach will help minimize disruption and ensure a smooth transition to the enhanced functionalities of the updated Java actions.

Examples and Testing

You can use this GitHub repository link to run included project: https://github.com/mendixlabs/mendix-list-operations-module

It contains additional modules that can help to understand functionality better.

Testing of this module can be done via the "Examples" pages or "Unit tests" page. There are buttons in the header that can be used to add or remove sample data from your database.

Mendix versions successfully tested on

  • 8.18.1
  • 8.18.27
  • 9.24.1
  • 9.24.13
  • 10.6.0

Dependencies

  • No dependencies on other modules or libraries

License

Apache 2

Releases

Version: 2.0.0
Framework Version: 8.18.1
Release Notes: Sample data pages, logic and entities were moved to a separate module within project with examples (ListOperationsExamples). It will no longer be shipped together with Java actions, since it's only purpose is to teach and show how to use ObjectListOperations module. Examples project is now deployed on a free node Added 9 other list operations with unit tests and examples page: - JA_List_FilterChanged - JA_List_FilterIfAttributeHasChanged - JA_List_FlatListAssociations - JA_List_GetObjectByIndex - JA_List_GetRandomObject - JA_List_InsertObjectAtIndex - JA_List_JoinAttributeToASingleString - JA_List_Reverse - JA_List_Shuffle Updated sorting operations: - V1 versions are contained in "Deprecated" folder with functionality un changed to prevent breaking changes in existing projects - V2 sorting java actions were renamed as "JA_List_MoveObjectToPosition", "JA_List_PerformSortingAction" and "JA_List_SanitizeSorting" - V2 sorting java actions now return list of objects that were changed during execution - "AffectedList" parameter was renamed to "ProvidedList" similarly to other operations - Sorting attribute now also accepts Long attributes - Java action documentation was updated accordingly to new changes - Java impl package was refactored - V1 versions of impl Java package were created to support V1 sorting actions - Unit tests coverage for V2 sorting java actions were added Sanitize sorting Java action: - New required parameter "StartingIndex" was added which defines sorting number of the very first element in the list. Usually it is "0" or "1". Before that it was set to "1" Move to position Java action: - "New position" parameter was slightly reworked. It is now should be equal to a value of sorting attribute of another object within shared provided list Successfully tested latest changed on higher Mendix versions: 8.18.27, 9.24.1, 9.24.13, 10.6.0
Version: 1.1.0
Framework Version: 8.18.1
Release Notes: New feature: Move to Index You can now specify a particular index of the list to move an object to. For example, moving the object in the 2nd position to the 6th can be done in a single java action call (specifying "6" as a parameter), rather than multiple java action calls which move it one step each time. Documentation has been updated appropriately, as well as other minor improvements.
Version: 1.0.1
Framework Version: 8.18.1
Release Notes: Before this release, there was a slight 'issue' when setting Commit = false on any of the actions. The instance of the object in the list was updated with its new 'sort' value. However, the instance of the object that was passed in to the microflow (the standalone object, not the object as part of the list) was not updated. This has now been corrected, making it easier to work with the module in cases where you would like to set Commit = false.
Version: 1.0.0
Framework Version: 8.18.1
Release Notes: First release. This module is used to make it quicker and easier for Mendix developers to apply list operations to a list of Mendix objects in runtime. Specifically, operations around moving an object's position in the list. Typically, this logic is straightforward to implement but time consuming to build and repeat for each necessary entity. The Java Actions provided in this module shorten the amount of logic that needs to be repeatedly built.