SingleSelect ListField

Description

see comments for actual fixes

Maybe there is a Problem with the building of the OR-List for the XWikiObjectFetcher.

Ecountered example in
CourseService#getRegistrationCount works with for-loop like this:

but with the direct filetering without a for-loop, the count() will always be 0. (The list is empty):

causes

Activity

Marc Sladek 
29 January 2018 at 15:14
(edited)

The merge caused:

because I moved some methods to the superclass, but when instantiating via reflection it still expects it in the subclass if the dependency is not updated in all projects. solution:
https://github.com/celements/celements-xwiki/pull/11

had the same issue in

Marc Sladek 
25 January 2018 at 22:02
(edited)

Additionally, I added a SingleListField, which is basically the same as a ListField with multiselect(false) but with easier to use generics:

class SingleListField<T> implements ClassField<T>
instead of
class ListField<T> implements ClassField<List<T>>

Type Hierarchy:

  • AbstractListField<T, E> implements CustomClassField<T>

    • ListField<T> extends AbstractListField<List<T>, T>

      • DBListField extends ListField<String>

      • CustomListField<T> extends ListField<T>

        • StringListField extends CustomListField<String> (aka StaticListField)

    • SingleListField<T> extends AbstractListField<T, T>

      • CustomSingleListField<T> extends SingleListField<T>

        • StringSingleListField extends CustomSingleListField<String> (aka StaticSingleListField)

Marc Sladek 
20 December 2017 at 17:38
(edited)

This is a problem for singleSelect ListField<T> extends ClassField<List<T>> . when calling
filter(listField, Arrays.asList(val1, val2))
it does not in fact call the filter with an OR-List, but merely the key/value filter (since value is expected to be of type List). the right call would be with a List<List<T>>:
filter(listField, Arrays.asList(Arrays.asList(val1), Arrays.asList(val2)))

This behaviour isn't intuitive for singleSelect ListFields since one expects only one value by default, therefore I propose explicit handlig for these kind of ClassFields

Done

Details

Priority

Assignee

Reporter

Sprint

Story Points

Components

Fix versions

Clockify

Created 20 December 2017 at 16:23
Updated 31 July 2018 at 15:16
Resolved 31 July 2018 at 15:16