Source:
protected void doOperation() { println("Running " + getClass().getSimpleName() + "..."); println("Preview: " + isPreview()); Cursor cursor = null; String cursorPosition = getLastPositionOfCursor(); if (StringHelper.isEmpty(cursorPosition)) { println("Start from the beginning, you may want to record the cursor position\n" + "in order to start from the last stopped position when re-run the script."); } else { println("Start from cursor position: " + cursorPosition); cursor = Cursor.fromWebSafeString(cursorPosition); } String entityType = "Unknown"; boolean shouldContinue = true; while (shouldContinue) { shouldContinue = false; Query<T> filterQueryKeys = getFilterQuery().limit(getCursorInformationPrintCycle()); if (cursor != null) { filterQueryKeys = filterQueryKeys.startAt(cursor); } QueryResultIterator<Key<T>> iterator = filterQueryKeys.keys().iterator(); while (iterator.hasNext()) { shouldContinue = true; Key<T> keyOfEntityToMigrate = iterator.next(); if (entityType.isEmpty()) { entityType = keyOfEntityToMigrate.getKind(); } migrate(keyOfEntityToMigrate); numberOfScannedKey.incrementAndGet(); } if (shouldContinue) { cursor = iterator.getCursor(); println(String.format("Cursor Position: %s", cursor.toWebSafeString())); println(String.format("Number Of Entity Key Scanned: %d", numberOfScannedKey.get())); println(String.format("Number Of Entity affected: %d", numberOfAffectedEntities.get())); println(String.format("Number Of Entity updated: %d", numberOfUpdatedEntities.get())); } } println(isPreview() ? "Preview Completed!" : "Migration Completed!"); println("Total number of " + entityType + "s: " + numberOfScannedKey.get()); println("Number of affected " + entityType + "s: " + numberOfAffectedEntities.get()); println("Number of updated " + entityType + "s: " + numberOfUpdatedEntities.get()); }

Target:
protected void doOperation() { println("Running " + getClass().getSimpleName() + "..."); println("Preview: " + isPreview()); Cursor cursor = null; String cursorPosition = getLastPositionOfCursor(); if (StringHelper.isEmpty(cursorPosition)) { println("Start from the beginning, you may want to record the cursor position\n" + "in order to start from the last stopped position when re-run the script."); } else { println("Start from cursor position: " + cursorPosition); cursor = Cursor.fromWebSafeString(cursorPosition); } String entityType = "Unknown"; boolean shouldContinue = true; while (shouldContinue) { shouldContinue = false; Query<T> filterQueryKeys = getFilterQuery().limit(getCursorInformationPrintCycle()); if (cursor != null) { filterQueryKeys = filterQueryKeys.startAt(cursor); } QueryResultIterator<Key<T>> iterator = filterQueryKeys.keys().iterator(); while (iterator.hasNext()) { shouldContinue = true; Key<T> keyOfEntityToMigrate = iterator.next(); if ("Unknown".equals(entityType)) { entityType = keyOfEntityToMigrate.getKind(); } migrate(keyOfEntityToMigrate); numberOfScannedKey.incrementAndGet(); } if (shouldContinue) { cursor = iterator.getCursor(); println(String.format("Cursor Position: %s", cursor.toWebSafeString())); println(String.format("Number Of Entity Key Scanned: %d", numberOfScannedKey.get())); println(String.format("Number Of Entity affected: %d", numberOfAffectedEntities.get())); println(String.format("Number Of Entity updated: %d", numberOfUpdatedEntities.get())); } } println(isPreview() ? "Preview Completed!" : "Migration Completed!"); println("Total number of " + entityType + "s: " + numberOfScannedKey.get()); println("Number of affected " + entityType + "s: " + numberOfAffectedEntities.get()); println("Number of updated " + entityType + "s: " + numberOfUpdatedEntities.get()); }