WIP: страницы для правил #62

Closed
Ghost wants to merge 132 commits from master into 61-rules-pages
4 changed files with 39 additions and 19 deletions
Showing only changes of commit 9aa05b83e2 - Show all commits

View File

@ -21,15 +21,20 @@ public class HttpService {
public JSONObject post(String url, JSONObject postData) {
log.debug("Service call: {}", url);
JSONObject response = new JSONObject(Optional.ofNullable(client
.post()
.uri(url)
.contentType(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromValue(postData.toString()))
.accept(MediaType.APPLICATION_JSON)
.retrieve()
.bodyToMono(String.class)
.block()).orElse("{response:\"empty\"}"));
JSONObject response = null;
try {
response = new JSONObject(Optional.ofNullable(client
.post()
.uri(url)
.contentType(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromValue(postData.toString()))
.accept(MediaType.APPLICATION_JSON)
.retrieve()
.bodyToMono(String.class)
.toFuture().get()).orElse("{response:\"empty\"}"));
} catch (Exception e) {
return new JSONObject("{response:\"empty\"}");
}
log.debug("Service response: {}", response);
return response;
}

View File

@ -119,7 +119,9 @@ public class TimeSeriesService {
if (ts != null && ts.getValues().size() > 5) {
JSONObject response = httpService.post(TIME_SERIES_TENDENCY_URL, new JSONObject(new SmoothingTimeSeries(ts)));
LOG.debug("Успешно отправлен на сервис сглаживания");
response.get("timeSeries");
if (response.has("response") && response.getString("response").equals("empty")) {
return 0.0;
}
JSONArray jsonArray = response.getJSONObject("timeSeries").getJSONArray("values");
return jsonArray.getJSONObject(jsonArray.length() - 1).getDouble("value");
}

View File

@ -11,6 +11,9 @@ logging.level.sun.rmi.transport=off
logging.level.javax.management.remote.rmi=off
logging.level.java.rmi.server=off
extractor.custom-projects-dir=
server.error.include-stacktrace=always
server.error.include-exception=true
server.error.include-message=always
# Thymeleaf Settings
spring.thymeleaf.cache=false
messages.basename.path=messages_en.properties

View File

@ -32,16 +32,26 @@
</p>
<div class="collapse" id="collapseExample">
<p class="card card-body">
<div th:utext="'Failed URL: ' + ${url}" th:remove="tag">${url}</div>
</p>
<div th:if="${exception != null}" th:utext="'Exception: ' + ${exception.message}" th:remove="tag">
${exception.message}
<div>
<span><strong>Status</strong></span>
<span th:text="${status}"></span>
</div>
<div>
<span><strong>Error</strong></span>
<span th:text="${error}"></span>
</div>
<div>
<span><strong>Message</strong></span>
<span th:text="${message}"></span>
</div>
<div th:if="${exception != null}">
<span><strong>Exception</strong></span>
<span th:text="${exception}"></span>
</div>
<div th:if="${trace != null}">
<span><strong>Stacktrace</strong></span>
<span th:text="${trace}"></span>
</div>
<ul th:remove="tag">
<li th:if="${exception != null && exception.stackTrace != null}" th:each="ste : ${exception.stackTrace}"
th:remove="tag"><span
th:utext="${ste}" th:remove="tag">${ste}</span></li>
</ul>
</div>
</div>
</div>