Improve building of SQL from an RSQL query (#1766)
* Improve building of SQL from an RSQL query * ignore case behavior could be disabled * like is used only when needed Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com> * Inlining of some methods and unified IN build + fix case Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com> * Implement more flexible ignore case configuration Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com> --------- Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.rsql;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
/**
|
||||
* Helper class providing static access to the RSQL configuration as managed the ignoreCase and
|
||||
* the {@link RsqlVisitorFactory} bean.
|
||||
*/
|
||||
@NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
|
||||
@Getter
|
||||
public final class RsqlConfigHolder {
|
||||
|
||||
private static final RsqlConfigHolder SINGLETON = new RsqlConfigHolder();
|
||||
|
||||
/**
|
||||
* If RSQL comparison operators shall ignore the case. If ignore case is <code>true</code>
|
||||
* "x == ax" will match "x == aX"
|
||||
*/
|
||||
@Value("${hawkbit.rsql.ignoreCase:true}")
|
||||
private boolean ignoreCase;
|
||||
/**
|
||||
* Declares if the database is case-insensitive, by default assumes <code>false</code>. In case it is case-sensitive and,
|
||||
* {@link #ignoreCase} is set to <code>true</code> the SQL queries use upper case comparisons to ignore case.
|
||||
*
|
||||
* If the database is declared as case-sensitive and ignoreCase is set to <code>false</code> the RSQL queries shall use strict
|
||||
* syntax - i.e. 'and' instead of 'AND' / 'aND'. Otherwise, the queries would be case-insensitive regarding operators.
|
||||
*/
|
||||
@Value("${hawkbit.rsql.caseInsensitiveDB:false}")
|
||||
private boolean caseInsensitiveDB;
|
||||
@Autowired
|
||||
private RsqlVisitorFactory rsqlVisitorFactory;
|
||||
|
||||
/**
|
||||
* @return The holder singleton instance.
|
||||
*/
|
||||
public static RsqlConfigHolder getInstance() {
|
||||
return SINGLETON;
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Bosch.IO GmbH and others
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.rsql;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Helper class providing static access to the managed
|
||||
* {@link RsqlVisitorFactory} bean.
|
||||
*/
|
||||
public final class RsqlVisitorFactoryHolder {
|
||||
|
||||
private static final RsqlVisitorFactoryHolder SINGLETON = new RsqlVisitorFactoryHolder();
|
||||
|
||||
@Autowired
|
||||
private RsqlVisitorFactory rsqlVisitorFactory;
|
||||
|
||||
private RsqlVisitorFactoryHolder() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The holder singleton instance.
|
||||
*/
|
||||
public static RsqlVisitorFactoryHolder getInstance() {
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The managed RsqlVisitorFactory bean
|
||||
*/
|
||||
public RsqlVisitorFactory getRsqlVisitorFactory() {
|
||||
return rsqlVisitorFactory;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user