Example usage for org.springframework.data.mongodb.core.query Query Query

List of usage examples for org.springframework.data.mongodb.core.query Query Query

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.query Query Query.

Prototype

public Query(CriteriaDefinition criteriaDefinition) 

Source Link

Document

Creates a new Query using the given CriteriaDefinition .

Usage

From source file:lodsve.mongodb.core.GenericMongoRepository.java

private Query getIdQuery(Object id) {
    return new Query(getIdCriteria(id));
}

From source file:com.epam.ta.reportportal.database.dao.ProjectRepositoryCustomImpl.java

@Override
public void addUsers(String projectId, Map<String, UserConfig> users) {
    Query query = Query.query(Criteria.where("_id").is(projectId));
    Update update = new Update();
    // TODO possible bug, only one update!
    for (Map.Entry<String, UserConfig> entry : users.entrySet()) {
        update.set("users." + entry.getKey(), entry.getValue());
    }/*from w w w  . j a v  a2 s.c  o  m*/
    mongoTemplate.updateFirst(query, update, Project.class);
}

From source file:quanlyhocvu.api.mongodb.DAO.HocSinhDAO.java

public List<HocSinhDTO> getHocSinhChuaXepLop() {
    Query query = Query.query(Criteria.where("maLopHoc").is(null));
    return mongoOperations.find(query, HocSinhDTO.class);
}

From source file:com.springsource.html5expense.mongodb.services.ExpenseRepository.java

@Override
public void updateExpense(Long expenseId, Update update) {
    mongoTemplate.updateFirst(new Query(Criteria.where("_id").is(expenseId)), update, EXPENSE_COLLECTION_NAME);
}

From source file:com.epam.ta.reportportal.database.dao.UserFilterRepositoryCustomImpl.java

@Override
public UserFilter findOneLoadACL(String userName, String id, String projectName) {
    Query query = Query.query(where(OWNER).is(userName)).addCriteria(where(ID).is(id))
            .addCriteria(where(PROJECT).is(projectName));
    Query shared = Query.query(where(ID).is(id)).addCriteria(where(ENTRIES).size(1))
            .addCriteria(where(PROJECT).is(projectName));
    query.fields().include(TARGET).include(ACL).include(LINK);
    shared.fields().include(TARGET).include(ACL).include(LINK);
    UserFilter filter = mongoTemplate.findOne(query, UserFilter.class);
    return filter == null ? mongoTemplate.findOne(shared, UserFilter.class) : filter;
}

From source file:demo.SpringNoChangeTest.java

@Test
public void testThreeWithMap() {
    Map values = new HashMap();
    values.put("TITLE", "title three from map loses");
    values.put("DESC", "desc three from map loses");
    Three three = new Three("three", "title three", "desc three", values);
    template.save(three);//from   w  ww . java  2 s . c o m

    Three foundThree = template.findOne(Query.query(Criteria.where("id").is(three.id)), Three.class);
    Assert.assertThat(foundThree.title, Matchers.nullValue());
    Assert.assertThat(foundThree.desc, Matchers.is("desc three"));
    Assert.assertThat((String) foundThree.map.get("TITLE"), Matchers.nullValue());
    Assert.assertThat((String) foundThree.map.get("DESC"), Matchers.is("desc three"));
}

From source file:com.skymobi.monitor.security.MongoUserManager.java

@Override
public User loadUserByUsername(String username) throws UsernameNotFoundException {
    logger.debug("try load user by username={}", username);

    User user = mongoTemplate.findOne(new Query(Criteria.where("username").is(username)), User.class,
            COLLECTION_NAME_USER);/*from w  w  w  .j  a v  a  2s .  co  m*/
    if (user != null && isSystemAdmin(username)) {
        user.setAuthorities(AuthorityUtils.createAuthorityList("ROLE_ADMIN"));
    }
    return user;
}

From source file:org.cbioportal.session_service.domain.internal.SessionRepositoryImpl.java

public List<Session> findBySourceAndType(String source, String type) {
    return this.mongoTemplate.find(new Query(Criteria.where("source").is(source).and("type").is(type)),
            Session.class, type);
}

From source file:strat.mining.multipool.stats.persistence.dao.coinshift.impl.AddressStatsDAOMongo.java

@Override
public List<AddressStats> getAddressStatsSince(Integer addressId, Date time) {
    Query query = new Query(Criteria.where("addressId").is(addressId).and("refreshTime").gte(time));
    query.with(new Sort(Sort.Direction.ASC, "refreshTime"));
    return mongoOperation.find(query, AddressStats.class);
}

From source file:eu.trentorise.smartcampus.profileservice.storage.ProfileStorage.java

public void deleteExtendedProfile(String userId, String profileId) throws DataException {
    Criteria criteria = new Criteria();
    criteria = Criteria.where("content.userId").is(userId).and("content.profileId").is(profileId);
    criteria.and("type").is(ExtendedProfile.class.getCanonicalName());
    criteria.and("deleted").is(false);

    List<ExtendedProfile> profiles = find(Query.query(criteria), ExtendedProfile.class);
    if (!profiles.isEmpty()) {
        deleteObject(profiles.get(0));//from   w ww  .ja  v  a  2s. c om
    }
}