本文整理汇总了Java中com.mongodb.client.model.Projections类的典型用法代码示例。如果您正苦于以下问题:Java Projections类的具体用法?Java Projections怎么用?Java Projections使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Projections类属于com.mongodb.client.model包,在下文中一共展示了Projections类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPendingDataLoader
import com.mongodb.client.model.Projections; //导入依赖的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: getServerDeployment
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@GET
@Path("services/server/{environment}/{hostname}/deployment/{applicationId}")
@ApiOperation(value = "Get a deployed application on the server", response = Deployment.class)
public Deployment getServerDeployment(
@ApiParam("Server hostname") @PathParam("hostname") String hostname,
@ApiParam("Environment") @PathParam("environment") String environment,
@ApiParam("Application id") @PathParam("applicationId") String applicationId
) {
final Document document = database.getCollection(Collections.SERVERS)
.find(Filters.and(
Filters.eq("environment", environment),
Filters.eq("hostname", hostname)
)).projection(Projections.elemMatch("deployments",
Filters.eq("applicationId", applicationId)
)).first();
if (document == null) {
throw new WebApplicationException(Status.NOT_FOUND);
}
final Deployment deployment = Mapper.mapObject(document, "deployments", Deployment::fromDeploymentBson);
if (deployment == null) {
throw new WebApplicationException(Status.NOT_FOUND);
}
return deployment;
}
示例3: list
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Override
public Pagination<VerseBean> list(VerseBean filter, Integer firstResult, Integer maxResults) {
MongoCollection<VerseBeanImpl> coll = this.persistenceManager.fetchCollection(VerseBeanImpl.class);
Pagination<VerseBean> pagination = new Pagination<VerseBean>();
pagination.setSize(this.countQueryResult(coll, this.createBasicFilter(filter)));
FindIterable<VerseBeanImpl> iterable = coll.find(this.createBasicFilter(filter))
.skip(firstResult - 1)
.limit(maxResults)
.projection(Projections.include("_id", "number", "chapter_id"));
Iterator<VerseBeanImpl> iterator = iterable.iterator();
List<VerseBean> verses = new ArrayList<>();
while (iterator.hasNext()) {
verses.add(iterator.next());
}
pagination.setElements(verses);
return pagination;
}
示例4: list
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Override
public Pagination<BibleBean> list(BibleBean filter, Integer firstResult, Integer maxResults) {
MongoCollection<BibleBeanImpl> coll = this.persistenceManager.fetchCollection(BibleBeanImpl.class);
Pagination<BibleBean> pagination = new Pagination<BibleBean>();
pagination.setSize(this.countQueryResult(coll, this.createBasicFilter(filter)));
FindIterable<BibleBeanImpl> iterable = coll.find(this.createBasicFilter(filter))
.skip(firstResult - 1)
.limit(maxResults)
.projection(Projections.include("_id", "name", "language"));
Iterator<BibleBeanImpl> iterator = iterable.iterator();
List<BibleBean> bibles = new ArrayList<>();
while (iterator.hasNext()) {
bibles.add(iterator.next());
}
pagination.setElements(bibles);
return pagination;
}
示例5: testInsertAndFind
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Test
public void testInsertAndFind() {
MongoDatabase db = connect();
CharacterPojo pojo = insert(db);
MongoCollection<CharacterPojo> coll = db.getCollection(COLL_NAME,
CharacterPojo.class);
CharacterPojo read = coll.find().first();
assertThat(read).isEqualToComparingFieldByField(pojo);
CharacterPojo empty = coll.find().projection(Projections.include("id")).first();
assertThat(empty.getScalarPrimitive()).isEqualTo((char) 0);
assertThat(empty.getScalar()).isNull();
assertThat(empty.getArray()).isNull();
assertThat(empty.getArrayPrimitive()).isNull();
assertThat(empty.getArray2()).isNull();
assertThat(empty.getArray2Primitive()).isNull();
assertThat(empty.getList()).isNull();
assertThat(empty.getSet()).isNull();
assertThat(empty.getMap()).isNull();
}
示例6: testInsertAndFind
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Test
public void testInsertAndFind() {
MongoDatabase db = connect();
StringPojo pojo = insert(db);
MongoCollection<StringPojo> coll = db.getCollection(COLL_NAME, StringPojo.class);
StringPojo read = coll.find().first();
assertThat(read).isEqualToComparingFieldByField(pojo);
StringPojo empty = coll.find().projection(Projections.include("id")).first();
assertThat(empty.getScalar()).isNull();
assertThat(empty.getArray()).isNull();
assertThat(empty.getArray2()).isNull();
assertThat(empty.getList()).isNull();
assertThat(empty.getSet()).isNull();
assertThat(empty.getMap()).isNull();
}
示例7: testInsertAndFind
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Test
public void testInsertAndFind() {
MongoDatabase db = connect();
ShortPojo pojo = insert(db);
MongoCollection<ShortPojo> coll = db.getCollection(COLL_NAME, ShortPojo.class);
ShortPojo read = coll.find().first();
assertThat(read).isEqualToComparingFieldByField(pojo);
ShortPojo empty = coll.find().projection(Projections.include("id")).first();
assertThat(empty.getScalarPrimitive()).isEqualTo((short) 0);
assertThat(empty.getScalar()).isNull();
assertThat(empty.getArray()).isNull();
assertThat(empty.getArrayPrimitive()).isNull();
assertThat(empty.getArray2()).isNull();
assertThat(empty.getArray2Primitive()).isNull();
assertThat(empty.getList()).isNull();
assertThat(empty.getSet()).isNull();
assertThat(empty.getMap()).isNull();
}
示例8: testInsertAndFind
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Test
public void testInsertAndFind() {
MongoDatabase db = connect();
LongPojo pojo = insert(db);
MongoCollection<LongPojo> coll = db.getCollection(COLL_NAME, LongPojo.class);
LongPojo read = coll.find().first();
assertThat(read).isEqualToComparingFieldByField(pojo);
LongPojo empty = coll.find().projection(Projections.include("id")).first();
assertThat(empty.getScalarPrimitive()).isEqualTo(0L);
assertThat(empty.getScalar()).isNull();
assertThat(empty.getArray()).isNull();
assertThat(empty.getArrayPrimitive()).isNull();
assertThat(empty.getArray2()).isNull();
assertThat(empty.getArray2Primitive()).isNull();
assertThat(empty.getList()).isNull();
assertThat(empty.getSet()).isNull();
assertThat(empty.getMap()).isNull();
}
示例9: testInsertAndFind
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Test
public void testInsertAndFind() {
MongoDatabase db = connect();
MonthPojo pojo = insert(db);
MongoCollection<MonthPojo> coll = db.getCollection(COLL_NAME, MonthPojo.class);
MonthPojo read = coll.find().first();
assertThat(read).isEqualToComparingFieldByField(pojo);
MonthPojo empty = coll.find().projection(Projections.include("id")).first();
assertThat(empty.getScalar()).isNull();
assertThat(empty.getArray()).isNull();
assertThat(empty.getArray2()).isNull();
assertThat(empty.getList()).isNull();
assertThat(empty.getSet()).isNull();
assertThat(empty.getMap()).isNull();
}
示例10: testInsertAndFind
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Test
public void testInsertAndFind() {
MongoDatabase db = connect();
DatePojo pojo = insert(db);
MongoCollection<DatePojo> coll = db.getCollection(COLL_NAME, DatePojo.class);
DatePojo read = coll.find().first();
assertThat(read).isEqualToComparingFieldByField(pojo);
DatePojo empty = coll.find().projection(Projections.include("id")).first();
assertThat(empty.getScalar()).isNull();
assertThat(empty.getArray()).isNull();
assertThat(empty.getArray2()).isNull();
assertThat(empty.getList()).isNull();
assertThat(empty.getSet()).isNull();
assertThat(empty.getMap()).isNull();
}
示例11: testInsertAndFind
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Test
public void testInsertAndFind() {
MongoDatabase db = connect();
BooleanPojo pojo = insert(db);
MongoCollection<BooleanPojo> coll = db.getCollection(COLL_NAME,
BooleanPojo.class);
BooleanPojo read = coll.find().first();
assertThat(read).isEqualToComparingFieldByField(pojo);
BooleanPojo empty = coll.find().projection(Projections.include("id")).first();
assertThat(empty.getScalarPrimitive()).isEqualTo(false);
assertThat(empty.getScalar()).isNull();
assertThat(empty.getArray()).isNull();
assertThat(empty.getArrayPrimitive()).isNull();
assertThat(empty.getArray2()).isNull();
assertThat(empty.getArray2Primitive()).isNull();
assertThat(empty.getList()).isNull();
assertThat(empty.getSet()).isNull();
assertThat(empty.getMap()).isNull();
}
示例12: testInsertAndFind
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Test
public void testInsertAndFind() {
MongoDatabase db = connect();
Decimal128Pojo pojo = insert(db);
MongoCollection<Decimal128Pojo> coll = db.getCollection(COLL_NAME,
Decimal128Pojo.class);
Decimal128Pojo read = coll.find().first();
assertThat(read).isEqualToComparingFieldByField(pojo);
Decimal128Pojo empty = coll.find().projection(Projections.include("id")).first();
assertThat(empty.getScalar()).isNull();
assertThat(empty.getArray()).isNull();
assertThat(empty.getArray2()).isNull();
assertThat(empty.getList()).isNull();
assertThat(empty.getSet()).isNull();
assertThat(empty.getMap()).isNull();
}
示例13: testInsertAndFind
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Test
public void testInsertAndFind() {
MongoDatabase db = connect();
YearPojo pojo = insert(db);
MongoCollection<YearPojo> coll = db.getCollection(COLL_NAME, YearPojo.class);
YearPojo read = coll.find().first();
assertThat(read).isEqualToComparingFieldByField(pojo);
YearPojo empty = coll.find().projection(Projections.include("id")).first();
assertThat(empty.getScalar()).isNull();
assertThat(empty.getArray()).isNull();
assertThat(empty.getArray2()).isNull();
assertThat(empty.getList()).isNull();
assertThat(empty.getSet()).isNull();
assertThat(empty.getMap()).isNull();
}
示例14: testInsertAndFind
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Test
public void testInsertAndFind() {
MongoDatabase db = connect();
DoublePojo pojo = insert(db);
MongoCollection<DoublePojo> coll = db.getCollection(COLL_NAME, DoublePojo.class);
DoublePojo read = coll.find().first();
assertThat(read).isEqualToComparingFieldByField(pojo);
DoublePojo empty = coll.find().projection(Projections.include("id")).first();
assertThat(empty.getScalarPrimitive()).isEqualTo(0.0f);
assertThat(empty.getScalar()).isNull();
assertThat(empty.getArray()).isNull();
assertThat(empty.getArrayPrimitive()).isNull();
assertThat(empty.getArray2()).isNull();
assertThat(empty.getArray2Primitive()).isNull();
assertThat(empty.getList()).isNull();
assertThat(empty.getSet()).isNull();
assertThat(empty.getMap()).isNull();
}
示例15: testInsertAndFind
import com.mongodb.client.model.Projections; //导入依赖的package包/类
@Test
public void testInsertAndFind() {
MongoDatabase db = connect();
FloatPojo pojo = insert(db);
MongoCollection<FloatPojo> coll = db.getCollection(COLL_NAME, FloatPojo.class);
FloatPojo read = coll.find().first();
assertThat(read).isEqualToComparingFieldByField(pojo);
FloatPojo empty = coll.find().projection(Projections.include("id")).first();
assertThat(empty.getScalarPrimitive()).isEqualTo(0.0f);
assertThat(empty.getScalar()).isNull();
assertThat(empty.getArray()).isNull();
assertThat(empty.getArrayPrimitive()).isNull();
assertThat(empty.getArray2()).isNull();
assertThat(empty.getArray2Primitive()).isNull();
assertThat(empty.getList()).isNull();
assertThat(empty.getSet()).isNull();
assertThat(empty.getMap()).isNull();
}