本文整理汇总了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;
}