Skip to content

Commit 06dacaf

Browse files
authored
Merge pull request #149 from q-rapids/develop
Release v1.4
2 parents 765e2d6 + d1fc8be commit 06dacaf

File tree

24 files changed

+12548
-264
lines changed

24 files changed

+12548
-264
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apply plugin: 'jacoco'
2626
apply plugin: 'org.asciidoctor.convert'
2727

2828
group = 'com.upc.gessi.qrapids'
29-
version = '1.3'
29+
version = '1.4'
3030
sourceCompatibility = 1.8
3131

3232
war {

docs/asciidoc/index.adoc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
= Q-Rapids Dashboard API REST Documentation
2-
v1.3, {docdate}
2+
v1.4, {docdate}
33
:toc: left
44

55
:sectnums:
@@ -57,6 +57,21 @@ include::{snippets}/si/historical-conflict/http-response.adoc[]
5757
include::{snippets}/si/historical-read-error/http-response.adoc[]
5858
:numbered:
5959

60+
=== Get current and historical evaluation
61+
62+
operation::si/current_and_historical[snippets='request-parameters,curl-request,response-fields,http-response']
63+
64+
:numbered!:
65+
==== HTTP response wrong project
66+
include::{snippets}/alerts/get-all-wrong-project/http-response.adoc[]
67+
68+
==== HTTP response categories error
69+
include::{snippets}/si/historical-conflict/http-response.adoc[]
70+
71+
==== HTTP response error on ElasticSearch connection
72+
include::{snippets}/si/historical-read-error/http-response.adoc[]
73+
:numbered:
74+
6075

6176
=== Get prediction evaluation
6277

@@ -279,7 +294,7 @@ include::{snippets}/alerts/add-qr-from-alert-backlog-error/http-response.adoc[]
279294

280295
=== Get historical evaluation
281296

282-
operation::qf/current[snippets='request-parameters,curl-request,response-fields,http-response']
297+
operation::qf/historical[snippets='request-parameters,curl-request,response-fields,http-response']
283298

284299
:numbered!:
285300

@@ -294,7 +309,7 @@ include::{snippets}/alerts/add-qr-from-alert-backlog-error/http-response.adoc[]
294309

295310
=== Get historical evaluation for strategic indicator
296311

297-
operation::qf/current-si[snippets='path-parameters,request-parameters,curl-request,response-fields,http-response']
312+
operation::qf/historical-si[snippets='path-parameters,request-parameters,curl-request,response-fields,http-response']
298313

299314
:numbered!:
300315

docs/asciidoc/index.html

Lines changed: 411 additions & 148 deletions
Large diffs are not rendered by default.

docs/index.html

Lines changed: 11345 additions & 71 deletions
Large diffs are not rendered by default.

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ sonar.projectKey=q-rapids_qrapids-dashboard
22

33
sonar.projectName=qrapids-dashboard
44

5-
sonar.projectVersion=1.3
5+
sonar.projectVersion=1.4
66

77
sonar.sources=src/main/java
88
sonar.tests=src/test/java
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
package com.upc.gessi.qrapids.app.presentation.rest.dto;
2+
3+
import com.upc.gessi.qrapids.app.domain.controllers.StrategicIndicatorsController;
4+
import org.springframework.data.util.Pair;
5+
6+
import java.time.LocalDate;
7+
import java.util.List;
8+
9+
public class DTOSICurrentHistoricEvaluation {
10+
//class attributes
11+
private String id;
12+
private Long dbId;
13+
private String prjName;
14+
private String name;
15+
private String description;
16+
private Pair<Float, String> currentValue;
17+
private String currentValueDescription;
18+
private String currentRationale;
19+
private LocalDate currentDate;
20+
private List<DTOSIAssessment> probabilities;
21+
private List<DTOHistoricalData> historicalDataList;
22+
23+
public static class DTOHistoricalData {
24+
private Pair<Float, String> value;
25+
private String valueDescription;
26+
private String rationale;
27+
private LocalDate date;
28+
29+
public DTOHistoricalData(Pair<Float, String> value, String rationale, LocalDate date) {
30+
setValue(value);
31+
this.valueDescription = StrategicIndicatorsController.buildDescriptiveLabelAndValue(value);
32+
setRationale(rationale);
33+
setDate(date);
34+
}
35+
36+
public void setValue(Pair<Float, String> value) {
37+
this.value = value;
38+
}
39+
40+
public Pair<Float, String> getValue() {
41+
return value;
42+
}
43+
44+
public String getValueDescription() {
45+
return valueDescription;
46+
}
47+
48+
public void setValueDescription(String valueDescription) {
49+
this.valueDescription = valueDescription;
50+
}
51+
52+
public void setRationale(String rationale) {
53+
this.rationale = rationale;
54+
}
55+
56+
public String getRationale() {
57+
return rationale;
58+
}
59+
60+
public void setDate(LocalDate date) {
61+
this.date = date;
62+
}
63+
64+
public LocalDate getDate() {
65+
return date;
66+
}
67+
}
68+
69+
public DTOSICurrentHistoricEvaluation(String id, String prjName, String name, String description, Pair<Float, String> value, Long dbId,
70+
String rationale, List<DTOSIAssessment> probabilities, LocalDate date) {
71+
setId(id);
72+
setPrjName(prjName);
73+
setName(name);
74+
setDescription(description);
75+
setCurrentValue(value);
76+
setCurrentRationale(rationale);
77+
setProbabilities(probabilities);
78+
setCurrentDate(date);
79+
setDbId(dbId);
80+
}
81+
82+
public String getId() {
83+
return id;
84+
}
85+
86+
public void setId(String id) {
87+
this.id = id;
88+
}
89+
90+
public Long getDbId() {
91+
return dbId;
92+
}
93+
94+
public void setDbId(Long dbId) {
95+
this.dbId = dbId;
96+
}
97+
98+
public String getPrjName() {
99+
return prjName;
100+
}
101+
102+
public void setPrjName(String prjName) {
103+
this.prjName = prjName;
104+
}
105+
106+
public String getName() {
107+
return name;
108+
}
109+
110+
public void setName(String name) {
111+
this.name = name;
112+
}
113+
114+
public String getDescription() {
115+
return description;
116+
}
117+
118+
public void setDescription(String description) {
119+
if (description != null)
120+
this.description = description;
121+
}
122+
123+
public Pair<Float, String> getCurrentValue() {
124+
return currentValue;
125+
}
126+
127+
public String getCurrentValueDescription() { return currentValueDescription;}
128+
129+
private void setCurrentValueDescription(Pair<Float, String> value) {
130+
this.currentValueDescription = StrategicIndicatorsController.buildDescriptiveLabelAndValue(value);
131+
}
132+
133+
public void setCurrentValue(Pair<Float, String> value) {
134+
this.currentValue = value;
135+
setCurrentValueDescription(value);
136+
}
137+
138+
public void setCurrentRationale(String rationale) {
139+
this.currentRationale = rationale;
140+
}
141+
142+
public String getCurrentRationale() {
143+
return currentRationale;
144+
}
145+
146+
public List<DTOSIAssessment> getProbabilities() {
147+
return probabilities;
148+
}
149+
150+
public void setProbabilities(List<DTOSIAssessment> probabilities) {
151+
this.probabilities = probabilities;
152+
}
153+
154+
public LocalDate getCurrentDate() {
155+
return currentDate;
156+
}
157+
158+
public void setCurrentDate(LocalDate date) {
159+
this.currentDate = date;
160+
}
161+
162+
public List<DTOHistoricalData> getHistoricalDataList() {
163+
return historicalDataList;
164+
}
165+
166+
public void setHistoricalDataList(List<DTOHistoricalData> historicalData) {
167+
this.historicalDataList = historicalData;
168+
}
169+
170+
}

src/main/java/com/upc/gessi/qrapids/app/presentation/rest/services/StrategicIndicators.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,4 +507,40 @@ public LocalDate getcurrentDate(@RequestParam(value = "prj") String prj) {
507507
// if the response is null
508508
return null;
509509
}
510+
511+
@GetMapping("/api/strategicIndicators/current_and_historical")
512+
@ResponseStatus(HttpStatus.OK)
513+
public List<DTOSICurrentHistoricEvaluation> getStrategicIndicatorsCurrentHistoricEvaluation(@RequestParam(value = "prj", required=false) String prj, @RequestParam("from") String from, @RequestParam("to") String to) {
514+
try {
515+
Project project = projectsController.findProjectByExternalId(prj);
516+
List<DTOStrategicIndicatorEvaluation> currentData = strategicIndicatorsController.getAllStrategicIndicatorsCurrentEvaluation(prj);
517+
List<DTOStrategicIndicatorEvaluation> historicData = strategicIndicatorsController.getAllStrategicIndicatorsHistoricalEvaluation(prj, LocalDate.parse(from), LocalDate.parse(to));
518+
List<DTOSICurrentHistoricEvaluation> result = new ArrayList<>();
519+
int j = 0;
520+
for (int i = 0; i < currentData.size(); i++) {
521+
DTOStrategicIndicatorEvaluation aux = currentData.get(i);
522+
DTOSICurrentHistoricEvaluation siInfo = new DTOSICurrentHistoricEvaluation(aux.getId(),project.getName(),aux.getName(),aux.getDescription(),
523+
aux.getValue(), aux.getDbId(),aux.getRationale(),aux.getProbabilities(),aux.getDate());
524+
List<DTOSICurrentHistoricEvaluation.DTOHistoricalData> siHistInfo = new ArrayList<>();
525+
while (j < historicData.size() && aux.getId().equals(historicData.get(j).getId())) {
526+
DTOStrategicIndicatorEvaluation histAux = historicData.get(j);
527+
DTOSICurrentHistoricEvaluation.DTOHistoricalData histInfo = new DTOSICurrentHistoricEvaluation.DTOHistoricalData(histAux.getValue(),histAux.getRationale(),histAux.getDate());
528+
siHistInfo.add(histInfo);
529+
j++;
530+
}
531+
siInfo.setHistoricalDataList(siHistInfo);
532+
result.add(siInfo);
533+
}
534+
return result;
535+
} catch (ElasticsearchStatusException e) {
536+
logger.error(e.getMessage(), e);
537+
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, Messages.PROJECT_NOT_FOUND);
538+
} catch (CategoriesException | ProjectNotFoundException e) {
539+
logger.error(e.getMessage(), e);
540+
throw new ResponseStatusException(HttpStatus.CONFLICT, Messages.CATEGORIES_DO_NOT_MATCH);
541+
} catch (IOException e) {
542+
logger.error(e.getMessage(), e);
543+
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, Messages.INTERNAL_SERVER_ERROR + e.getMessage());
544+
}
545+
}
510546
}

src/main/java/com/upc/gessi/qrapids/app/presentation/rest/services/Util.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import javax.servlet.http.HttpServletResponse;
1212
import java.time.LocalDate;
1313
import java.util.ArrayList;
14+
import java.util.Arrays;
1415
import java.util.List;
1516

1617
@RestController
@@ -25,6 +26,20 @@ public class Util {
2526
@Value("${server.url}")
2627
private String serverUrl;
2728

29+
// add jasterserver data
30+
@Value("${jasperServer.url}")
31+
private String jasperserverURL;
32+
@Value("${jasperserver.user}")
33+
private String jasperserverUser;
34+
@Value("${jasperserver.password}")
35+
private String jasperserverPassword;
36+
37+
@GetMapping("/api/jasperserverInfo")
38+
@ResponseStatus(HttpStatus.OK)
39+
public List<String> jasperserverInfo() {
40+
return Arrays.asList(jasperserverURL, jasperserverUser, jasperserverPassword);
41+
}
42+
2843
@GetMapping("/api/rawdataDashboard")
2944
@ResponseStatus(HttpStatus.OK)
3045
public String RawDataDashboard() {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.upc.gessi.qrapids.app.presentation.web.mapping;
2+
3+
import org.springframework.web.bind.annotation.RequestMapping;
4+
import org.springframework.stereotype.Controller;
5+
6+
@Controller("/Reporting")
7+
public class ReportingController {
8+
@RequestMapping("/Reporting")
9+
public String reporting(){ return "Reporting/Reporting"; }
10+
}

src/main/resources/static/css/products.css

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
@CHARSET "UTF-8";
22

33

4-
#productView, #SIConfigView, #CategoriesConfigView {
4+
#productView, #SIConfigView, #CategoriesConfigView, #ReportingView {
55
display: flex;
66
flex-direction: row;
77
}
8-
9-
#productTree, #SITree, #CategoriesElementSelector {
8+
#productTree, #SITree, #CategoriesElementSelector, #ProjectSelector {
109
margin: 1%;
1110
width: 21%;
1211
}
1312

14-
#productInfo, #SIInfo, #Categories {
13+
#productInfo, #SIInfo, #Categories, #ReportingInfo {
1514
margin: 1%;
1615
width: 75%;
1716
display: flex;
1817
flex-direction: column;
1918
}
20-
21-
#productForm, #SIForm, #SICategories, #FactorsCategories, #MetricsCategories {
19+
#productForm, #SIForm, #SICategories, #FactorsCategories, #MetricsCategories, #RedirectToReport, #tableREPdiv {
2220
margin: 1%;
2321
display: flex;
2422
flex-direction: column;

0 commit comments

Comments
 (0)