Shinsuke Sugaya vor 8 Jahren
Ursprung
Commit
f4fc74617c

+ 11 - 1
src/main/java/org/codelibs/fess/es/config/allcommon/EsAbstractBehavior.java

@@ -15,8 +15,10 @@
  */
 package org.codelibs.fess.es.config.allcommon;
 
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
@@ -498,7 +500,7 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
     // ===================================================================================
     //                                                                        Assist Logic
     //                                                                        ============
-    public static String[] toStringArray(final Object value) {
+    protected String[] toStringArray(final Object value) {
         if (value instanceof String[]) {
             return (String[]) value;
         } else if (value instanceof List) {
@@ -511,6 +513,14 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
         return new String[] { str };
     }
 
+    protected LocalDateTime toLocalDateTime(Object value) {
+        return DfTypeUtil.toLocalDateTime(value);
+    }
+
+    protected Date toDate(Object value) {
+        return DfTypeUtil.toDate(value);
+    }
+
     public static class BulkList<E, B> implements List<E> {
 
         private final List<E> parent;

+ 11 - 1
src/main/java/org/codelibs/fess/es/log/allcommon/EsAbstractBehavior.java

@@ -15,8 +15,10 @@
  */
 package org.codelibs.fess.es.log.allcommon;
 
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
@@ -498,7 +500,7 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
     // ===================================================================================
     //                                                                        Assist Logic
     //                                                                        ============
-    public static String[] toStringArray(final Object value) {
+    protected String[] toStringArray(final Object value) {
         if (value instanceof String[]) {
             return (String[]) value;
         } else if (value instanceof List) {
@@ -511,6 +513,14 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
         return new String[] { str };
     }
 
+    protected LocalDateTime toLocalDateTime(Object value) {
+        return DfTypeUtil.toLocalDateTime(value);
+    }
+
+    protected Date toDate(Object value) {
+        return DfTypeUtil.toDate(value);
+    }
+
     public static class BulkList<E, B> implements List<E> {
 
         private final List<E> parent;

+ 2 - 2
src/main/java/org/codelibs/fess/es/log/bsbhv/BsClickLogBhv.java

@@ -73,8 +73,8 @@ public abstract class BsClickLogBhv extends EsAbstractBehavior<ClickLog, ClickLo
     protected <RESULT extends ClickLog> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
         try {
             final RESULT result = entityType.newInstance();
-            result.setQueryRequestedAt(DfTypeUtil.toLocalDateTime(source.get("queryRequestedAt")));
-            result.setRequestedAt(DfTypeUtil.toLocalDateTime(source.get("requestedAt")));
+            result.setQueryRequestedAt(toLocalDateTime(source.get("queryRequestedAt")));
+            result.setRequestedAt(toLocalDateTime(source.get("requestedAt")));
             result.setQueryId(DfTypeUtil.toString(source.get("queryId")));
             result.setDocId(DfTypeUtil.toString(source.get("docId")));
             result.setUserSessionId(DfTypeUtil.toString(source.get("userSessionId")));

+ 1 - 1
src/main/java/org/codelibs/fess/es/log/bsbhv/BsFavoriteLogBhv.java

@@ -73,7 +73,7 @@ public abstract class BsFavoriteLogBhv extends EsAbstractBehavior<FavoriteLog, F
     protected <RESULT extends FavoriteLog> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
         try {
             final RESULT result = entityType.newInstance();
-            result.setCreatedAt(DfTypeUtil.toLocalDateTime(source.get("createdAt")));
+            result.setCreatedAt(toLocalDateTime(source.get("createdAt")));
             result.setUrl(DfTypeUtil.toString(source.get("url")));
             result.setDocId(DfTypeUtil.toString(source.get("docId")));
             result.setQueryId(DfTypeUtil.toString(source.get("queryId")));

+ 1 - 1
src/main/java/org/codelibs/fess/es/log/bsbhv/BsSearchLogBhv.java

@@ -82,7 +82,7 @@ public abstract class BsSearchLogBhv extends EsAbstractBehavior<SearchLog, Searc
             result.setQueryOffset(DfTypeUtil.toInteger(source.get("queryOffset")));
             result.setQueryPageSize(DfTypeUtil.toInteger(source.get("queryPageSize")));
             result.setReferer(DfTypeUtil.toString(source.get("referer")));
-            result.setRequestedAt(DfTypeUtil.toLocalDateTime(source.get("requestedAt")));
+            result.setRequestedAt(toLocalDateTime(source.get("requestedAt")));
             result.setResponseTime(DfTypeUtil.toLong(source.get("responseTime")));
             result.setQueryTime(DfTypeUtil.toLong(source.get("queryTime")));
             result.setSearchWord(DfTypeUtil.toString(source.get("searchWord")));

+ 2 - 3
src/main/java/org/codelibs/fess/es/log/bsbhv/BsUserInfoBhv.java

@@ -31,7 +31,6 @@ import org.dbflute.cbean.result.ListResultBean;
 import org.dbflute.cbean.result.PagingResultBean;
 import org.dbflute.exception.IllegalBehaviorStateException;
 import org.dbflute.optional.OptionalEntity;
-import org.dbflute.util.DfTypeUtil;
 import org.elasticsearch.action.bulk.BulkRequestBuilder;
 import org.elasticsearch.action.delete.DeleteRequestBuilder;
 import org.elasticsearch.action.index.IndexRequestBuilder;
@@ -73,8 +72,8 @@ public abstract class BsUserInfoBhv extends EsAbstractBehavior<UserInfo, UserInf
     protected <RESULT extends UserInfo> RESULT createEntity(Map<String, Object> source, Class<? extends RESULT> entityType) {
         try {
             final RESULT result = entityType.newInstance();
-            result.setCreatedAt(DfTypeUtil.toLocalDateTime(source.get("createdAt")));
-            result.setUpdatedAt(DfTypeUtil.toLocalDateTime(source.get("updatedAt")));
+            result.setCreatedAt(toLocalDateTime(source.get("createdAt")));
+            result.setUpdatedAt(toLocalDateTime(source.get("updatedAt")));
             return updateEntity(source, result);
         } catch (InstantiationException | IllegalAccessException e) {
             final String msg = "Cannot create a new instance: " + entityType.getName();

+ 15 - 0
src/main/java/org/codelibs/fess/es/log/exbhv/ClickLogBhv.java

@@ -15,11 +15,26 @@
  */
 package org.codelibs.fess.es.log.exbhv;
 
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+
 import org.codelibs.fess.es.log.bsbhv.BsClickLogBhv;
+import org.dbflute.util.DfTypeUtil;
 
 /**
  * @author FreeGen
  */
 public class ClickLogBhv extends BsClickLogBhv {
+    @Override
+    protected LocalDateTime toLocalDateTime(Object value) {
+        if (value != null) {
+            Instant instant = Instant.from(DateTimeFormatter.ISO_INSTANT.parse(value.toString()));
+            LocalDateTime date = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
+            return date;
+        }
+        return DfTypeUtil.toLocalDateTime(value);
+    }
 
 }

+ 15 - 0
src/main/java/org/codelibs/fess/es/log/exbhv/FavoriteLogBhv.java

@@ -15,11 +15,26 @@
  */
 package org.codelibs.fess.es.log.exbhv;
 
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+
 import org.codelibs.fess.es.log.bsbhv.BsFavoriteLogBhv;
+import org.dbflute.util.DfTypeUtil;
 
 /**
  * @author FreeGen
  */
 public class FavoriteLogBhv extends BsFavoriteLogBhv {
+    @Override
+    protected LocalDateTime toLocalDateTime(Object value) {
+        if (value != null) {
+            Instant instant = Instant.from(DateTimeFormatter.ISO_INSTANT.parse(value.toString()));
+            LocalDateTime date = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
+            return date;
+        }
+        return DfTypeUtil.toLocalDateTime(value);
+    }
 
 }

+ 15 - 0
src/main/java/org/codelibs/fess/es/log/exbhv/SearchLogBhv.java

@@ -15,11 +15,26 @@
  */
 package org.codelibs.fess.es.log.exbhv;
 
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+
 import org.codelibs.fess.es.log.bsbhv.BsSearchLogBhv;
+import org.dbflute.util.DfTypeUtil;
 
 /**
  * @author FreeGen
  */
 public class SearchLogBhv extends BsSearchLogBhv {
+    @Override
+    protected LocalDateTime toLocalDateTime(Object value) {
+        if (value != null) {
+            Instant instant = Instant.from(DateTimeFormatter.ISO_INSTANT.parse(value.toString()));
+            LocalDateTime date = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
+            return date;
+        }
+        return DfTypeUtil.toLocalDateTime(value);
+    }
 
 }

+ 15 - 0
src/main/java/org/codelibs/fess/es/log/exbhv/UserInfoBhv.java

@@ -15,11 +15,26 @@
  */
 package org.codelibs.fess.es.log.exbhv;
 
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+
 import org.codelibs.fess.es.log.bsbhv.BsUserInfoBhv;
+import org.dbflute.util.DfTypeUtil;
 
 /**
  * @author FreeGen
  */
 public class UserInfoBhv extends BsUserInfoBhv {
 
+    @Override
+    protected LocalDateTime toLocalDateTime(Object value) {
+        if (value != null) {
+            Instant instant = Instant.from(DateTimeFormatter.ISO_INSTANT.parse(value.toString()));
+            LocalDateTime date = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
+            return date;
+        }
+        return DfTypeUtil.toLocalDateTime(value);
+    }
 }

+ 11 - 1
src/main/java/org/codelibs/fess/es/user/allcommon/EsAbstractBehavior.java

@@ -15,8 +15,10 @@
  */
 package org.codelibs.fess.es.user.allcommon;
 
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
@@ -498,7 +500,7 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
     // ===================================================================================
     //                                                                        Assist Logic
     //                                                                        ============
-    public static String[] toStringArray(final Object value) {
+    protected String[] toStringArray(final Object value) {
         if (value instanceof String[]) {
             return (String[]) value;
         } else if (value instanceof List) {
@@ -511,6 +513,14 @@ public abstract class EsAbstractBehavior<ENTITY extends Entity, CB extends Condi
         return new String[] { str };
     }
 
+    protected LocalDateTime toLocalDateTime(Object value) {
+        return DfTypeUtil.toLocalDateTime(value);
+    }
+
+    protected Date toDate(Object value) {
+        return DfTypeUtil.toDate(value);
+    }
+
     public static class BulkList<E, B> implements List<E> {
 
         private final List<E> parent;