Shinsuke Sugaya пре 10 година
родитељ
комит
c180c80fa5

+ 16 - 0
src/main/java/org/codelibs/fess/es/exentity/KeyMatch.java

@@ -8,4 +8,20 @@ import org.codelibs.fess.es.bsentity.BsKeyMatch;
 public class KeyMatch extends BsKeyMatch {
 public class KeyMatch extends BsKeyMatch {
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
+
+    public String getId() {
+        return asDocMeta().id();
+    }
+
+    public void setId(String id) {
+        asDocMeta().id(id);
+    }
+
+    public Long getVersionNo() {
+        return asDocMeta().version();
+    }
+
+    public void setVersionNo(Long version) {
+        asDocMeta().version(version);
+    }
 }
 }

+ 6 - 5
src/main/java/org/codelibs/fess/helper/KeyMatchHelper.java

@@ -25,7 +25,7 @@ import java.util.Map;
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.core.lang.StringUtil;
 import org.codelibs.fess.client.FessEsClient;
 import org.codelibs.fess.client.FessEsClient;
 import org.codelibs.fess.client.FessEsClient.SearchConditionBuilder;
 import org.codelibs.fess.client.FessEsClient.SearchConditionBuilder;
-import org.codelibs.fess.db.exentity.KeyMatch;
+import org.codelibs.fess.es.exentity.KeyMatch;
 import org.codelibs.fess.service.KeyMatchService;
 import org.codelibs.fess.service.KeyMatchService;
 import org.codelibs.fess.util.ComponentUtil;
 import org.codelibs.fess.util.ComponentUtil;
 import org.seasar.framework.container.SingletonS2Container;
 import org.seasar.framework.container.SingletonS2Container;
@@ -80,10 +80,11 @@ public class KeyMatchHelper {
         final FessEsClient fessEsClient = ComponentUtil.getElasticsearchClient();
         final FessEsClient fessEsClient = ComponentUtil.getElasticsearchClient();
         final FieldHelper fieldHelper = ComponentUtil.getFieldHelper();
         final FieldHelper fieldHelper = ComponentUtil.getFieldHelper();
         final List<Map<String, Object>> documentList =
         final List<Map<String, Object>> documentList =
-                fessEsClient.getDocumentList(fieldHelper.docIndex, fieldHelper.docType, searchRequestBuilder -> {
-                    return SearchConditionBuilder.builder(searchRequestBuilder).administrativeAccess().size(keyMatch.getMaxSize())
-                            .responseFields(new String[] { fieldHelper.docIdField }).build();
-                });
+                fessEsClient.getDocumentList(fieldHelper.docIndex, fieldHelper.docType,
+                        searchRequestBuilder -> {
+                            return SearchConditionBuilder.builder(searchRequestBuilder).administrativeAccess().size(keyMatch.getMaxSize())
+                                    .query(keyMatch.getQuery()).responseFields(new String[] { fieldHelper.docIdField }).build();
+                        });
         return documentList;
         return documentList;
     }
     }
 
 

+ 12 - 9
src/main/java/org/codelibs/fess/service/KeyMatchService.java

@@ -24,9 +24,9 @@ import javax.annotation.Resource;
 
 
 import org.codelibs.fess.crud.CommonConstants;
 import org.codelibs.fess.crud.CommonConstants;
 import org.codelibs.fess.crud.CrudMessageException;
 import org.codelibs.fess.crud.CrudMessageException;
-import org.codelibs.fess.db.cbean.KeyMatchCB;
-import org.codelibs.fess.db.exbhv.KeyMatchBhv;
-import org.codelibs.fess.db.exentity.KeyMatch;
+import org.codelibs.fess.es.cbean.KeyMatchCB;
+import org.codelibs.fess.es.exbhv.KeyMatchBhv;
+import org.codelibs.fess.es.exentity.KeyMatch;
 import org.codelibs.fess.pager.KeyMatchPager;
 import org.codelibs.fess.pager.KeyMatchPager;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.seasar.framework.beans.util.Beans;
 import org.seasar.framework.beans.util.Beans;
@@ -60,7 +60,7 @@ public class KeyMatchService implements Serializable {
 
 
     public KeyMatch getKeyMatch(final Map<String, String> keys) {
     public KeyMatch getKeyMatch(final Map<String, String> keys) {
         final KeyMatch keyMatch = keyMatchBhv.selectEntity(cb -> {
         final KeyMatch keyMatch = keyMatchBhv.selectEntity(cb -> {
-            cb.query().setId_Equal(Long.parseLong(keys.get("id")));
+            cb.query().docMeta().setId_Equal(keys.get("id"));
             setupEntityCondition(cb, keys);
             setupEntityCondition(cb, keys);
         }).orElse(null);//TODO
         }).orElse(null);//TODO
         if (keyMatch == null) {
         if (keyMatch == null) {
@@ -74,25 +74,28 @@ public class KeyMatchService implements Serializable {
     public void store(final KeyMatch keyMatch) throws CrudMessageException {
     public void store(final KeyMatch keyMatch) throws CrudMessageException {
         setupStoreCondition(keyMatch);
         setupStoreCondition(keyMatch);
 
 
-        keyMatchBhv.insertOrUpdate(keyMatch);
+        keyMatchBhv.insertOrUpdate(keyMatch, op -> {
+            op.setRefresh(true);
+        });
 
 
     }
     }
 
 
     public void delete(final KeyMatch keyMatch) throws CrudMessageException {
     public void delete(final KeyMatch keyMatch) throws CrudMessageException {
         setupDeleteCondition(keyMatch);
         setupDeleteCondition(keyMatch);
 
 
-        keyMatchBhv.delete(keyMatch);
+        keyMatchBhv.delete(keyMatch, op -> {
+            op.setRefresh(true);
+        });
 
 
     }
     }
 
 
     protected void setupListCondition(final KeyMatchCB cb, final KeyMatchPager keyMatchPager) {
     protected void setupListCondition(final KeyMatchCB cb, final KeyMatchPager keyMatchPager) {
         if (keyMatchPager.id != null) {
         if (keyMatchPager.id != null) {
-            cb.query().setId_Equal(Long.parseLong(keyMatchPager.id));
+            cb.query().docMeta().setId_Equal(keyMatchPager.id);
         }
         }
         // TODO Long, Integer, String supported only.
         // TODO Long, Integer, String supported only.
 
 
         // setup condition
         // setup condition
-        cb.query().setDeletedBy_IsNull();
         cb.query().addOrderBy_Term_Asc();
         cb.query().addOrderBy_Term_Asc();
 
 
         // search
         // search
@@ -119,7 +122,7 @@ public class KeyMatchService implements Serializable {
 
 
     public List<KeyMatch> getAvailableKeyMatchList() {
     public List<KeyMatch> getAvailableKeyMatchList() {
         return keyMatchBhv.selectList(cb -> {
         return keyMatchBhv.selectList(cb -> {
-            cb.query().setDeletedBy_IsNull();
+            cb.query().matchAll();
         });
         });
     }
     }
 
 

+ 3 - 8
src/main/java/org/codelibs/fess/web/admin/KeyMatchAction.java

@@ -27,7 +27,7 @@ import org.codelibs.fess.beans.FessBeans;
 import org.codelibs.fess.crud.CommonConstants;
 import org.codelibs.fess.crud.CommonConstants;
 import org.codelibs.fess.crud.CrudMessageException;
 import org.codelibs.fess.crud.CrudMessageException;
 import org.codelibs.fess.crud.util.SAStrutsUtil;
 import org.codelibs.fess.crud.util.SAStrutsUtil;
-import org.codelibs.fess.db.exentity.KeyMatch;
+import org.codelibs.fess.es.exentity.KeyMatch;
 import org.codelibs.fess.helper.SystemHelper;
 import org.codelibs.fess.helper.SystemHelper;
 import org.codelibs.fess.pager.KeyMatchPager;
 import org.codelibs.fess.pager.KeyMatchPager;
 import org.codelibs.fess.service.KeyMatchService;
 import org.codelibs.fess.service.KeyMatchService;
@@ -235,7 +235,7 @@ public class KeyMatchAction extends FessAdminAction {
     protected KeyMatch createKeyMatch() {
     protected KeyMatch createKeyMatch() {
         KeyMatch keyMatch;
         KeyMatch keyMatch;
         final String username = systemHelper.getUsername();
         final String username = systemHelper.getUsername();
-        final LocalDateTime currentTime = systemHelper.getCurrentTime();
+        final long currentTime = systemHelper.getCurrentTimeAsLong();
         if (keyMatchForm.crudMode == CommonConstants.EDIT_MODE) {
         if (keyMatchForm.crudMode == CommonConstants.EDIT_MODE) {
             keyMatch = keyMatchService.getKeyMatch(createKeyMap());
             keyMatch = keyMatchService.getKeyMatch(createKeyMap());
             if (keyMatch == null) {
             if (keyMatch == null) {
@@ -313,12 +313,7 @@ public class KeyMatchAction extends FessAdminAction {
                 throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { keyMatchForm.id });
                 throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { keyMatchForm.id });
             }
             }
 
 
-            //           keyMatchService.delete(keyMatch);
-            final String username = systemHelper.getUsername();
-            final LocalDateTime currentTime = systemHelper.getCurrentTime();
-            keyMatch.setDeletedBy(username);
-            keyMatch.setDeletedTime(currentTime);
-            keyMatchService.store(keyMatch);
+            keyMatchService.delete(keyMatch);
             SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
             SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
 
 
             ComponentUtil.getKeyMatchHelper().update();
             ComponentUtil.getKeyMatchHelper().update();

+ 6 - 13
src/main/java/org/codelibs/fess/web/admin/KeyMatchForm.java

@@ -21,6 +21,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
 import org.codelibs.fess.Constants;
 import org.codelibs.fess.Constants;
+import org.codelibs.fess.util.ComponentUtil;
 import org.seasar.struts.annotation.DateType;
 import org.seasar.struts.annotation.DateType;
 import org.seasar.struts.annotation.IntRange;
 import org.seasar.struts.annotation.IntRange;
 import org.seasar.struts.annotation.IntegerType;
 import org.seasar.struts.annotation.IntegerType;
@@ -45,7 +46,7 @@ public class KeyMatchForm implements Serializable {
     }
     }
 
 
     @Required(target = "confirmfromupdate,update,delete")
     @Required(target = "confirmfromupdate,update,delete")
-    @LongType
+    @Maxbytelength(maxbytelength = 1000)
     public String id;
     public String id;
 
 
     @Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
     @Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
@@ -69,21 +70,15 @@ public class KeyMatchForm implements Serializable {
     public String createdBy;
     public String createdBy;
 
 
     @Required(target = "confirmfromupdate,update,delete")
     @Required(target = "confirmfromupdate,update,delete")
-    @DateType(datePattern = Constants.DEFAULT_DATETIME_FORMAT)
+    @LongType
     public String createdTime;
     public String createdTime;
 
 
     @Maxbytelength(maxbytelength = 255)
     @Maxbytelength(maxbytelength = 255)
     public String updatedBy;
     public String updatedBy;
 
 
-    @DateType(datePattern = Constants.DEFAULT_DATETIME_FORMAT)
+    @LongType
     public String updatedTime;
     public String updatedTime;
 
 
-    @Maxbytelength(maxbytelength = 255)
-    public String deletedBy;
-
-    @DateType(datePattern = Constants.DEFAULT_DATETIME_FORMAT)
-    public String deletedTime;
-
     @Required(target = "confirmfromupdate,update,delete")
     @Required(target = "confirmfromupdate,update,delete")
     @IntegerType
     @IntegerType
     public String versionNo;
     public String versionNo;
@@ -94,12 +89,10 @@ public class KeyMatchForm implements Serializable {
         query = null;
         query = null;
         maxSize = null;
         maxSize = null;
         boost = null;
         boost = null;
-        createdBy = null;
-        createdTime = null;
+        createdBy = "system";
+        createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
         updatedBy = null;
         updatedBy = null;
         updatedTime = null;
         updatedTime = null;
-        deletedBy = null;
-        deletedTime = null;
         versionNo = null;
         versionNo = null;
         maxSize = "10";
         maxSize = "10";
         boost = "100.0";
         boost = "100.0";