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,7 +21,9 @@ public class HttpService {
public JSONObject post(String url, JSONObject postData) { public JSONObject post(String url, JSONObject postData) {
log.debug("Service call: {}", url); log.debug("Service call: {}", url);
JSONObject response = new JSONObject(Optional.ofNullable(client JSONObject response = null;
try {
response = new JSONObject(Optional.ofNullable(client
.post() .post()
.uri(url) .uri(url)
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
@ -29,7 +31,10 @@ public class HttpService {
.accept(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)
.retrieve() .retrieve()
.bodyToMono(String.class) .bodyToMono(String.class)
.block()).orElse("{response:\"empty\"}")); .toFuture().get()).orElse("{response:\"empty\"}"));
} catch (Exception e) {
return new JSONObject("{response:\"empty\"}");
}
log.debug("Service response: {}", response); log.debug("Service response: {}", response);
return response; return response;
} }

View File

@ -119,7 +119,9 @@ public class TimeSeriesService {
if (ts != null && ts.getValues().size() > 5) { if (ts != null && ts.getValues().size() > 5) {
JSONObject response = httpService.post(TIME_SERIES_TENDENCY_URL, new JSONObject(new SmoothingTimeSeries(ts))); JSONObject response = httpService.post(TIME_SERIES_TENDENCY_URL, new JSONObject(new SmoothingTimeSeries(ts)));
LOG.debug("Успешно отправлен на сервис сглаживания"); LOG.debug("Успешно отправлен на сервис сглаживания");
response.get("timeSeries"); if (response.has("response") && response.getString("response").equals("empty")) {
return 0.0;
}
JSONArray jsonArray = response.getJSONObject("timeSeries").getJSONArray("values"); JSONArray jsonArray = response.getJSONObject("timeSeries").getJSONArray("values");
return jsonArray.getJSONObject(jsonArray.length() - 1).getDouble("value"); 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.javax.management.remote.rmi=off
logging.level.java.rmi.server=off logging.level.java.rmi.server=off
extractor.custom-projects-dir= extractor.custom-projects-dir=
server.error.include-stacktrace=always
server.error.include-exception=true
server.error.include-message=always
# Thymeleaf Settings # Thymeleaf Settings
spring.thymeleaf.cache=false spring.thymeleaf.cache=false
messages.basename.path=messages_en.properties messages.basename.path=messages_en.properties

View File

@ -32,16 +32,26 @@
</p> </p>
<div class="collapse" id="collapseExample"> <div class="collapse" id="collapseExample">
<p class="card card-body"> <p class="card card-body">
<div th:utext="'Failed URL: ' + ${url}" th:remove="tag">${url}</div> <div>
</p> <span><strong>Status</strong></span>
<div th:if="${exception != null}" th:utext="'Exception: ' + ${exception.message}" th:remove="tag"> <span th:text="${status}"></span>
${exception.message} </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> </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> </div>
</div> </div>