Deprecate VirtualPropertyReplacer (#2697)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -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