当前位置: 首页>>代码示例>>Java>>正文


Java BasicDBList.get方法代码示例

本文整理汇总了Java中com.mongodb.BasicDBList.get方法的典型用法代码示例。如果您正苦于以下问题:Java BasicDBList.get方法的具体用法?Java BasicDBList.get怎么用?Java BasicDBList.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mongodb.BasicDBList的用法示例。


在下文中一共展示了BasicDBList.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAsJsonArray

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
/**
 * Convert the given runnable BasicDBList object to JsonArray.
 *
 * @param object BasicDBList
 * @return JsonArray
 */
public JsonArray getAsJsonArray(DBObject object) {
    if (!(object instanceof BasicDBList)) {
        throw new IllegalArgumentException("Expected BasicDBList as argument type!");
    }
    BasicDBList list = (BasicDBList)object;
    JsonArray jsonArray = new JsonArray();
    for (int i = 0; i < list.size(); i++) {
        Object dbObject = list.get(i);
        if (dbObject instanceof BasicDBList) {
            jsonArray.add(getAsJsonArray((BasicDBList) dbObject));
        } else if (dbObject instanceof BasicDBObject) { // it's an object
            jsonArray.add(getAsJsonObject((BasicDBObject) dbObject));
        } else {   // it's a primitive type number or string
            jsonArray.add(getAsJsonPrimitive(dbObject));
            jsonArray.add(getAsJsonPrimitive(dbObject));
        }
    }
    return jsonArray;
}
 
开发者ID:stump201,项目名称:mongiORM,代码行数:26,代码来源:Mongo2JSON.java

示例2: getPCJIndexDetails

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
private static PCJIndexDetails.Builder getPCJIndexDetails(final BasicDBObject basicObj) {
    final BasicDBObject pcjIndexDBO = (BasicDBObject) basicObj.get(PCJ_DETAILS_KEY);

    final PCJIndexDetails.Builder pcjBuilder = PCJIndexDetails.builder();
    if (!pcjIndexDBO.getBoolean(PCJ_ENABLED_KEY)) {
        pcjBuilder.setEnabled(false);
    } else {
        pcjBuilder.setEnabled(true);//no fluo details to set since mongo has no fluo support
        final BasicDBList pcjs = (BasicDBList) pcjIndexDBO.get(PCJ_PCJS_KEY);
        if (pcjs != null) {
            for (int ii = 0; ii < pcjs.size(); ii++) {
                final BasicDBObject pcj = (BasicDBObject) pcjs.get(ii);
                pcjBuilder.addPCJDetails(toPCJDetails(pcj));
            }
        }
    }
    return pcjBuilder;
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:19,代码来源:MongoDetailsAdapter.java

示例3: getYagoTypeLabel

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
public String getYagoTypeLabel(String uri){
    
    DBCursor cursor = db.getCollection("entities_yago").find(new BasicDBObject().append("uri", uri));
    
    if(cursor.size() > 0){
        DBObject tmp = cursor.next();
        BasicDBList labels = (BasicDBList)tmp.get("labels");
        
        if(labels != null){
            DBObject tmp2 = (DBObject)labels.get(0);
            return tmp2.get("label").toString();
        }
    }
    
    return null;

}
 
开发者ID:entityclassifier-eu,项目名称:entityclassifier-core,代码行数:18,代码来源:YagoOntologyManager.java

示例4: packBackgroundsInToScenarios

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
/**
 * go through find all the backgrounds elements and nest them in their scenarios (simplifies application logic downstream)
 */
protected void packBackgroundsInToScenarios(final DBObject feature) {
	final List<DBObject> packedScenarios = new ArrayList<DBObject>();
	// go through all the backgrounds /scenarios
	final BasicDBList elements = (BasicDBList) feature.get("elements");
	if (elements != null) {
		for (int i = 0; i < elements.size(); i++) {
			final DBObject element = (DBObject) elements.get(i);
			if (element.get("type").equals("background")) { // if its a background
				((DBObject) elements.get(i + 1)).put("background", element); // push it in to the next element.
			} else {
				// assume this is a scenario/other top level element and push it to the packed array.
				packedScenarios.add(element);
			}
		}
		elements.clear();
		elements.addAll(packedScenarios);
	}
}
 
开发者ID:orionhealth,项目名称:XBDD,代码行数:22,代码来源:Report.java

示例5: unmarshal

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
@Override
public Object unmarshal(Object obj, boolean lifecycle) {
    if (obj == null || !(obj instanceof BasicDBList)) {
        return null;
    }

    BasicDBList list = (BasicDBList) obj;
    int[] sizes = sizes(list);

    Object array = Array.newInstance(arrayType, sizes);
    for (int i = 0; i < list.size(); i++) {
        Object value = list.get(i);
        Object result = mapper.unmarshal(value, lifecycle);
        Array.set(array, i, result);
    }

    return array;
}
 
开发者ID:hfoxy,项目名称:morphix,代码行数:19,代码来源:ArrayMapper.java

示例6: testQueryFilterDrugName

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
@Test
public void testQueryFilterDrugName() throws UnknownHostException, MongoException {
	assertEquals(50, collection.getCount());
	MongoQueryRunner qr = new MongoQueryRunner();
	String result = qr.query("localhost", "dbname", "fda_enforcement", "{\"openfda.substance_name.0.0\":\"CARBOPLATIN\"}", null, null);
	DBObject record = (DBObject) JSON.parse(result);
	
	assertTrue(record.containsField("count"));
	assertEquals(1, record.get("count"));
	assertTrue(record.containsField("results"));
	assertEquals(1, ((BasicDBList)record.get("results")).size());
	
	BasicDBList results = (BasicDBList)record.get("results");
	DBObject result1 = (DBObject)results.get(0);
	DBObject openfda = (DBObject)result1.get("openfda");
	BasicDBList list1 = (BasicDBList)openfda.get("substance_name");
	BasicDBList list2 = (BasicDBList)list1.get(0);
	assertEquals("CARBOPLATIN", list2.get(0));
}
 
开发者ID:deleidos,项目名称:prototype-20150626,代码行数:20,代码来源:MongoQueryRunnerTest.java

示例7: testQueryFilterRecallArea

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
@Test
public void testQueryFilterRecallArea() throws UnknownHostException, MongoException {
	assertEquals(50, collection.getCount());
	MongoQueryRunner qr = new MongoQueryRunner();
	String result = qr.query("localhost", "dbname", "fda_enforcement", "{\"recall_area\":\"California\"}", null, null);
	DBObject record = (DBObject) JSON.parse(result);
	
	assertTrue(record.containsField("count"));
	assertEquals(1, record.get("count"));
	assertTrue(record.containsField("results"));
	assertEquals(1, ((BasicDBList)record.get("results")).size());
	
	BasicDBList results = (BasicDBList)record.get("results");
	DBObject result1 = (DBObject)results.get(0);
	assertTrue(result1.get("recall_area").toString().indexOf("California") > -1);
}
 
开发者ID:deleidos,项目名称:prototype-20150626,代码行数:17,代码来源:MongoQueryRunnerTest.java

示例8: testQueryLimitFields

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
@Test
public void testQueryLimitFields() throws UnknownHostException, MongoException {
	assertEquals(50, collection.getCount());
	MongoQueryRunner qr = new MongoQueryRunner();
	String result = qr.query("localhost", "dbname", "fda_enforcement", "{\"recall_area\":\"California\"}", "recall_area", null);
	DBObject record = (DBObject) JSON.parse(result);
	
	assertTrue(record.containsField("count"));
	assertEquals(1, record.get("count"));
	assertTrue(record.containsField("results"));
	assertEquals(1, ((BasicDBList)record.get("results")).size());
	
	BasicDBList results = (BasicDBList)record.get("results");
	DBObject result1 = (DBObject)results.get(0);
	assertEquals(1, result1.keySet().size());
	assertTrue(result1.containsField("recall_area"));
}
 
开发者ID:deleidos,项目名称:prototype-20150626,代码行数:18,代码来源:MongoQueryRunnerTest.java

示例9: testDrugCount

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
@Test
public void testDrugCount() throws UnknownHostException, MongoException {
	MongoQueryRunner qr = new MongoQueryRunner();
	String result = qr.drugCount("localhost", "dbname", "fda_enforcement", "Baxter Healthcare Corporation");
	DBObject record = (DBObject) JSON.parse(result);
	
	assertTrue(record.containsField("count"));
	assertEquals(2, record.get("count"));
	assertTrue(record.containsField("results"));
	assertEquals(2, ((BasicDBList)record.get("results")).size());
	
	assertEquals("Baxter Healthcare Corporation", record.get("manufacturer").toString());
	
	BasicDBList results = (BasicDBList)record.get("results");
	assertEquals(2, results.size());
	DBObject drug1 = (DBObject)results.get(0);
	assertEquals("DIANEAL LOW CALCIUM WITH DEXTROSE", drug1.get("drug_name"));
	assertEquals(1, drug1.get("count"));
	assertEquals("Nationwide", ((BasicDBList)drug1.get("recall_area")).get(0).toString());
	
	DBObject drug2 = (DBObject)results.get(1);
	assertEquals("DEXTROSE", drug2.get("drug_name"));
	assertEquals(2, drug2.get("count"));
	assertEquals("Nationwide", ((BasicDBList)drug2.get("recall_area")).get(0).toString());
}
 
开发者ID:deleidos,项目名称:prototype-20150626,代码行数:26,代码来源:MongoQueryRunnerTest.java

示例10: Group

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
/**
 * Create a group based on a Mongo DB Object
 *
 * @param group The existing Mongo DB Object
 */
public Group(DBObject group) {
  this.id = ((ObjectId) group.get(DB_ID)).toString();
  this.name = (String) group.get(JSON_KEY_GROUP_NAME);

  BasicDBList dbMembers = ((BasicDBList) group.get(JSON_KEY_MEMBERS_LIST));
  this.members = new String[dbMembers.size()];
  for (int i = 0; i < dbMembers.size(); i++) {
    members[i] = (String) dbMembers.get(i);
  }
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:16,代码来源:Group.java

示例11: getTotalCount

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
private long getTotalCount() {
    AggregationResults aggregationResults = mongoTemplate.aggregate(
            Aggregation.newAggregation(
                    group("team"),
                    count().as("count")),
            Submission.class, Team.class
    );

    Object results = aggregationResults.getRawResults().get("result");

    if (results != null && results instanceof BasicDBList) {
        BasicDBList resultsList = (BasicDBList) results;

        if (resultsList.isEmpty()) {
            return 0;
        }
        BasicDBObject countResult = (BasicDBObject) resultsList.get(0);

        if (countResult.containsField("count")) {
            return countResult.getLong("count");
        }

        return 0;


    }

    return -1;
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:30,代码来源:SubmissionRepositoryCustomImpl.java

示例12: getTotalItemCountByTeam

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
private long getTotalItemCountByTeam(String teamName) {
    AggregationResults aggregationResults = mongoTemplate.aggregate(
            Aggregation.newAggregation(
                    teamMatchOperation(teamName),
                    groupByAlias(),
                    group().count().as("count")
            ),
            clazz, clazz
    );

    Object results = aggregationResults.getRawResults().get("result");

    if (results != null && results instanceof BasicDBList) {
        BasicDBList resultsList = (BasicDBList) results;

        if (resultsList.isEmpty()) {
            return 0;
        }
        BasicDBObject countResult = (BasicDBObject) resultsList.get(0);

        if (countResult.containsField("count")) {
            return countResult.getLong("count");
        }

        return 0;


    }

    return -1;
}
 
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:32,代码来源:SubmittablesAggregateSupport.java

示例13: testGetZipsWithOrderBy

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
@Test
public void testGetZipsWithOrderBy() throws Exception {
	StringWriter sw = new StringWriter();
	PrintWriter pw = new PrintWriter(sw);

	when(response.getWriter()).thenReturn(pw);
	when(request.getPathInfo()).thenReturn("/zips");
	@SuppressWarnings("serial")
	HashMap<String, String[]> parameterMap = new HashMap<String, String[]>() {
		{
			put("order-by", new String[] { "state, city" });
		}
	};
	when(request.getParameterMap()).thenReturn(parameterMap);

	new MongoCrudServlet().doGet(request, response);

	String result = sw.getBuffer().toString().trim();
	System.out.println("Json Result As String is : " + result.length() + " characters long");
	assertTrue("somehow got a very small JSON resposne: " + result, result.length() > 20);
	BasicDBList json = (BasicDBList) JSON.parse(result);
	for (int i = 0; i < json.size() - 1; i++) {
		BasicDBObject r1 = (BasicDBObject) json.get(i);
		BasicDBObject r2 = (BasicDBObject) json.get(i + 1);
		String k1 = r1.getString("state") + " " + r1.getString("city");
		String k2 = r2.getString("state") + " " + r2.getString("city");
		assertTrue(String.format("records %d and %d were not in the right order: %s vs %s", i, i + 1, k1, k2),
				k1.compareTo(k2) <= 0);
	}

}
 
开发者ID:timbaileyjones,项目名称:nomopojo,代码行数:32,代码来源:MongoCrudServletTest.java

示例14: embedSteps

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
/**
 * go through all the embedded content, store it to GridFS, replace the doc embeddings with a hyperlink to the saved content.
 */
protected void embedSteps(final DBObject feature, final GridFS gridFS, final Coordinates coordinates) {
	final BasicDBList elements = (BasicDBList) feature.get("elements");
	final String featureId = (String) feature.get("_id");
	if (elements != null) {
		for (int j = 0; j < elements.size(); j++) {
			final DBObject scenario = (DBObject) elements.get(j);
			final String scenarioId = (String) scenario.get("_id");
			final BasicDBList steps = (BasicDBList) scenario.get("steps");
			if (steps != null) {
				for (int k = 0; k < steps.size(); k++) {
					final DBObject step = (DBObject) steps.get(k);
					final BasicDBList embeddings = (BasicDBList) step.get("embeddings");
					if (embeddings != null) {
						for (int l = 0; l < embeddings.size(); l++) {
							final DBObject embedding = (DBObject) embeddings.get(l);
							final GridFSInputFile image = gridFS
									.createFile(Base64.decodeBase64(((String) embedding.get("data")).getBytes()));
							image.setFilename(guid());
							final BasicDBObject metadata = new BasicDBObject().append("product", coordinates.getProduct())
									.append("major", coordinates.getMajor()).append("minor", coordinates.getMinor())
									.append("servicePack", coordinates.getServicePack()).append("build", coordinates.getBuild())
									.append("feature", featureId)
									.append("scenario", scenarioId);
							image.setMetaData(metadata);
							image.setContentType((String) embedding.get("mime_type"));
							image.save();
							embeddings.put(l, image.getFilename());
						}
					}
				}
			}
		}
	}
}
 
开发者ID:orionhealth,项目名称:XBDD,代码行数:38,代码来源:Report.java

示例15: getFeatureStatus

import com.mongodb.BasicDBList; //导入方法依赖的package包/类
public static String getFeatureStatus(final DBObject feature) {
	final List<String> allStatuses = new ArrayList<String>();
	final BasicDBList featureElements = (BasicDBList) feature.get("elements");
	if (featureElements != null) {
		for (int i = 0; i < featureElements.size(); i++) {
			final DBObject scenario = (DBObject) featureElements.get(i);
			if (isScenarioKeyword((String) scenario.get("keyword"))) {
				allStatuses.add(getScenarioStatus(scenario));
			}
		}
	}

	final String result = reduceStatuses(allStatuses).getTextName();
	return result;
}
 
开发者ID:orionhealth,项目名称:XBDD,代码行数:16,代码来源:StatusHelper.java


注:本文中的com.mongodb.BasicDBList.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。