/*
   * (non-Javadoc)
   * @see de.mq.portfolio.exchangerate.support.ExchangeRateDatebaseRepository#exchangerates(java.util.Collection)
   */
  @Override
  public final Collection<ExchangeRate> exchangerates(
      final Collection<ExchangeRate> exchangerates) {
    Assert.notNull(exchangerates);
    final Collection<ExchangeRate> rates = new HashSet<>();
    rates.addAll(exchangerates);

    rates.addAll(
        exchangerates
            .stream()
            .map(er -> new ExchangeRateImpl(er.target(), er.source()))
            .collect(Collectors.toSet()));

    final Collection<ExchangeRate> results = new HashSet<>();
    rates.forEach(
        rate ->
            results.addAll(
                mongoOperations.find(
                    Query.query(
                        Criteria.where(SOURCE_FIELD_NAME)
                            .is(rate.source())
                            .and(TARGET_FIELD_NAME)
                            .is(rate.target())),
                    ExchangeRateImpl.class)));
    return Collections.unmodifiableCollection(results);
  }
  private List<MaintenanceSpendBySupplier> getTruckMaintenanceSpend(
      Truck truck, Date from, Date to) {
    Query truckMaintenanceSpendListQuery = new Query();
    truckMaintenanceSpendListQuery.addCriteria(
        Criteria.where("truckId")
            .is(truck.getId())
            .andOperator(
                Criteria.where("transactionDate").gte(from),
                Criteria.where("transactionDate").lte(to)));

    /*
    * List<MaintenanceSpendBySupplier> maintenanceSpendList = mongoOperation.find(truckMaintenanceSpendListQuery, MaintenanceSpendBySupplier.class);

    System.out.println(" MaintenanceSpendBySupplierRepository - TRUCK QUERY - Start= " + to + " | To= " + to + "  FOR truckId: " + truck.getId());
    if (maintenanceSpendList.isEmpty()) {
    System.out.println("MaintenanceSpendBySupplierRepository  - TRUCK QUERY - NO MATCHING RECORDS FOUND");
    }

    for (MaintenanceSpendBySupplier maintenanceSpend : maintenanceSpendList) {
    System.out.println(" MaintenanceSpendBySupplierRepository - TRUCK QUERY - Date= " + maintenanceSpend.getTransactionDate() + " | Cost= " + maintenanceSpend.getMaintenanceCost() + " | Truck= " + maintenanceSpend.getTruckId() + " | Supplier" + maintenanceSpend.getSupplierId());
    }
    System.out.println("--==--");
    */

    return mongoOperation.find(truckMaintenanceSpendListQuery, MaintenanceSpendBySupplier.class);
  }
 public List<HelloWorld> getManybyName(String name) {
   System.out.println("DAO: Querying all data name:" + name);
   Query query = new Query();
   query.addCriteria(Criteria.where("name").is(name));
   System.out.println("DAO: Return data");
   return mongoOps.find(query, HelloWorld.class, COLLECTION);
 }
  @Override
  public List<MaintenanceSpendBySupplier> getMaintenanceSpendBetweenTwoDates(Date from, Date to) {
    Date fromDate = dateTimeFormatHelper.resetTimeAndMonthStart(from);
    Date toDate = dateTimeFormatHelper.resetTimeAndMonthEnd(to);
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(toDate);
    // Set time fields to last hour:minute:second:millisecond
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MILLISECOND, 999);

    Query maintenanceSpendListQuery = new Query();
    maintenanceSpendListQuery.addCriteria(
        Criteria.where("transactionDate")
            .exists(true)
            .andOperator(
                Criteria.where("transactionDate").gte(fromDate),
                Criteria.where("transactionDate").lte(calendar.getTime())));

    /*
    List<MaintenanceSpendBySupplier> maintenanceSpendList = mongoOperation.find(maintenanceSpendListQuery, MaintenanceSpendBySupplier.class);

    System.out.println(" MaintenanceSpendBySupplierRepository - GENERAL QUERY - Start= " + to + " | To= " + to);
    if (maintenanceSpendList.isEmpty()) {
    System.out.println("MaintenanceSpendBySupplierRepository  - GENERAL QUERY - NO MATCHING RECORDS FOUND");
    }

    for (MaintenanceSpendBySupplier maintenanceSpend : maintenanceSpendList) {
    System.out.println(" MaintenanceSpendBySupplierRepository - GENERAL QUERY - Date= " + maintenanceSpend.getTransactionDate() + " | Cost= " + maintenanceSpend.getMaintenanceCost() + " | Truck= " + maintenanceSpend.getTruckId() + " | Supplier" + maintenanceSpend.getSupplierId());
    }
    System.out.println("--==--");
    */
    return mongoOperation.find(maintenanceSpendListQuery, MaintenanceSpendBySupplier.class);
  }
  public PackageInfo GetTracking(String idPaquete) {
    Query query = new Query();
    query.addCriteria(Criteria.where("_id").is(idPaquete));

    List<PackageInfo> packs = mongoOperations.find(query, PackageInfo.class);
    if (packs.size() > 0) return packs.get(0);
    else return null;
  }
Beispiel #6
0
 @Override
 public boolean userExists(String username) {
   Query query = new Query(Criteria.where("username").is(username));
   if (mongoOperations.find(query, User.class).isEmpty()) {
     return false;
   }
   return true;
 }
 private String getEntityOwnerTenant(final EntityResource entityResource) {
   final Class<?> collectionClass =
       (entityBelongsToProvider(entityResource) ? Provider.class : Application.class);
   final Criteria criteria = Criteria.where("_id").is(entityResource.getEntityOwner());
   final TenantResource entityOwner =
       (TenantResource) mongoOps.find(new Query(criteria), collectionClass).get(0);
   return entityOwner.getTenantId();
 }
 /** {@link RepositoryOperations#findAll} */
 public List<T> find(Iterable<QueryCriteria> queryCriterias, Sort sort) {
   Criteria criteria = MongoQueryUtils.getQueryFromQueryCriteria(queryCriterias);
   Query query = new Query();
   if (criteria != null) {
     query.addCriteria(criteria);
   }
   return mongoOperations.find(query.with(sort), model);
 }
Beispiel #9
0
  @Override
  public List<Compte> listerComptes(int offset, int limit, Direction direction) {
    final Query query = new Query();
    query.skip(offset);
    query.limit(limit);

    query.with(new Sort(direction, Constantes.ChampCollectionCompte.IDCOMPTE));
    return mongoOperations.find(query, Compte.class);
  }
 /** {@link RepositoryOperations#findAll} */
 public Page<T> find(Iterable<QueryCriteria> queryCriterias, Pageable pageable) {
   Criteria criteria = MongoQueryUtils.getQueryFromQueryCriteria(queryCriterias);
   Query query = new Query();
   if (criteria != null) {
     query.addCriteria(criteria);
   }
   List<T> entities = mongoOperations.find(query.with(pageable), model);
   long count = count(queryCriterias);
   return new PageImpl<T>(entities, pageable, count);
 }
 @Override
 public Collection<E> findAllAtivos() {
   final Query query = query(where("ativo").is(true)).addCriteria(getTypeCriteria());
   return new ArrayList<>(operations.find(query, type));
 }
 public List<PackageInfo> GetAllPackages() {
   return mongoOperations.find(new Query(), PackageInfo.class);
 }
 /** {@link RepositoryOperations#findAll} */
 public List<T> findAll(Sort sort) {
   return mongoOperations.find(new Query().with(sort), model);
 }
 /** {@link RepositoryOperations#findAll} */
 public Page<T> findAll(Pageable pageable) {
   List<T> entities = mongoOperations.find(new Query().with(pageable), model);
   long count = count();
   return new PageImpl<T>(entities, pageable, count);
 }
 @Override
 public Collection<E> findAll() {
   final Query query = query(getTypeCriteria());
   return new ArrayList<>(operations.find(query, type));
 }
 public List<CreditTransaction> getAllTransactionByUserId(String userId)
     throws UnknownHostException {
   Query query = new Query();
   query.addCriteria(where("user_Id").is(userId));
   return transactionMongoOps.find(query, CreditTransaction.class);
 }
 public List<Article> findArticlesByAuthor(Author author) {
   Query query = query(where("author").is(author));
   return operations.find(query, Article.class);
 }