Example usage for org.springframework.data.mongodb.core.query Criteria where

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

Introduction

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

Prototype

public static Criteria where(String key) 

Source Link

Document

Static factory method to create a Criteria using the provided key

Usage

From source file:com.telefonica.euro_iaas.sdc.puppetwrapper.services.impl.CatalogManagerMongoImpl.java

public Node getNode(String nodeName) {
    Query searchNodeQuery = new Query(Criteria.where("id").is(nodeName));
    Node savedNode = mongoTemplate.findOne(searchNodeQuery, Node.class);
    if (savedNode == null) {
        throw new NoSuchElementException(format("The node {0} could not be found", nodeName));
    }/* w ww. java2s  . c o  m*/
    return savedNode;
}

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

public GiaoVienDTO getById(String id) {
    Query query = Query.query(Criteria.where("id").is(id));
    GiaoVienDTO obj = mongoOperations.findOne(query, GiaoVienDTO.class);
    return obj;//from w  w  w .j a v  a  2s  .co  m
}

From source file:data.repository.pragma.mongo.StagingDBRepository.java

public GridFSDBFile findDOByKey(String key, String value) {
    return stagingDBTemplate.findOne(Query.query(Criteria.where(key).is(value)));
}

From source file:org.ingini.mongodb.spring.example.update.TestUpdate.java

@Test
public void shouldAddFieldToTheLightbringer() {
    //GIVEN/* www .  j  av a  2s. c o m*/
    CollectionManager.cleanAndFill(mongoTemplate.getDb(), "weapons.json", WEAPONS);

    WeaponDetails details = new WeaponDetails(
            "The one who pulls out this sword from fire will be named Lord's Chosen ...", "Azor Ahai");

    //WHEN
    mongoTemplate.findAndModify(Query.query(Criteria.where("_id").is("Lightbringer")),
            new Update().set("details", details), Weapon.class);

    //AND WHEN
    Weapon weapon = mongoTemplate.findOne(Query.query(Criteria.where("_id").is("Lightbringer")), Weapon.class);

    //THEN
    assertThat(weapon).isNotNull();
}

From source file:com.epam.ta.reportportal.database.search.ModifiableQueryBuilder.java

/**
 * Find entities modified lately//ww w .  ja  va 2 s.  com
 * 
 * @param period
 * @param testItem
 * @return
 */
public static Query findModifiedLately(final Time period, final TestItem testItem) {
    return findModifiedLately(period).addCriteria(Criteria.where(TESTITEM_REF).is(testItem.getId()));
}

From source file:com.epam.ta.reportportal.database.search.ConditionParameterizedTest.java

@Test
public void checkEquals() {
    Filter filter = new Filter(TestItem.class, condition, false, toFind,
            criteriaMap.getCriteriaHolder(fieldName).getFilterCriteria());
    Criteria criteria = Criteria.where(TEST_QUERY_FIELD);
    condition.addCondition(criteria, filter.getFilterConditions().iterator().next(),
            criteriaMap.getCriteriaHolder(fieldName));
}

From source file:org.maodian.flyingcat.im.shiro.MongoRealm.java

@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    UsernamePasswordToken upToken = (UsernamePasswordToken) token;
    String username = upToken.getUsername();
    if (StringUtils.isBlank(username)) {
        throw new AccountException("Null or blank usernames are not allowed by this realm.");
    }//from  w w  w.  ja v a 2 s  .co  m
    Account user = template.findOne(Query.query(Criteria.where("username").is(username)), Account.class);
    if (user == null) {
        throw new AccountException("No user found for username:" + username);
    }

    SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(username, user.getPassword(), getName());
    return info;
}

From source file:jp.co.ctc_g.rack.connector.process.WooreaProcessRepository.java

@Override
public void delete(String groupId, String pid) {

    operations.remove(new Query().addCriteria(Criteria.where("groupId").is(groupId))
            .addCriteria(Criteria.where("metadata.pid").is(pid)), WooreaProcess.class);
}

From source file:tv.arte.resteventapi.core.domain.repositories.impl.mongo.db.RestEventRepositoryImpl.java

/**
 * {@inheritDoc}//from   w  w w  . j  a  v  a  2 s  .  c o m
 */
public List<RestEvent> findEventsForScheduling(Date beforeDate) {

    Query query = new Query(
            Criteria.where("status").ne(RestEventStatus.SENT.name()).and("nextExecution").lt(beforeDate));

    return mongoTemplate.find(query, RestEvent.class);
}

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

@Override
public void deleteAddressStats(Integer addressId) {
    Query query = new Query(Criteria.where("addressId").is(addressId));
    mongoOperation.remove(query, AddressStats.class);
}