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;
|
package org.eclipse.hawkbit.autoconfigure.repository;
|
||||||
|
|
||||||
import org.eclipse.hawkbit.repository.jpa.JpaRepositoryConfiguration;
|
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.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.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
@@ -25,13 +21,4 @@ import org.springframework.context.annotation.Import;
|
|||||||
@ConditionalOnClass({ JpaRepositoryConfiguration.class })
|
@ConditionalOnClass({ JpaRepositoryConfiguration.class })
|
||||||
@Import({ JpaRepositoryConfiguration.class })
|
@Import({ JpaRepositoryConfiguration.class })
|
||||||
public class JpaRepositoryAutoConfiguration {
|
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> {
|
public enum ActionFields implements QueryField, FieldValueConverter<ActionFields> {
|
||||||
|
|
||||||
ID("id"),
|
ID("id"),
|
||||||
STATUS("active"),
|
STATUS("active"), // true if status is "pending", false if "finished"
|
||||||
DETAILSTATUS("status"),
|
DETAILSTATUS("status"), // real status
|
||||||
LASTSTATUSCODE("lastActionStatusCode"),
|
LASTSTATUSCODE("lastActionStatusCode"),
|
||||||
CREATEDAT("createdAt"),
|
CREATEDAT("createdAt"),
|
||||||
CREATEDBY("createdBy"),
|
CREATEDBY("createdBy"),
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ import java.io.Serializable;
|
|||||||
* Implementations map a placeholder to the associated value.
|
* Implementations map a placeholder to the associated value.
|
||||||
* <p>
|
* <p>
|
||||||
* This is used in context of string replacement.
|
* 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
|
@FunctionalInterface
|
||||||
public interface VirtualPropertyReplacer extends Serializable {
|
public interface VirtualPropertyReplacer extends Serializable {
|
||||||
|
|
||||||
|
|||||||
@@ -181,12 +181,13 @@ public class QLSupport {
|
|||||||
|
|
||||||
public static class DefaultQueryParser implements QueryParser {
|
public static class DefaultQueryParser implements QueryParser {
|
||||||
|
|
||||||
private VirtualPropertyReplacer virtualPropertyReplacer;
|
@Override
|
||||||
|
public <T extends Enum<T> & QueryField> Node parse(final String query, final Class<T> queryFieldType) throws QueryException {
|
||||||
@Autowired(required = false)
|
return RsqlParser.parse(query, queryFieldType);
|
||||||
void setVirtualPropertyReplacer(final VirtualPropertyReplacer virtualPropertyReplacer) {
|
|
||||||
this.virtualPropertyReplacer = virtualPropertyReplacer;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MappingQueryParser extends DefaultQueryParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Enum<T> & QueryField> Node parse(final String query, final Class<T> queryFieldType) throws QueryException {
|
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;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// just extension points for subclasses
|
||||||
protected Object mapValue(final Object value, final Comparison comparison) {
|
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.AfterTransactionCommitExecutorHolder;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityInterceptorHolder;
|
import org.eclipse.hawkbit.repository.jpa.model.helper.EntityInterceptorHolder;
|
||||||
import org.eclipse.hawkbit.repository.jpa.model.helper.TenantAwareHolder;
|
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.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.ql.QLSupport.QueryParser;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
|
import org.eclipse.hawkbit.repository.jpa.repository.ActionRepository;
|
||||||
import org.eclipse.hawkbit.repository.jpa.repository.DistributionSetRepository;
|
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.TargetFilterQuery;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder;
|
import org.eclipse.hawkbit.repository.model.helper.SystemSecurityContextHolder;
|
||||||
import org.eclipse.hawkbit.repository.model.helper.TenantConfigurationManagementHolder;
|
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.HawkbitSecurityProperties;
|
||||||
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
||||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||||
@@ -517,8 +522,20 @@ public class JpaRepositoryConfiguration {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
QueryParser queryParser() {
|
public VirtualPropertyResolver virtualPropertyReplacer() {
|
||||||
return new DefaultQueryParser();
|
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