Deprecate VirtualPropertyReplacer (#2697)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -10,11 +10,7 @@
|
||||
package org.eclipse.hawkbit.autoconfigure.repository;
|
||||
|
||||
import org.eclipse.hawkbit.repository.jpa.JpaRepositoryConfiguration;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyResolver;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@@ -25,13 +21,4 @@ import org.springframework.context.annotation.Import;
|
||||
@ConditionalOnClass({ JpaRepositoryConfiguration.class })
|
||||
@Import({ JpaRepositoryConfiguration.class })
|
||||
public class JpaRepositoryAutoConfiguration {
|
||||
|
||||
/**
|
||||
* @return returns a VirtualPropertyReplacer
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public VirtualPropertyReplacer virtualPropertyReplacer() {
|
||||
return new VirtualPropertyResolver();
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,8 @@ import lombok.Getter;
|
||||
public enum ActionFields implements QueryField, FieldValueConverter<ActionFields> {
|
||||
|
||||
ID("id"),
|
||||
STATUS("active"),
|
||||
DETAILSTATUS("status"),
|
||||
STATUS("active"), // true if status is "pending", false if "finished"
|
||||
DETAILSTATUS("status"), // real status
|
||||
LASTSTATUSCODE("lastActionStatusCode"),
|
||||
CREATEDAT("createdAt"),
|
||||
CREATEDBY("createdBy"),
|
||||
|
||||
@@ -15,7 +15,10 @@ import java.io.Serializable;
|
||||
* Implementations map a placeholder to the associated value.
|
||||
* <p>
|
||||
* This is used in context of string replacement.
|
||||
*
|
||||
* @deprecated Since 0.10.0, used only in deprecated specification builders
|
||||
*/
|
||||
@Deprecated(since = "0.10.0", forRemoval = true)
|
||||
@FunctionalInterface
|
||||
public interface VirtualPropertyReplacer extends Serializable {
|
||||
|
||||
|
||||
@@ -181,12 +181,13 @@ public class QLSupport {
|
||||
|
||||
public static class DefaultQueryParser implements QueryParser {
|
||||
|
||||
private VirtualPropertyReplacer virtualPropertyReplacer;
|
||||
|
||||
@Autowired(required = false)
|
||||
void setVirtualPropertyReplacer(final VirtualPropertyReplacer virtualPropertyReplacer) {
|
||||
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
||||
@Override
|
||||
public <T extends Enum<T> & QueryField> Node parse(final String query, final Class<T> queryFieldType) throws QueryException {
|
||||
return RsqlParser.parse(query, queryFieldType);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MappingQueryParser extends DefaultQueryParser {
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T> & QueryField> Node parse(final String query, final Class<T> queryFieldType) throws QueryException {
|
||||
@@ -205,8 +206,9 @@ public class QLSupport {
|
||||
return key;
|
||||
}
|
||||
|
||||
// just extension points for subclasses
|
||||
protected Object mapValue(final Object value, final Comparison comparison) {
|
||||
return value instanceof String strValue ? virtualPropertyReplacer.replace(strValue) : value;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,10 @@ 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;
|
||||
@@ -96,6 +99,8 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder;
|
||||
import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyResolver;
|
||||
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
|
||||
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
@@ -517,8 +522,20 @@ public class JpaRepositoryConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
QueryParser queryParser() {
|
||||
return new DefaultQueryParser();
|
||||
public VirtualPropertyResolver virtualPropertyReplacer() {
|
||||
return new VirtualPropertyResolver();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
QueryParser queryParser(final Optional<VirtualPropertyResolver> virtualPropertyResolver) {
|
||||
return virtualPropertyResolver.<QueryParser>map(resolver -> new MappingQueryParser() {
|
||||
|
||||
@Override
|
||||
protected Object mapValue(final Object value, final Comparison comparison) {
|
||||
return value instanceof String strValue ? resolver.replace(strValue) : value;
|
||||
}
|
||||
}).orElseGet(DefaultQueryParser::new);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user