コード例 #1
0
 /**
  * Sets the application attribute using the name passed to the constructor on a batch feed.
  *
  * @param batchFeed
  */
 @SuppressWarnings("unchecked")
 private void addApplicationAttribute(IFeed iFeed) {
   if (!(iFeed instanceof BaseFeed)) {
     throw new IllegalArgumentException("Unexpected feed type: " + iFeed);
   }
   BaseFeed<?, ?> batchFeed = (BaseFeed<?, ?>) iFeed;
   BatchOperationType defaultType = BatchUtils.getBatchOperationType(batchFeed);
   if (defaultType == null) {
     defaultType = BatchOperationType.INSERT;
   }
   List<? extends BaseEntry> entries = batchFeed.getEntries();
   for (BaseEntry<?> entry : entries) {
     BatchOperationType type = BatchUtils.getBatchOperationType(entry);
     if (type == null) {
       type = defaultType;
     }
     if (type == BatchOperationType.INSERT || type == BatchOperationType.UPDATE) {
       addApplicationAttribute(entry);
     }
   }
 }
コード例 #2
0
ファイル: CellDemo.java プロジェクト: cavr/MongoCourse
 /**
  * Writes (to stdout) a list of the entries in the batch request in a human readable format.
  *
  * @param batchRequest the CellFeed containing entries to display.
  */
 private void printBatchRequest(CellFeed batchRequest) {
   System.out.println("Current operations in batch");
   for (CellEntry entry : batchRequest.getEntries()) {
     String msg =
         "\tID: "
             + BatchUtils.getBatchId(entry)
             + " - "
             + BatchUtils.getBatchOperationType(entry)
             + " row: "
             + entry.getCell().getRow()
             + " col: "
             + entry.getCell().getCol()
             + " value: "
             + entry.getCell().getInputValue();
     System.out.println(msg);
   }
 }