本文整理汇总了Java中org.bson.Document.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Document.isEmpty方法的具体用法?Java Document.isEmpty怎么用?Java Document.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bson.Document
的用法示例。
在下文中一共展示了Document.isEmpty方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPendingDataLoader
import org.bson.Document; //导入方法依赖的package包/类
public O2MSyncDataLoader getPendingDataLoader() {
O2MSyncDataLoader loader = null;
Document document = syncEventDoc.findOneAndUpdate(
Filters.and(Filters.eq(SyncAttrs.STATUS, SyncStatus.PENDING),
Filters.eq(SyncAttrs.EVENT_TYPE, String.valueOf(EventType.System))),
Updates.set(SyncAttrs.STATUS, SyncStatus.IN_PROGRESS),
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
.projection(Projections.include(SyncAttrs.SOURCE_DB_NAME, SyncAttrs.SOURCE_USER_NAME)));
if (document != null && !document.isEmpty()) {
Object interval = document.get(SyncAttrs.INTERVAL);
String appName = document.getString(SyncAttrs.APPLICATION_NAME);
if(interval!=null && interval instanceof Long){
loader = new O2MSyncDataLoader((Long)interval, appName);
}else{
loader = new O2MSyncDataLoader(120000, appName);
}
loader.setEventId(document.getObjectId(SyncAttrs.ID));
loader.setDbName(document.getString(SyncAttrs.SOURCE_DB_NAME));
loader.setDbUserName(document.getString(SyncAttrs.SOURCE_USER_NAME));
loader.setStatus(document.getString(SyncAttrs.STATUS));
}
return loader;
}
示例2: decodeMongoToOracleMap
import org.bson.Document; //导入方法依赖的package包/类
private MongoToOracleMap decodeMongoToOracleMap(Document mapDocument) {
MongoToOracleMap map = new MongoToOracleMap();
map.setCollectionName(mapDocument.getString(SyncAttrs.COLLECTION_NAME));
List<Document> nodeGrpListDoc = (List<Document>) mapDocument.get(SyncAttrs.NODE_TABLE_GROUP);
if (nodeGrpListDoc != null && !nodeGrpListDoc.isEmpty()) {
//Map<String, NodeGroup> tableNodeGrp = new HashMap<String, NodeGroup>();
List<NodeGroup> rootNodeList = new ArrayList<NodeGroup>();
for (Document nodeGrpDoc : nodeGrpListDoc) {
if (nodeGrpDoc != null && !nodeGrpDoc.isEmpty()) {
NodeGroup node = decodeNodeGroup(nodeGrpDoc);
rootNodeList.add(node);
//tableNodeGrp.put(node.getNodeName(), node);
}
}
map.setRootNode(rootNodeList);
}
return map;
}
示例3: getDataLoader
import org.bson.Document; //导入方法依赖的package包/类
public O2MSyncDataLoader getDataLoader(ObjectId eventId) {
O2MSyncDataLoader loader = null;
Document document = syncEventDoc
.find(Filters.and(Filters.eq(SyncAttrs.ID, eventId))).first();
if (document != null && !document.isEmpty()) {
Object interval = document.get(SyncAttrs.INTERVAL);
String appName = document.getString(SyncAttrs.APPLICATION_NAME);
if(interval!=null && interval instanceof Long){
loader = new O2MSyncDataLoader((Long)interval , appName);
}else{
loader = new O2MSyncDataLoader(120000 , appName);
}
loader.setEventId(document.getObjectId(SyncAttrs.ID));
loader.setDbName(document.getString(SyncAttrs.SOURCE_DB_NAME));
loader.setDbUserName(document.getString(SyncAttrs.SOURCE_USER_NAME));
loader.setStatus(document.getString(SyncAttrs.STATUS));
}
return loader;
}
示例4: processChildNodes
import org.bson.Document; //导入方法依赖的package包/类
private void processChildNodes(NodeGroup rootNode, Document dataMap, Map<String, Object> parentValueMap,
String parentNodeName) throws SQLException {
logger.debug("Processing child nodes for root node " + rootNode.getNodeName());
List<NodeGroup> childNodes = rootNode.getChildGroups();
List<Document> childDataMapList = null;
if (childNodes != null && !childNodes.isEmpty()) {
for (NodeGroup childNode : childNodes) {
Object childDataObj = dataMap.get(childNode.getNodeName());
if (childDataObj != null) {
if (childDataObj instanceof List) {
childDataMapList = (List<Document>) childDataObj;
} else {
Document childDataMap = (Document) childDataObj;
if (!childDataMap.isEmpty()) {
childDataMapList = Arrays.asList(childDataMap);
}
}
if (childDataMapList != null && !childDataMapList.isEmpty()) {
processSyncDocument(childNode, childDataMapList, parentValueMap,
parentNodeName + QueryConstants.DOT + childNode.getNodeName(), false);
}
}
}
}
}
示例5: list
import org.bson.Document; //导入方法依赖的package包/类
/**
* Get objects from the cache/database
*
* @param query The query to filter
* @param queried Queried or looped access?
* @param limit Limit of objects
* @return The list of elements
*/
public List<E> list(DbFilter query, boolean queried, int limit, boolean cached) {
List<E> l = limit == -1 ? new ArrayList<>() : new FixedSizeList<>(limit);
try {
if(isCacheable() && cached) {
List l1 = query == null ? getCache().asList() : getCache().get(query, queried);
l.addAll(l1);
}
if(l.isEmpty()) {
FindIterable<Document> documents = fetch(query, limit);
for(Document d : documents) {
if(d != null && !d.isEmpty()) {
l.add(convert(d));
}
}
}
}
catch(Exception e) {
System.err.println("Error while fetching data from " + getClass().getSimpleName() + " module:");
e.printStackTrace();
}
if(l.size() == 1 && l.get(0) == null) l = new ArrayList<>();
return l;
}
示例6: decodeMongoAttribute
import org.bson.Document; //导入方法依赖的package包/类
private MongoAttribute decodeMongoAttribute(Document doc) {
logger.debug("Decode called for MongoAttribute" + doc);
MongoAttribute attribute = new MongoAttribute();
attribute.setAttributeName(doc.getString(SyncAttrs.ATTRIBUTE_NAME));
attribute.setAttributeType(MongoAttributeType.valueOf(doc.getString(SyncAttrs.ATTRIBUTE_TYPE)));
attribute.setIdentifier(doc.getBoolean(SyncAttrs.IS_IDENTIFIER, false));
Document mappedOracleEntityDoc = (Document) doc.get(SyncAttrs.COLUMN_DATA);
if (mappedOracleEntityDoc != null && !mappedOracleEntityDoc.isEmpty())
attribute.setMappedOracleColumn(decodeColumn(mappedOracleEntityDoc));
attribute.setDefaultValue(doc.getString(SyncAttrs.DEFAULT_VALUE));
logger.debug("Decode Completed. Decode Object : " + attribute);
return attribute;
}
示例7: decodeOracleParallelReadInfo
import org.bson.Document; //导入方法依赖的package包/类
private OracleParallelReadInfo decodeOracleParallelReadInfo(Document document) {
OracleParallelReadInfo parallelReadInfo = new OracleParallelReadInfo();
parallelReadInfo.setNumOfBuckets(document.getInteger(SyncAttrs.NUM_OF_BUCKETS, 0));
parallelReadInfo.setProcessParallel(document.getBoolean(SyncAttrs.PROCESS_PARALLEL, false));
Document columnDataDoc = (Document) document.get(SyncAttrs.COLUMN_DATA);
if (columnDataDoc != null && !columnDataDoc.isEmpty()) {
parallelReadInfo.setRangeColumn(decodeColumn(columnDataDoc));
}
return parallelReadInfo;
}
示例8: decodeOracleToMongoMap
import org.bson.Document; //导入方法依赖的package包/类
private OracleToMongoMap decodeOracleToMongoMap(Document document) {
logger.debug("Start of decode method");
OracleToMongoMap map = new OracleToMongoMap();
Document mapObjectDoc = (Document) document.get(SyncAttrs.MAP_OBJECT);
if (mapObjectDoc != null && !mapObjectDoc.isEmpty()) {
map.setMapObject(decodeMongoObject(mapObjectDoc));
}
return map;
}
示例9: decodeColumnAttrMapper
import org.bson.Document; //导入方法依赖的package包/类
private ColumnAttrMapper decodeColumnAttrMapper(Document document) {
ColumnAttrMapper mapper = new ColumnAttrMapper();
Document columnData = (Document) document.get(SyncAttrs.COLUMN_DATA);
if (columnData != null) {
mapper.setColumn(decodeColumn(columnData));
}
mapper.setParentColumn(document.getBoolean(SyncAttrs.IS_PARENT_COLUMN, false));
mapper.setSeqGenerated(document.getBoolean(SyncAttrs.IS_SEQ_GENERATED, false));
mapper.setSeqName(document.getString(SyncAttrs.SEQ_NAME));
mapper.setIgnoreList((List<String>) document.get(SyncAttrs.IGNORE_LIST));
Object literalValDoc = document.get(SyncAttrs.LITERAL_VALUE_FOR_COLUMN);
if (literalValDoc != null && !"".equals(literalValDoc)) {
if (literalValDoc instanceof Document) {
mapper.setLiteralValueForColumn(decodeLiteral((Document) literalValDoc));
} else {
Literal literal = SqlLiteralFactory.getLiteral(literalValDoc, mapper.getColumn().getColumnType());
mapper.setLiteralValueForColumn(literal);
}
}
Document mongoAttribute = (Document) document.get(SyncAttrs.ATTRIBUTE);
if (mongoAttribute != null && !mongoAttribute.isEmpty()) {
mapper.setAttribute(decodeMongoAttribute(mongoAttribute));
}
mapper.setParentAttribute(document.getBoolean(SyncAttrs.IS_PARENT_ATTRIBUTE, false));
mapper.setParentAttributeNode(document.getString(SyncAttrs.PARENT_ATTRIBUTE_NODE));
mapper.setChildAttribute(document.getBoolean(SyncAttrs.IS_CHILD_ATTRIBUTE, false));
mapper.setChildAttributeNode(document.getString(SyncAttrs.CHILD_ATTRIBUTE_NODE));
mapper.setReplacementMap((Map<String, String>) document.get(SyncAttrs.REPLACEMENT_MAP));
return mapper;
}
示例10: decodeColumnAttrMapper
import org.bson.Document; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private ColumnAttrMapper decodeColumnAttrMapper(Document document) {
ColumnAttrMapper mapper = new ColumnAttrMapper();
Document columnData = (Document) document.get(SyncAttrs.COLUMN_DATA);
if (columnData != null) {
mapper.setColumn(decodeColumn(columnData));
}
mapper.setParentColumn(document.getBoolean(SyncAttrs.IS_PARENT_COLUMN, false));
mapper.setSeqGenerated(document.getBoolean(SyncAttrs.IS_SEQ_GENERATED, false));
mapper.setSeqName(document.getString(SyncAttrs.SEQ_NAME));
mapper.setIgnoreList((List<String>) document.get(SyncAttrs.IGNORE_LIST));
Object literalValDoc = document.get(SyncAttrs.LITERAL_VALUE_FOR_COLUMN);
if (literalValDoc != null && !"".equals(literalValDoc)) {
if (literalValDoc instanceof Document) {
mapper.setLiteralValueForColumn(decodeLiteral((Document) literalValDoc));
} else {
Literal literal = SqlLiteralFactory.getLiteral(literalValDoc, mapper.getColumn().getColumnType());
mapper.setLiteralValueForColumn(literal);
}
}
Document mongoAttribute = (Document) document.get(SyncAttrs.ATTRIBUTE);
if (mongoAttribute != null && !mongoAttribute.isEmpty()) {
mapper.setAttribute(decodeMongoAttribute(mongoAttribute));
}
mapper.setParentAttribute(document.getBoolean(SyncAttrs.IS_PARENT_ATTRIBUTE, false));
mapper.setParentAttributeNode(document.getString(SyncAttrs.PARENT_ATTRIBUTE_NODE));
mapper.setChildAttribute(document.getBoolean(SyncAttrs.IS_CHILD_ATTRIBUTE, false));
mapper.setChildAttributeNode(document.getString(SyncAttrs.CHILD_ATTRIBUTE_NODE));
mapper.setReplacementMap((Map<String, String>) document.get(SyncAttrs.REPLACEMENT_MAP));
return mapper;
}
示例11: processChildNodes
import org.bson.Document; //导入方法依赖的package包/类
private List<Document> processChildNodes(MongoObject mongoObject, ResultSet parentRow, String parentObjectName)
throws SQLException, SyncError {
List<Document> documentBundle = null;
Object value = null;
Document document = new Document();
String attributeName = null;
for (MongoEntity attribute : mongoObject.getAttributes()) {
value = null;
if (attribute instanceof MongoAttribute) {
MongoAttribute mongoAttribute = (MongoAttribute) attribute;
attributeName = mongoAttribute.getAttributeName();
if (mongoAttribute.getMappedOracleColumn().isParentColumn()) {
value = processMongoAttribute(mongoAttribute, parentRow);
}
} else if (attribute instanceof MongoObject) {
MongoObject mongoNestedObject = (MongoObject) attribute;
attributeName = mongoNestedObject.getCollectionName();
List<Document> nestedDocList = processMongoObject(mongoNestedObject, false, parentRow, parentObjectName,
null);
MongoAttributeType collectionType = MongoAttributeType.valueOf(mongoNestedObject.getCollectionType());
if (MongoAttributeType.AUTO.equals(collectionType)) {
if (nestedDocList != null && nestedDocList.size() > 1) {
value = nestedDocList;
} else if (nestedDocList != null && nestedDocList.size() == 1) {
value = nestedDocList.get(0);
}
} else if (MongoAttributeType.COLLECTION.equals(collectionType)) {
if (nestedDocList != null && nestedDocList.size() >= 1) {
value = nestedDocList.get(0);
}
} else {
if (nestedDocList != null && nestedDocList.size() >= 1) {
value = nestedDocList;
}
}
}
if (value != null || saveNulls) {
/*document.append(SyncConstants.SRC, SyncConstants.ORCL);
document.append(SyncConstants.SYNC_TIME, System.currentTimeMillis());*/
document.append(attributeName, value);
}
}
if (!document.isEmpty()) {
documentBundle = new ArrayList<Document>(1);
documentBundle.add(document);
}
return documentBundle;
}