Remove FieldValueConverter (#2699)

* (because) used only for ActionFields.STATUS
* could be part of new Node mapping mechanism
* simplify
* Deprecate ActionFields.STATUS, add / replace it with ActionFields.ACTIVE. In future STATUS will become the real action status (and DETAILSTATUS will be removed)
* Deprecate MgmtAction.getStatus add / replace it with MgmtAction.isActive. In future status will become the real action status (and detailStatus will be removed)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-09-26 16:57:10 +03:00
committed by GitHub
parent 1abfa0a2f4
commit a6867219b1
11 changed files with 88 additions and 141 deletions

View File

@@ -25,6 +25,7 @@ import org.eclipse.hawkbit.artifact.encryption.ArtifactEncryptionSecretsStorage;
import org.eclipse.hawkbit.artifact.encryption.ArtifactEncryptionService;
import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.PropertiesQuotaManagement;
import org.eclipse.hawkbit.repository.QueryField;
import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.RepositoryConfiguration;
import org.eclipse.hawkbit.repository.RepositoryProperties;
@@ -67,10 +68,8 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaTargetType;
import org.eclipse.hawkbit.repository.jpa.model.helper.AfterTransactionCommitExecutorHolder;
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityInterceptorHolder;
import org.eclipse.hawkbit.repository.jpa.model.helper.TenantAwareHolder;
import org.eclipse.hawkbit.repository.jpa.ql.Node;
import org.eclipse.hawkbit.repository.jpa.ql.Node.Comparison;
import org.eclipse.hawkbit.repository.jpa.ql.QLSupport.DefaultQueryParser;
import org.eclipse.hawkbit.repository.jpa.ql.QLSupport.MappingQueryParser;
import org.eclipse.hawkbit.repository.jpa.ql.QLSupport.QueryParser;
import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetRepository;
@@ -529,11 +528,12 @@ public class JpaRepositoryConfiguration {
@Bean
@ConditionalOnMissingBean
QueryParser queryParser(final Optional<VirtualPropertyResolver> virtualPropertyResolver) {
return virtualPropertyResolver.<QueryParser>map(resolver -> new MappingQueryParser() {
return virtualPropertyResolver.<QueryParser>map(resolver -> new DefaultQueryParser() {
@Override
protected Object mapValue(final Object value, final Comparison comparison) {
return value instanceof String strValue ? resolver.replace(strValue) : value;
protected <T extends Enum<T> & QueryField> Object mapValue(
final Object value, final Comparison comparison, final Class<T> queryFieldType) {
return super.mapValue(value instanceof String strValue ? resolver.replace(strValue) : value, comparison, queryFieldType);
}
}).orElseGet(DefaultQueryParser::new);
}

View File

@@ -14,6 +14,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import org.eclipse.hawkbit.repository.ActionFields;
import org.eclipse.hawkbit.repository.TargetManagement.Create;
import org.eclipse.hawkbit.repository.exception.QueryException;
import org.eclipse.hawkbit.repository.exception.RSQLParameterUnsupportedFieldException;
import org.eclipse.hawkbit.repository.jpa.AbstractJpaIntegrationTest;
import org.eclipse.hawkbit.repository.jpa.model.JpaAction;
@@ -77,8 +78,8 @@ class RsqlActionFieldsTest extends AbstractJpaIntegrationTest {
assertRSQLQuery(ActionFields.STATUS.name() + "=in=(pending)", 5);
assertRSQLQuery(ActionFields.STATUS.name() + "=out=(pending)", 6);
final String rsql = ActionFields.STATUS.name() + "==true";
assertThatExceptionOfType(RSQLParameterUnsupportedFieldException.class)
final String rsql = ActionFields.STATUS.name() + "==true2";
assertThatExceptionOfType(QueryException.class)
.as("RSQLParameterUnsupportedFieldException because status cannot be compared with 'true'")
.isThrownBy(() -> assertRSQLQuery(rsql, 5));
}