Skip to content

Commit

Permalink
feat(search like): remove wordSearchExclusionMappings configuration (…
Browse files Browse the repository at this point in the history
  • Loading branch information
abirembaut authored Dec 13, 2023
1 parent 0abb78f commit c4f1dce
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 266 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1023,56 +1023,12 @@
</property>
</bean>

<bean id="defaultPlatformWordSearchExclusionMappings" class="org.springframework.beans.factory.config.SetFactoryBean">
<property name="targetSetClass">
<value>java.util.HashSet</value>
</property>
<property name="sourceSet">
<list>
</list>
</property>
</bean>

<bean id="platformWordSearchExclusionMappings" parent="defaultPlatformWordSearchExclusionMappings" class="org.springframework.beans.factory.config.SetFactoryBean">
<property name="targetSetClass">
<value>java.util.HashSet</value>
</property>
<property name="sourceSet">
<list merge="true">
<!-- value>org.bonitasoft.engine.identity.model.SUser</value -->
</list>
</property>
</bean>

<bean id="queryBuilderFactory" class="org.bonitasoft.engine.persistence.QueryBuilderFactory">
<constructor-arg name="orderByCheckingMode" value="${sysprop.bonita.orderby.checking.mode:NONE}" />
<constructor-arg name="classAliasMappings">
<bean factory-bean="hbmConfigurationProvider" factory-method="getClassAliasMappings" />
</constructor-arg>
<constructor-arg name="likeEscapeCharacter" value="${bonita.platform.persistence.tenant.likeEscapeCharacter}" />
<constructor-arg name="wordSearchExclusionMappings" ref="tenantWordSearchExclusionMappings" />
</bean>

<bean id="defaultTenantWordSearchExclusionMappings" class="org.springframework.beans.factory.config.SetFactoryBean">
<property name="targetSetClass">
<value>java.util.HashSet</value>
</property>
<property name="sourceSet">
<list>

</list>
</property>
</bean>

<bean id="tenantWordSearchExclusionMappings" parent="defaultTenantWordSearchExclusionMappings" class="org.springframework.beans.factory.config.SetFactoryBean">
<property name="targetSetClass">
<value>java.util.HashSet</value>
</property>
<property name="sourceSet">
<list merge="true">
<!-- value>org.bonitasoft.engine.identity.model.SUser</value -->
</list>
</property>
</bean>

<bean id="hbmConfigurationProviderProperties" parent="communityHbmConfigurationProviderProperties" class="org.bonitasoft.engine.service.impl.MapToPropertiesFactoryBean">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,4 @@

<!-- ADD ANY BEAN DEFINITION YOU WANT TO BE AVAILABLE TO THE PLATFORM ACCESSOR -->

<!--
<bean id="platformWordSearchExclusionMappings" parent="defaultPlatformWordSearchExclusionMappings" class="org.springframework.beans.factory.config.SetFactoryBean">
<property name="targetSetClass">
<value>java.util.HashSet</value>
</property>
<property name="sourceSet">
<list merge="true">
<value>org.bonitasoft.engine.identity.model.SUser</value>
</list>
</property>
</bean>
-->

<!--
<bean id="tenantWordSearchExclusionMappings" parent="defaultTenantWordSearchExclusionMappings" class="org.springframework.beans.factory.config.SetFactoryBean">
<property name="targetSetClass">
<value>java.util.HashSet</value>
</property>
<property name="sourceSet">
<list merge="true">
<value>org.bonitasoft.engine.identity.model.SUser</value>
</list>
</property>
</bean>
-->
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
**/
package org.bonitasoft.engine.persistence;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.Session;
Expand All @@ -32,31 +30,13 @@ public class QueryBuilderFactory {
private OrderByBuilder orderByBuilder = new DefaultOrderByBuilder();
private Map<String, String> classAliasMappings;
private char likeEscapeCharacter;
private final Set<Class<? extends PersistentObject>> wordSearchExclusionMappings = new HashSet<>();

public QueryBuilderFactory(OrderByCheckingMode orderByCheckingMode, Map<String, String> classAliasMappings,
char likeEscapeCharacter, Set<String> wordSearchExclusionMappings)
char likeEscapeCharacter)
throws Exception {
this.orderByCheckingMode = orderByCheckingMode;
this.classAliasMappings = classAliasMappings;
this.likeEscapeCharacter = likeEscapeCharacter;
initializeWordSearchExclusions(wordSearchExclusionMappings);
}

private void initializeWordSearchExclusions(Set<String> wordSearchExclusionMappings)
throws Exception {
if (wordSearchExclusionMappings != null && !wordSearchExclusionMappings.isEmpty()) {
for (final String wordSearchExclusionMapping : wordSearchExclusionMappings) {
final Class<?> clazz = Class.forName(wordSearchExclusionMapping);
if (!PersistentObject.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(
"Unable to add a word search exclusion mapping for class " + clazz
+ " because it does not implements "
+ PersistentObject.class);
}
this.wordSearchExclusionMappings.add((Class<? extends PersistentObject>) clazz);
}
}
}

public <T> QueryBuilder createQueryBuilderFor(Session session,
Expand All @@ -75,17 +55,4 @@ public <T> QueryBuilder createQueryBuilderFor(Session session,
public void setOrderByBuilder(OrderByBuilder orderByBuilder) {
this.orderByBuilder = orderByBuilder;
}

protected boolean isWordSearchEnabled(final Class<? extends PersistentObject> entityClass) {
if (entityClass == null) {
return false;
}
for (final Class<? extends PersistentObject> exclusion : wordSearchExclusionMappings) {
if (exclusion.isAssignableFrom(entityClass)) {
return false;
}
}
return true;
}

}

This file was deleted.

0 comments on commit c4f1dce

Please sign in to comment.