Пример #1
0
 private void writeParameters(JsonWriter json, QProfileActivity event) {
   json.name("params").beginObject().prop("severity", event.severity());
   for (Entry<String, String> param : event.parameters().entrySet()) {
     json.prop(param.getKey(), param.getValue());
   }
   json.endObject();
 }
Пример #2
0
  private Result<QProfileActivity> searchActivities(
      QProfileActivityQuery query, SearchOptions options) {
    DbSession session = dbClient.openSession(false);
    try {
      SearchResponse response = activityIndex.doSearch(query, options);
      Result<QProfileActivity> result = new Result<>(response);
      for (SearchHit hit : response.getHits().getHits()) {
        QProfileActivity profileActivity = new QProfileActivity(hit.getSource());
        RuleDto ruleDto = dbClient.ruleDao().getNullableByKey(session, profileActivity.ruleKey());
        profileActivity.ruleName(ruleDto != null ? ruleDto.getName() : null);

        String login = profileActivity.getLogin();
        if (login != null) {
          UserDto user = dbClient.userDao().selectActiveUserByLogin(session, login);
          profileActivity.authorName(user != null ? user.getName() : null);
        }
        result.getHits().add(profileActivity);
      }
      return result;
    } finally {
      session.close();
    }
  }
Пример #3
0
 private void writeResponse(JsonWriter json, Result<QProfileActivity> result, Paging paging) {
   json.beginObject();
   json.prop("total", result.getTotal());
   json.prop(Param.PAGE, paging.pageIndex());
   json.prop(Param.PAGE_SIZE, paging.pageSize());
   json.name("events").beginArray();
   for (QProfileActivity event : result.getHits()) {
     json.beginObject()
         .prop("date", DateUtils.formatDateTime(event.getCreatedAt()))
         .prop("authorLogin", event.getLogin())
         .prop("authorName", event.authorName())
         .prop("action", event.getAction())
         .prop("ruleKey", event.ruleKey().toString())
         .prop("ruleName", event.ruleName());
     writeParameters(json, event);
     json.endObject();
   }
   json.endArray();
   json.endObject().close();
 }