當前位置: 首頁>>代碼示例>>Java>>正文


Java DBObject.containsField方法代碼示例

本文整理匯總了Java中com.mongodb.DBObject.containsField方法的典型用法代碼示例。如果您正苦於以下問題:Java DBObject.containsField方法的具體用法?Java DBObject.containsField怎麽用?Java DBObject.containsField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.mongodb.DBObject的用法示例。


在下文中一共展示了DBObject.containsField方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: insert

import com.mongodb.DBObject; //導入方法依賴的package包/類
public void insert(List<CanalEntry.Column> data, String schemaName, String tableName) {
    DBObject obj = DBConvertUtil.columnToJson(data);
    logger.debug("insert :{}", obj.toString());
    //訂單庫單獨處理
    if (schemaName.equals("order")) {
        //保存原始數據
        if (tableName.startsWith("order_base_info")) {
            tableName = "order_base_info";
        } else if (tableName.startsWith("order_detail_info")) {
            tableName = "order_detail_info";
        } else {
            logger.info("unknown data :{}.{}:{}", schemaName, tableName, obj);
            return;
        }
        insertData(schemaName, tableName, obj, obj);
    } else {
        DBObject newObj = (DBObject) ObjectUtils.clone(obj);
        if (newObj.containsField("id")) {
            newObj.put("_id", newObj.get("id"));
            newObj.removeField("id");
        }
        insertData(schemaName, tableName, newObj, obj);
    }
}
 
開發者ID:zhangtr,項目名稱:canal-mongo,代碼行數:25,代碼來源:DataService.java

示例2: update

import com.mongodb.DBObject; //導入方法依賴的package包/類
public void update(List<CanalEntry.Column> data, String schemaName, String tableName) {
    DBObject obj = DBConvertUtil.columnToJson(data);
    logger.debug("update:{}", obj.toString());
    //訂單庫單獨處理
    if (schemaName.equals("order")) {
        if (tableName.startsWith("order_base_info")) {
            tableName = "order_base_info";
        } else if (tableName.startsWith("order_detail_info")) {
            tableName = "order_detail_info";
        } else {
            logger.info("unknown data:{}.{}:{}", schemaName, tableName, obj);
        }
        updateData(schemaName, tableName, new BasicDBObject("orderId", obj.get("orderId")), obj);
    } else {
        if (obj.containsField("id")) {
            updateData(schemaName, tableName, new BasicDBObject("_id", obj.get("id")), obj);
        } else {
            logger.info("unknown data structure");
        }
    }
}
 
開發者ID:zhangtr,項目名稱:canal-mongo,代碼行數:22,代碼來源:DataService.java

示例3: deleteData

import com.mongodb.DBObject; //導入方法依賴的package包/類
public void deleteData(String schemaName, String tableName, DBObject obj) {
    int i = 0;
    String path = "/" + schemaName + "/" + tableName + "/" + CanalEntry.EventType.DELETE.getNumber();
    DBObject newObj = (DBObject) ObjectUtils.clone(obj);
    DBObject logObj = (DBObject) ObjectUtils.clone(obj);
    //保存原始數據
    try {
        i++;
        if (obj.containsField("id")) {
            naiveMongoTemplate.getCollection(tableName).remove(new BasicDBObject("_id", obj.get("id")));
        }
        i++;
        SpringUtil.doEvent(path, newObj);
    } catch (MongoClientException | MongoSocketException clientException) {
        //客戶端連接異常拋出,阻塞同步,防止mongodb宕機
        throw clientException;
    } catch (Exception e) {
        logError(schemaName, tableName, 3, i, logObj, e);
    }
}
 
開發者ID:zhangtr,項目名稱:canal-mongo,代碼行數:21,代碼來源:DataService.java

示例4: deserialize

import com.mongodb.DBObject; //導入方法依賴的package包/類
public static CubotFloppyDrive deserialize(DBObject obj) {

        CubotFloppyDrive drive = new CubotFloppyDrive((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((long) obj.get("cubot")));

        if (obj.containsField("floppy")) {
            drive.floppyDisk = FloppyDisk.deserialise((DBObject) obj.get("floppy"));
        }

        return drive;
    }
 
開發者ID:simon987,項目名稱:Much-Assembly-Required,代碼行數:11,代碼來源:CubotFloppyDrive.java


注:本文中的com.mongodb.DBObject.containsField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。