Using squence ID
This commit is contained in:
Binary file not shown.
@@ -76,7 +76,7 @@ public class CalendarQuickstart {
|
||||
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
|
||||
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
|
||||
.setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH)))
|
||||
.setAccessType("offline")
|
||||
// .setAccessType("offline")
|
||||
.build();
|
||||
LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
|
||||
return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
|
||||
@@ -104,12 +104,10 @@ public class CalendarQuickstart {
|
||||
|
||||
System.out.println("\nEvents:");
|
||||
int ct = 0;
|
||||
int ex = 0;
|
||||
int colCt = 0;
|
||||
int hitCt = 0;
|
||||
int pageCt = 0;
|
||||
|
||||
HashSet<String> colSet = new HashSet<String>();
|
||||
int cngCt = 0;
|
||||
|
||||
String srcId = "tero23q0dqqfc45r4jjcecl7bs@group.calendar.google.com";
|
||||
String trgId = "rpg91b8ls4e437a2gu63jhmlfk@group.calendar.google.com";
|
||||
@@ -169,12 +167,23 @@ public class CalendarQuickstart {
|
||||
} while (events.getNextPageToken() != null);
|
||||
|
||||
|
||||
|
||||
if (srcItems.isEmpty()) {
|
||||
System.out.println("No upcoming events found.");
|
||||
} else {
|
||||
|
||||
System.out.println("# src items: " + srcItems.size());
|
||||
|
||||
for (Event event : srcItems) {
|
||||
|
||||
ct++;
|
||||
|
||||
if (event.getColorId() != null) {
|
||||
|
||||
colCt++;
|
||||
|
||||
// if (!event.getSummary().equals("T Freier Abend"))
|
||||
// continue;
|
||||
|
||||
String startStr = null;
|
||||
if (event.getStart() != null && event.getStart().getDateTime() != null)
|
||||
startStr = event.getStart().getDateTime().toString();
|
||||
@@ -184,19 +193,20 @@ public class CalendarQuickstart {
|
||||
+ ", UPDATED: " + event.getUpdated()
|
||||
+ ", COLOR: " + event.getColorId()
|
||||
+ ", START: " + startStr
|
||||
+ ", " + (++ct)
|
||||
+ ", " + ct
|
||||
+ ", DESCRIPTION: " + event.getDescription()
|
||||
+ ", SUMMARY: " + event.getSummary());
|
||||
|
||||
colSet.add(event.getColorId());
|
||||
|
||||
if (event.getColorId() != null) {
|
||||
|
||||
colCt++;
|
||||
|
||||
for (Event trgEvent : trgItems) {
|
||||
if (trgEvent.getId().equals(event.getId())) {
|
||||
hitCt++;
|
||||
|
||||
Event currentEvent = service.events().get(trgId, trgEvent.getId()).execute();
|
||||
trgEvent.setSequence(currentEvent.getSequence());
|
||||
|
||||
trgEvent.setColorId(event.getColorId());
|
||||
service.events().update(trgId, trgEvent.getId(), trgEvent).execute();
|
||||
cngCt++;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -220,11 +230,7 @@ public class CalendarQuickstart {
|
||||
System.out.println("Page count: " + pageCt);
|
||||
System.out.println("Colored source events: " + colCt);
|
||||
System.out.println("Target hits: " + hitCt);
|
||||
|
||||
System.out.println("Colors used:");
|
||||
for (String str : colSet) {
|
||||
System.out.println(str);
|
||||
}
|
||||
System.out.println("Change count: " + cngCt);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user