本文整理匯總了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);
}
}
示例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");
}
}
}
示例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);
}
}
示例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;
}