[camel] branch master updated (c9e498c -> 93418f6)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated (c9e498c -> 93418f6)

acosentino
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from c9e498c  Upgrade Hazelcast to version 3.10.6
     new 9702b09  CAMEL-12874 - Camel-google-calendar-stream: Last update date must consider UpdatedMin field instead of TimeMin when used
     new 93418f6  CAMEL-12874 - Fixed CS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../stream/GoogleCalendarStreamConsumer.java       | 33 ++++++++++++++++------
 1 file changed, 24 insertions(+), 9 deletions(-)

Reply | Threaded
Open this post in threaded view
|

[camel] 01/02: CAMEL-12874 - Camel-google-calendar-stream: Last update date must consider UpdatedMin field instead of TimeMin when used

acosentino
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9702b096536adadb5cf1ed06aedfa37d8c97cb35
Author: Andrea Cosentino <[hidden email]>
AuthorDate: Thu Oct 11 09:29:40 2018 +0200

    CAMEL-12874 - Camel-google-calendar-stream: Last update date must consider UpdatedMin field instead of TimeMin when used
---
 .../stream/GoogleCalendarStreamConsumer.java       | 37 ++++++++++++++++------
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumer.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumer.java
index 460de6b..0c87d97 100644
--- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumer.java
+++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumer.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.google.calendar.stream;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.LinkedList;
 import java.util.List;
@@ -70,36 +71,54 @@ public class GoogleCalendarStreamConsumer extends ScheduledBatchPollingConsumer
         if (ObjectHelper.isNotEmpty(getConfiguration().getMaxResults())) {
             request.setMaxResults(getConfiguration().getMaxResults());
         }
-        if (getConfiguration().isConsumeFromNow() && !getConfiguration().isConsiderLastUpdate()) {
+        if (getConfiguration().isConsumeFromNow()) {
             Date date = new Date();
             request.setTimeMin(new DateTime(date));
-        } else if (getConfiguration().isConsiderLastUpdate()) {
+        }
+        if (getConfiguration().isConsiderLastUpdate()) {
             if (ObjectHelper.isNotEmpty(lastUpdate)) {
-                request.setTimeMin(lastUpdate);
-            }
+                request.setUpdatedMin(lastUpdate);
+            }
         }
 
         Queue<Exchange> answer = new LinkedList<>();
+        List<Date> dateList = new ArrayList<>();
 
         Events c = request.execute();
 
         if (c != null) {
             List<Event> list = c.getItems();
-            int i = 0;
             
             for (Event event : list) {
                 Exchange exchange = getEndpoint().createExchange(getEndpoint().getExchangePattern(), event);
                 answer.add(exchange);
-                i++;
-                if (i == c.getItems().size()) {
-                    lastUpdate = event.getUpdated();
-                }
+                dateList.add(new Date(event.getUpdated().getValue()));
+                System.err.println("Title! " + event.getSummary());
+                System.err.println("Date created! " + new Date(event.getCreated().getValue()));
+                System.err.println("Date updated! " + new Date(event.getUpdated().getValue()));
             }
         }
 
+        System.err.println(dateList.toString());
+        lastUpdate = retrieveLastUpdateDate(dateList);
         return processBatch(CastUtils.cast(answer));
     }
 
+    private DateTime retrieveLastUpdateDate(List<Date> dateList) {
+        Date finalLastUpdate;
+        if (!dateList.isEmpty()) {
+        dateList.sort((o1,o2) -> o1.compareTo(o2));
+        Date lastUpdateDate = dateList.get(dateList.size() - 1);
+        java.util.Calendar calendar = java.util.Calendar.getInstance();
+        calendar.setTime(lastUpdateDate);
+        calendar.add(java.util.Calendar.SECOND, 1);
+        finalLastUpdate = calendar.getTime();
+        } else {
+           finalLastUpdate = new Date();
+        }
+        return new DateTime(finalLastUpdate);
+    }
+
     @Override
     public int processBatch(Queue<Object> exchanges) throws Exception {
         int total = exchanges.size();

Reply | Threaded
Open this post in threaded view
|

[camel] 02/02: CAMEL-12874 - Fixed CS

acosentino
In reply to this post by acosentino
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 93418f6e4ab398900507450f25f4dabab1bc36b7
Author: Andrea Cosentino <[hidden email]>
AuthorDate: Thu Oct 11 09:35:28 2018 +0200

    CAMEL-12874 - Fixed CS
---
 .../stream/GoogleCalendarStreamConsumer.java       | 24 +++++++++-------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumer.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumer.java
index 0c87d97..5c31853 100644
--- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumer.java
+++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConsumer.java
@@ -74,11 +74,11 @@ public class GoogleCalendarStreamConsumer extends ScheduledBatchPollingConsumer
         if (getConfiguration().isConsumeFromNow()) {
             Date date = new Date();
             request.setTimeMin(new DateTime(date));
-        }
+        }
         if (getConfiguration().isConsiderLastUpdate()) {
             if (ObjectHelper.isNotEmpty(lastUpdate)) {
                 request.setUpdatedMin(lastUpdate);
-            }
+            }
         }
 
         Queue<Exchange> answer = new LinkedList<>();
@@ -88,18 +88,14 @@ public class GoogleCalendarStreamConsumer extends ScheduledBatchPollingConsumer
 
         if (c != null) {
             List<Event> list = c.getItems();
-            
+
             for (Event event : list) {
                 Exchange exchange = getEndpoint().createExchange(getEndpoint().getExchangePattern(), event);
                 answer.add(exchange);
                 dateList.add(new Date(event.getUpdated().getValue()));
-                System.err.println("Title! " + event.getSummary());
-                System.err.println("Date created! " + new Date(event.getCreated().getValue()));
-                System.err.println("Date updated! " + new Date(event.getUpdated().getValue()));
             }
         }
 
-        System.err.println(dateList.toString());
         lastUpdate = retrieveLastUpdateDate(dateList);
         return processBatch(CastUtils.cast(answer));
     }
@@ -107,14 +103,14 @@ public class GoogleCalendarStreamConsumer extends ScheduledBatchPollingConsumer
     private DateTime retrieveLastUpdateDate(List<Date> dateList) {
         Date finalLastUpdate;
         if (!dateList.isEmpty()) {
-        dateList.sort((o1,o2) -> o1.compareTo(o2));
-        Date lastUpdateDate = dateList.get(dateList.size() - 1);
-        java.util.Calendar calendar = java.util.Calendar.getInstance();
-        calendar.setTime(lastUpdateDate);
-        calendar.add(java.util.Calendar.SECOND, 1);
-        finalLastUpdate = calendar.getTime();
+            dateList.sort((o1, o2) -> o1.compareTo(o2));
+            Date lastUpdateDate = dateList.get(dateList.size() - 1);
+            java.util.Calendar calendar = java.util.Calendar.getInstance();
+            calendar.setTime(lastUpdateDate);
+            calendar.add(java.util.Calendar.SECOND, 1);
+            finalLastUpdate = calendar.getTime();
         } else {
-           finalLastUpdate = new Date();
+            finalLastUpdate = new Date();
         }
         return new DateTime(finalLastUpdate);
     }