예제 #1
0
  public PlayerMention retrievePlayerMentionForPlayerAndSelectioner(
      String player, String selectioner) {

    Select select = QueryBuilder.select().from("player_mention");
    select.where(QueryBuilder.eq("player", player));
    select.where(QueryBuilder.eq("selectioner_email", selectioner));

    return this.cassandraOperations.selectOne(select, PlayerMention.class);
  }
  public List<LogEvent> findByAppIdContains(
      final String appId, String token, LogEvent lastRow, int limit, boolean isPrevPaging) {
    Select sel = QueryBuilder.select().from(table).limit(limit);
    Where w = sel.where(QueryBuilder.eq(pkCols[0], appId));

    w.and(
        QueryBuilder.eq(
            luceneCol,
            Builder.search()
                .filter(Builder.phrase(logTextCol, token))
                .sort(SortField.field(timeuuidCol).reverse(isPrevPaging))
                .build()));

    if (lastRow != null) {
      w.and(
          isPrevPaging
              ? QueryBuilder.gt(timeuuidCol, lastRow.getId().getTimestamp())
              : QueryBuilder.lt(timeuuidCol, lastRow.getId().getTimestamp()));
    }

    log.debug(">>>>>>>>> Firing select query: " + sel.toString());
    List<LogEvent> events = cassandraOperations.select(sel, LogEvent.class);
    if (isPrevPaging) {
      Collections.sort(
          events,
          new Comparator<LogEvent>() {

            @Override
            public int compare(LogEvent o1, LogEvent o2) {
              return o2.getId().getTimestamp().compareTo(o1.getId().getTimestamp());
            }
          });
    }
    return events;
  }
  public List<LogEvent> findByAppId(
      final String appId, LogEvent lastRow, int limit, boolean isPrevPaging) {
    Select sel = QueryBuilder.select().from(table).limit(limit);
    Where w = sel.where(QueryBuilder.eq(pkCols[0], appId));
    if (lastRow != null) {
      w.and(
          isPrevPaging
              ? QueryBuilder.gt(timeuuidCol, lastRow.getId().getTimestamp())
              : QueryBuilder.lt(timeuuidCol, lastRow.getId().getTimestamp()));
    }

    if (isPrevPaging) sel.orderBy(QueryBuilder.asc(timeuuidCol));

    log.debug(">>>>>>>>> Firing select query: " + sel.toString());
    List<LogEvent> events = cassandraOperations.select(sel, LogEvent.class);
    if (isPrevPaging) {
      Collections.sort(
          events,
          new Comparator<LogEvent>() {

            @Override
            public int compare(LogEvent o1, LogEvent o2) {
              return o2.getId().getTimestamp().compareTo(o1.getId().getTimestamp());
            }
          });
    }
    return events;
  }
예제 #4
0
  public UserSelection retrieveUserSelectionForEmail(String email) {

    Select select = QueryBuilder.select().from("user_selection");
    select.where(QueryBuilder.eq("email", email));

    return this.cassandraOperations.selectOne(select, UserSelection.class);
  }
예제 #5
0
  public Collection<PlayerMention> retrievePlayerMentionsForPlayer(String player) {

    Select select = QueryBuilder.select().from("player_mention");
    select.where(QueryBuilder.eq("player", player));

    return this.cassandraOperations.select(select, PlayerMention.class);
  }
  @Override
  public List<DocumentMetadata> searchByUploader(String uploader) {
    Select select = QueryBuilder.select().from("documents");
    select.where(QueryBuilder.eq("uploaded_by", uploader));

    return DocumentMetadataMapping.unwrapList(
        cassandraOperations.select(select, DocumentMetadataMapping.class));
  }
  @Override
  public List<DocumentMetadata> searchByUploadTime(long from, long to) {
    Select select = QueryBuilder.select().from("documents");
    select.where(QueryBuilder.gte("upload_time", from)).and(QueryBuilder.lte("upload_time", to));
    select.allowFiltering();

    return DocumentMetadataMapping.unwrapList(
        cassandraOperations.select(select, DocumentMetadataMapping.class));
  }
예제 #8
0
 @Override
 public void processMessage(Message message) throws MessageProcessingException {
   String payload = message.getPayload();
   String dttm = message.getHeader().getDttm();
   try {
     Map<String, String> payloadMap = mapper.readValue(payload, Map.class);
     Integer userId = Integer.valueOf(payloadMap.get("UserId"));
     String tracker = payloadMap.get("Tracker");
     HeartTracker heartTracker = null;
     Select select = QueryBuilder.select().from("heart_tracker");
     select.where(QueryBuilder.eq("user_id", userId));
     select.where(QueryBuilder.eq("httr_tracker", tracker));
     select.allowFiltering();
     List<HeartTracker> heartTrackers = cassandraTemplate.select(select, HeartTracker.class);
     if (heartTrackers.size() == 0) {
       heartTracker = new HeartTracker();
       heartTracker.setHttrId(UUID.randomUUID());
       heartTracker.setUserId(userId);
       heartTracker.setHttrTracker(tracker);
       heartTracker.setCreatedDttm(new Date());
       heartTracker.setDeleteFl(Boolean.FALSE);
       heartTracker.setPtnId(1);
       cassandraTemplate.insert(heartTracker);
     } else {
       heartTracker = heartTrackers.get(0);
     }
     HeartRate heartRate = new HeartRate();
     heartRate.setHtrtId(UUID.randomUUID());
     heartRate.setHttrId(heartTracker.getHttrId());
     heartRate.setHtrtDttm(formatter.parse(dttm));
     heartRate.setHtrtValue(Integer.valueOf(payloadMap.get("Value")));
     heartRate.setUserId(userId);
     heartRate.setCreatedDttm(new Date());
     heartRate.setDeleteFl(Boolean.FALSE);
     heartRate.setPtnId(1);
     cassandraTemplate.insert(heartRate);
   } catch (IOException e) {
     logger.error("Exception occured in Heart Rate Message Processing. ", e);
     throw new MessageProcessingException(e);
   } catch (ParseException e) {
     logger.error("Exception occured in Date Conversion. Invalid Date. " + dttm, e);
     throw new MessageProcessingException(e);
   }
 }
 @SuppressWarnings("unchecked")
 protected <T extends Entity> T findEntity(T entity) {
   Select selection = select().all().from(tableName(entity));
   selection.where(eq("id", entity.getId()));
   return (T) template.selectOne(selection, entity.getClass());
 }