[#2176] RSQL filtering with exist/not-exist support (#2396)

* [#2176] RSQL filtering with exist/not-exist support

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>

* [#2176] Big Refactoring

* RSQL: all maps with joins with on

---------

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-05-16 16:13:04 +03:00
committed by GitHub
parent c0e89fbbee
commit 12140e468d
24 changed files with 518 additions and 616 deletions

View File

@@ -9,6 +9,7 @@
*/
package org.eclipse.hawkbit.repository;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -53,13 +54,8 @@ public enum ActionFields implements RsqlQueryField, FieldValueConverter<ActionFi
}
@Override
public Object convertValue(final ActionFields e, final String value) {
return STATUS == e ? convertStatusValue(value) : value;
}
@Override
public String[] possibleValues(final ActionFields e) {
return STATUS == e ? new String[] { ACTIVE, INACTIVE } : new String[0];
public Object convertValue(final ActionFields enumValue, final String value) {
return STATUS == enumValue ? convertStatusValue(value) : value;
}
private static Object convertStatusValue(final String value) {
@@ -69,7 +65,7 @@ public enum ActionFields implements RsqlQueryField, FieldValueConverter<ActionFi
} else if (trimmedValue.equalsIgnoreCase(INACTIVE)) {
return false;
} else {
return null;
throw new IllegalArgumentException("field 'status' must be one of the following values {" + ACTIVE + ", " + INACTIVE + "}");
}
}
}

View File

@@ -21,21 +21,13 @@ package org.eclipse.hawkbit.repository;
public interface FieldValueConverter<T extends Enum<T>> {
/**
* Converts the given {@code value} into the representation to build a
* generic query.
* Converts the given {@code value} into the representation to build ageneric query.
*
* @param e the enum to build the value for
* @param enumValue the enum to build the value for
* @param value the value in string representation
* @return the converted object or {@code null} if conversation fails, if given enum does not need to be converted the
* unmodified {@code value} is returned.
* @throws IllegalArgumentException if the value is not supported
*/
Object convertValue(final T e, final String value);
/**
* returns the possible values associated with the given enum type.
*
* @param e the enum type to retrieve the possible values
* @return the possible values for a specific enum or {@code null}
*/
String[] possibleValues(final T e);
Object convertValue(final T enumValue, final String value);
}

View File

@@ -33,9 +33,13 @@ public enum TargetFields implements RsqlQueryField {
UPDATESTATUS("updateStatus"),
IPADDRESS("address"),
ATTRIBUTE("controllerAttributes"),
ASSIGNEDDS("assignedDistributionSet", "name", "version"),
INSTALLEDDS("installedDistributionSet", "name", "version"),
TAG("tags", "name"),
ASSIGNEDDS(
"assignedDistributionSet",
DistributionSetFields.NAME.getJpaEntityFieldName(), DistributionSetFields.VERSION.getJpaEntityFieldName()),
INSTALLEDDS(
"installedDistributionSet",
DistributionSetFields.NAME.getJpaEntityFieldName(), DistributionSetFields.VERSION.getJpaEntityFieldName()),
TAG("tags", TagFields.NAME.getJpaEntityFieldName()),
LASTCONTROLLERREQUESTAT("lastTargetQuery"),
METADATA("metadata", new SimpleImmutableEntry<>("key", "value")),
TARGETTYPE("targetType", TargetTypeFields.KEY.getJpaEntityFieldName(), TargetTypeFields.NAME.getJpaEntityFieldName());