Quellcode durchsuchen

Merge pull request #2370 from deka0106/issue-2368

#2368: wrap search options with asterisk
Shinsuke Sugaya vor 5 Jahren
Ursprung
Commit
d11f66691e

+ 3 - 3
src/main/java/org/codelibs/fess/app/service/BoostDocumentRuleService.java

@@ -30,7 +30,7 @@ import org.codelibs.fess.mylasta.direction.FessConfig;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalEntity;
 
 
-public class BoostDocumentRuleService {
+public class BoostDocumentRuleService extends FessAppService {
 
 
     @Resource
     @Resource
     protected BoostDocumentRuleBhv boostDocumentRuleBhv;
     protected BoostDocumentRuleBhv boostDocumentRuleBhv;
@@ -71,10 +71,10 @@ public class BoostDocumentRuleService {
 
 
     protected void setupListCondition(final BoostDocumentRuleCB cb, final BoostDocPager boostDocumentRulePager) {
     protected void setupListCondition(final BoostDocumentRuleCB cb, final BoostDocPager boostDocumentRulePager) {
         if (StringUtil.isNotBlank(boostDocumentRulePager.urlExpr)) {
         if (StringUtil.isNotBlank(boostDocumentRulePager.urlExpr)) {
-            cb.query().setUrlExpr_Wildcard(boostDocumentRulePager.urlExpr);
+            cb.query().setUrlExpr_Wildcard(wrapQuery(boostDocumentRulePager.urlExpr));
         }
         }
         if (StringUtil.isNotBlank(boostDocumentRulePager.boostExpr)) {
         if (StringUtil.isNotBlank(boostDocumentRulePager.boostExpr)) {
-            cb.query().setBoostExpr_Wildcard(boostDocumentRulePager.boostExpr);
+            cb.query().setBoostExpr_Wildcard(wrapQuery(boostDocumentRulePager.boostExpr));
         }
         }
         // TODO Long, Integer, String supported only.
         // TODO Long, Integer, String supported only.
 
 

+ 3 - 3
src/main/java/org/codelibs/fess/app/service/DataConfigService.java

@@ -31,7 +31,7 @@ import org.codelibs.fess.util.ParameterUtil;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalEntity;
 
 
-public class DataConfigService {
+public class DataConfigService extends FessAppService {
 
 
     @Resource
     @Resource
     protected DataConfigBhv dataConfigBhv;
     protected DataConfigBhv dataConfigBhv;
@@ -79,10 +79,10 @@ public class DataConfigService {
             cb.query().setName_Wildcard(dataConfigPager.name);
             cb.query().setName_Wildcard(dataConfigPager.name);
         }
         }
         if (StringUtil.isNotBlank(dataConfigPager.handlerName)) {
         if (StringUtil.isNotBlank(dataConfigPager.handlerName)) {
-            cb.query().setHandlerName_Wildcard(dataConfigPager.handlerName);
+            cb.query().setHandlerName_Wildcard(wrapQuery(dataConfigPager.handlerName));
         }
         }
         if (StringUtil.isNotBlank(dataConfigPager.description)) {
         if (StringUtil.isNotBlank(dataConfigPager.description)) {
-            cb.query().setDescription_Wildcard(dataConfigPager.description);
+            cb.query().setDescription_Wildcard(wrapQuery(dataConfigPager.description));
         }
         }
         // TODO Long, Integer, String supported only.
         // TODO Long, Integer, String supported only.
 
 

+ 3 - 3
src/main/java/org/codelibs/fess/app/service/DuplicateHostService.java

@@ -30,7 +30,7 @@ import org.codelibs.fess.mylasta.direction.FessConfig;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalEntity;
 
 
-public class DuplicateHostService {
+public class DuplicateHostService extends FessAppService {
 
 
     @Resource
     @Resource
     protected DuplicateHostBhv duplicateHostBhv;
     protected DuplicateHostBhv duplicateHostBhv;
@@ -86,10 +86,10 @@ public class DuplicateHostService {
 
 
     protected void setupListCondition(final DuplicateHostCB cb, final DuplicateHostPager duplicateHostPager) {
     protected void setupListCondition(final DuplicateHostCB cb, final DuplicateHostPager duplicateHostPager) {
         if (StringUtil.isNotBlank(duplicateHostPager.regularName)) {
         if (StringUtil.isNotBlank(duplicateHostPager.regularName)) {
-            cb.query().setRegularName_Wildcard(duplicateHostPager.regularName);
+            cb.query().setRegularName_Wildcard(wrapQuery(duplicateHostPager.regularName));
         }
         }
         if (StringUtil.isNotBlank(duplicateHostPager.duplicateHostName)) {
         if (StringUtil.isNotBlank(duplicateHostPager.duplicateHostName)) {
-            cb.query().setDuplicateHostName_Wildcard(duplicateHostPager.duplicateHostName);
+            cb.query().setDuplicateHostName_Wildcard(wrapQuery(duplicateHostPager.duplicateHostName));
         }
         }
         // TODO Long, Integer, String supported only.
         // TODO Long, Integer, String supported only.
 
 

+ 32 - 0
src/main/java/org/codelibs/fess/app/service/FessAppService.java

@@ -0,0 +1,32 @@
+/*
+ * Copyright 2012-2020 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.app.service;
+
+public abstract class FessAppService {
+
+    protected static String wrapQuery(final String query) {
+        final StringBuilder sb = new StringBuilder();
+        if (!query.startsWith("*")) {
+            sb.append("*");
+        }
+        sb.append(query);
+        if (!query.endsWith("*")) {
+            sb.append("*");
+        }
+        return sb.toString();
+    }
+
+}

+ 4 - 4
src/main/java/org/codelibs/fess/app/service/FileConfigService.java

@@ -32,7 +32,7 @@ import org.codelibs.fess.util.ParameterUtil;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalEntity;
 
 
-public class FileConfigService {
+public class FileConfigService extends FessAppService {
 
 
     @Resource
     @Resource
     protected FileConfigBhv fileConfigBhv;
     protected FileConfigBhv fileConfigBhv;
@@ -85,13 +85,13 @@ public class FileConfigService {
 
 
     protected void setupListCondition(final FileConfigCB cb, final FileConfigPager fileConfigPager) {
     protected void setupListCondition(final FileConfigCB cb, final FileConfigPager fileConfigPager) {
         if (StringUtil.isNotBlank(fileConfigPager.name)) {
         if (StringUtil.isNotBlank(fileConfigPager.name)) {
-            cb.query().setName_Wildcard(fileConfigPager.name);
+            cb.query().setName_Wildcard(wrapQuery(fileConfigPager.name));
         }
         }
         if (StringUtil.isNotBlank(fileConfigPager.paths)) {
         if (StringUtil.isNotBlank(fileConfigPager.paths)) {
-            cb.query().setPaths_Wildcard(fileConfigPager.paths);
+            cb.query().setPaths_Wildcard(wrapQuery(fileConfigPager.paths));
         }
         }
         if (StringUtil.isNotBlank(fileConfigPager.description)) {
         if (StringUtil.isNotBlank(fileConfigPager.description)) {
-            cb.query().setDescription_Wildcard(fileConfigPager.description);
+            cb.query().setDescription_Wildcard(wrapQuery(fileConfigPager.description));
         }
         }
         // TODO Long, Integer, String supported only.
         // TODO Long, Integer, String supported only.
 
 

+ 3 - 3
src/main/java/org/codelibs/fess/app/service/KeyMatchService.java

@@ -30,7 +30,7 @@ import org.codelibs.fess.mylasta.direction.FessConfig;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalEntity;
 
 
-public class KeyMatchService {
+public class KeyMatchService extends FessAppService {
 
 
     @Resource
     @Resource
     protected KeyMatchBhv keyMatchBhv;
     protected KeyMatchBhv keyMatchBhv;
@@ -76,10 +76,10 @@ public class KeyMatchService {
 
 
     protected void setupListCondition(final KeyMatchCB cb, final KeyMatchPager keyMatchPager) {
     protected void setupListCondition(final KeyMatchCB cb, final KeyMatchPager keyMatchPager) {
         if (StringUtil.isNotBlank(keyMatchPager.term)) {
         if (StringUtil.isNotBlank(keyMatchPager.term)) {
-            cb.query().setTerm_Wildcard(keyMatchPager.term);
+            cb.query().setTerm_Wildcard(wrapQuery(keyMatchPager.term));
         }
         }
         if (StringUtil.isNotBlank(keyMatchPager.query)) {
         if (StringUtil.isNotBlank(keyMatchPager.query)) {
-            cb.query().setQuery_Wildcard(keyMatchPager.query);
+            cb.query().setQuery_Wildcard(wrapQuery(keyMatchPager.query));
         }
         }
         // TODO Long, Integer, String supported only.
         // TODO Long, Integer, String supported only.
 
 

+ 3 - 3
src/main/java/org/codelibs/fess/app/service/LabelTypeService.java

@@ -32,7 +32,7 @@ import org.codelibs.fess.util.ComponentUtil;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalEntity;
 
 
-public class LabelTypeService {
+public class LabelTypeService extends FessAppService {
 
 
     @Resource
     @Resource
     protected LabelTypeBhv labelTypeBhv;
     protected LabelTypeBhv labelTypeBhv;
@@ -70,10 +70,10 @@ public class LabelTypeService {
 
 
     protected void setupListCondition(final LabelTypeCB cb, final LabelTypePager labelTypePager) {
     protected void setupListCondition(final LabelTypeCB cb, final LabelTypePager labelTypePager) {
         if (StringUtil.isNotBlank(labelTypePager.name)) {
         if (StringUtil.isNotBlank(labelTypePager.name)) {
-            cb.query().setName_Wildcard(labelTypePager.name);
+            cb.query().setName_Wildcard(wrapQuery(labelTypePager.name));
         }
         }
         if (StringUtil.isNotBlank(labelTypePager.value)) {
         if (StringUtil.isNotBlank(labelTypePager.value)) {
-            cb.query().setValue_Wildcard(labelTypePager.value);
+            cb.query().setValue_Wildcard(wrapQuery(labelTypePager.value));
         }
         }
         // TODO Long, Integer, String supported only.
         // TODO Long, Integer, String supported only.
 
 

+ 3 - 3
src/main/java/org/codelibs/fess/app/service/PathMappingService.java

@@ -32,7 +32,7 @@ import org.codelibs.fess.util.ComponentUtil;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalEntity;
 
 
-public class PathMappingService {
+public class PathMappingService extends FessAppService {
 
 
     @Resource
     @Resource
     protected PathMappingBhv pathMappingBhv;
     protected PathMappingBhv pathMappingBhv;
@@ -89,10 +89,10 @@ public class PathMappingService {
 
 
     protected void setupListCondition(final PathMappingCB cb, final PathMapPager pathMappingPager) {
     protected void setupListCondition(final PathMappingCB cb, final PathMapPager pathMappingPager) {
         if (StringUtil.isNotBlank(pathMappingPager.regex)) {
         if (StringUtil.isNotBlank(pathMappingPager.regex)) {
-            cb.query().setRegex_Wildcard(pathMappingPager.regex);
+            cb.query().setRegex_Wildcard(wrapQuery(pathMappingPager.regex));
         }
         }
         if (StringUtil.isNotBlank(pathMappingPager.replacement)) {
         if (StringUtil.isNotBlank(pathMappingPager.replacement)) {
-            cb.query().setReplacement_Wildcard(pathMappingPager.replacement);
+            cb.query().setReplacement_Wildcard(wrapQuery(pathMappingPager.replacement));
         }
         }
         // TODO Long, Integer, String supported only.
         // TODO Long, Integer, String supported only.
 
 

+ 3 - 3
src/main/java/org/codelibs/fess/app/service/RelatedContentService.java

@@ -31,7 +31,7 @@ import org.codelibs.fess.util.ComponentUtil;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalEntity;
 
 
-public class RelatedContentService {
+public class RelatedContentService extends FessAppService {
 
 
     @Resource
     @Resource
     protected RelatedContentBhv relatedContentBhv;
     protected RelatedContentBhv relatedContentBhv;
@@ -72,10 +72,10 @@ public class RelatedContentService {
 
 
     protected void setupListCondition(final RelatedContentCB cb, final RelatedContentPager relatedContentPager) {
     protected void setupListCondition(final RelatedContentCB cb, final RelatedContentPager relatedContentPager) {
         if (StringUtil.isNotBlank(relatedContentPager.term)) {
         if (StringUtil.isNotBlank(relatedContentPager.term)) {
-            cb.query().setTerm_Wildcard(relatedContentPager.term);
+            cb.query().setTerm_Wildcard(wrapQuery(relatedContentPager.term));
         }
         }
         if (StringUtil.isNotBlank(relatedContentPager.content)) {
         if (StringUtil.isNotBlank(relatedContentPager.content)) {
-            cb.query().setContent_Wildcard(relatedContentPager.content);
+            cb.query().setContent_Wildcard(wrapQuery(relatedContentPager.content));
         }
         }
         // TODO Long, Integer, String supported only.
         // TODO Long, Integer, String supported only.
 
 

+ 3 - 3
src/main/java/org/codelibs/fess/app/service/RelatedQueryService.java

@@ -31,7 +31,7 @@ import org.codelibs.fess.util.ComponentUtil;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalEntity;
 
 
-public class RelatedQueryService {
+public class RelatedQueryService extends FessAppService {
 
 
     @Resource
     @Resource
     protected RelatedQueryBhv relatedQueryBhv;
     protected RelatedQueryBhv relatedQueryBhv;
@@ -72,10 +72,10 @@ public class RelatedQueryService {
 
 
     protected void setupListCondition(final RelatedQueryCB cb, final RelatedQueryPager relatedQueryPager) {
     protected void setupListCondition(final RelatedQueryCB cb, final RelatedQueryPager relatedQueryPager) {
         if (StringUtil.isNotBlank(relatedQueryPager.term)) {
         if (StringUtil.isNotBlank(relatedQueryPager.term)) {
-            cb.query().setTerm_Wildcard(relatedQueryPager.term);
+            cb.query().setTerm_Wildcard(wrapQuery(relatedQueryPager.term));
         }
         }
         if (StringUtil.isNotBlank(relatedQueryPager.queries)) {
         if (StringUtil.isNotBlank(relatedQueryPager.queries)) {
-            cb.query().setQueries_Wildcard(relatedQueryPager.queries);
+            cb.query().setQueries_Wildcard(wrapQuery(relatedQueryPager.queries));
         }
         }
         // TODO Long, Integer, String supported only.
         // TODO Long, Integer, String supported only.
 
 

+ 4 - 4
src/main/java/org/codelibs/fess/app/service/WebConfigService.java

@@ -33,7 +33,7 @@ import org.codelibs.fess.util.ParameterUtil;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalEntity;
 
 
-public class WebConfigService {
+public class WebConfigService extends FessAppService {
 
 
     @Resource
     @Resource
     protected WebConfigBhv webConfigBhv;
     protected WebConfigBhv webConfigBhv;
@@ -93,13 +93,13 @@ public class WebConfigService {
 
 
     protected void setupListCondition(final WebConfigCB cb, final WebConfigPager webConfigPager) {
     protected void setupListCondition(final WebConfigCB cb, final WebConfigPager webConfigPager) {
         if (StringUtil.isNotBlank(webConfigPager.name)) {
         if (StringUtil.isNotBlank(webConfigPager.name)) {
-            cb.query().setName_Wildcard(webConfigPager.name);
+            cb.query().setName_Wildcard(wrapQuery(webConfigPager.name));
         }
         }
         if (StringUtil.isNotBlank(webConfigPager.urls)) {
         if (StringUtil.isNotBlank(webConfigPager.urls)) {
-            cb.query().setUrls_Wildcard(webConfigPager.urls);
+            cb.query().setUrls_Wildcard(wrapQuery(webConfigPager.urls));
         }
         }
         if (StringUtil.isNotBlank(webConfigPager.description)) {
         if (StringUtil.isNotBlank(webConfigPager.description)) {
-            cb.query().setDescription_Wildcard(webConfigPager.description);
+            cb.query().setDescription_Wildcard(wrapQuery(webConfigPager.description));
         }
         }
         // TODO Long, Integer, String supported only.
         // TODO Long, Integer, String supported only.