Skip to content

Commit

Permalink
Merge pull request #142 from q-rapids/develop
Browse files Browse the repository at this point in the history
Release v1.3
  • Loading branch information
alejandravv committed Apr 24, 2020
2 parents 3199828 + 35fc071 commit 765e2d6
Show file tree
Hide file tree
Showing 33 changed files with 2,119 additions and 505 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'jacoco'
apply plugin: 'org.asciidoctor.convert'

group = 'com.upc.gessi.qrapids'
version = '1.2'
version = '1.3'
sourceCompatibility = 1.8

war {
Expand Down
2 changes: 1 addition & 1 deletion docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
= Q-Rapids Dashboard API REST Documentation
v1.2, {docdate}
v1.3, {docdate}
:toc: left

:sectnums:
Expand Down
266 changes: 203 additions & 63 deletions docs/asciidoc/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sonar.projectKey=q-rapids_qrapids-dashboard

sonar.projectName=qrapids-dashboard

sonar.projectVersion=1.2
sonar.projectVersion=1.3

sonar.sources=src/main/java
sonar.tests=src/test/java
Expand Down
185 changes: 161 additions & 24 deletions src/main/java/com/upc/gessi/qrapids/app/domain/adapters/Forecast.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ public List<DTODetailedStrategicIndicator> getSingleDetailedStrategicIndicatorsH
return qmaDetailedStrategicIndicators.HistoricalData(strategicIndicatorId, from, to, projectExternalId);
}

public List<DTOStrategicIndicatorEvaluation> getStrategicIndicatorsPrediction (String technique, String freq, String horizon, String projectExternalId) throws IOException, ElasticsearchStatusException {
return qmaForecast.ForecastSI(technique, freq, horizon, projectExternalId);
public List<DTOStrategicIndicatorEvaluation> getStrategicIndicatorsPrediction (List<DTOStrategicIndicatorEvaluation> si, String technique, String freq, String horizon, String projectExternalId) throws IOException, ElasticsearchStatusException {
return qmaForecast.ForecastSI(si,technique, freq, horizon, projectExternalId);
}

public List<DTODetailedStrategicIndicator> getDetailedStrategicIndicatorsPrediction (List<DTODetailedStrategicIndicator> currentEvaluation, String technique, String freq, String horizon, String projectExternalId) throws IOException, ElasticsearchStatusException {
Expand All @@ -242,12 +242,15 @@ public void trainForecastModelsAllProjects(String technique) throws IOException,
}
}

public void trainForecastModelsSingleProject(String project, String technique) throws IOException {
public void trainForecastModelsSingleProject(String project, String technique) throws IOException, CategoriesException {
List<DTOMetric> metrics = metricsController.getAllMetricsCurrentEvaluation(project);
qmaForecast.trainMetricForecast(metrics, "7", project, technique);

List<DTOQualityFactor> factors = qualityFactorsController.getAllFactorsWithMetricsCurrentEvaluation(project);
qmaForecast.trainFactorForecast(factors, "7", project, technique);

List<DTOStrategicIndicatorEvaluation> strategicIndicators = getAllStrategicIndicatorsCurrentEvaluation(project);
qmaForecast.trainStrategicIndicatorForecast(strategicIndicators, "7", project, technique);
}

public boolean assessStrategicIndicators(String projectExternalId, LocalDate dateFrom) throws IOException, CategoriesException, ProjectNotFoundException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class DTOStrategicIndicatorEvaluation {
private String categories_description;
private boolean hasBN;
private boolean hasFeedback;
private Pair<Float, Float> confidence80;
private Pair<Float, Float> confidence95;
private String forecastingError;
private int mismatchDays;
private List<String> missingFactors;
Expand Down Expand Up @@ -58,6 +60,22 @@ public DTOStrategicIndicatorEvaluation(String id, String name, String descriptio
setHasBN(hasBN);
}

public DTOStrategicIndicatorEvaluation(String id, String name, String description, Pair<Float, String> value, Pair<Float, Float> confidence80, Pair<Float, Float> confidence95, String rationale, List<DTOSIAssessment> probabilities, LocalDate date, String datasource, Long dbId, String categories, boolean hasBN) {
setId(id);
setName(name);
setDescription(description);
setValue(value);
setConfidence80(confidence80);
setConfidence95(confidence95);
setRationale(rationale);
setProbabilities(probabilities);
setDate(date);
setDbId(dbId);
setDatasource(datasource);
setCategories_description(categories);
setHasBN(hasBN);
}

public DTOStrategicIndicatorEvaluation(String id, String name, String forecastingError) {
this.id = id;
this.name = name;
Expand Down Expand Up @@ -102,7 +120,6 @@ public void setDescription(String description) {
this.description = description;
}


public Pair<Float, String> getValue() {
return value;
}
Expand Down Expand Up @@ -208,4 +225,20 @@ public List<String> getMissingFactors() {
public void setMissingFactors(List<String> missingFactors) {
this.missingFactors = missingFactors;
}

public void setConfidence80(Pair<Float, Float> confidence80) {
this.confidence80 = confidence80;
}

public Pair<Float, Float> getConfidence80() {
return confidence80;
}

public void setConfidence95(Pair<Float, Float> confidence95) {
this.confidence95 = confidence95;
}

public Pair<Float, Float> getConfidence95() {
return confidence95;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ public List<DTOMetric> getHistoricalDataForMetric(@RequestParam(value = "prj") S

@RequestMapping("/api/metrics/prediction")
@ResponseStatus(HttpStatus.OK)
public List<DTOMetric> getMetricsPredictionData(@RequestParam(value = "prj") String prj, @RequestParam("technique") String techinique, @RequestParam("horizon") String horizon) throws IOException {
public List<DTOMetric> getMetricsPredictionData(@RequestParam(value = "prj") String prj, @RequestParam("technique") String technique, @RequestParam("horizon") String horizon) throws IOException {
try {
List<DTOMetric> currentEvaluation = metricsController.getAllMetricsCurrentEvaluation(prj);
return metricsController.getMetricsPrediction(currentEvaluation, prj, techinique, "7", horizon);
return metricsController.getMetricsPrediction(currentEvaluation, prj, technique, "7", horizon);
} catch (ElasticsearchStatusException e) {
logger.error(e.getMessage(), e);
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, Messages.PROJECT_NOT_FOUND);
Expand All @@ -122,4 +122,16 @@ public List<DTOMetric> getMetricsPredictionData(@RequestParam(value = "prj") Str
}
}

@GetMapping("/api/metrics/currentDate")
@ResponseStatus(HttpStatus.OK)
public LocalDate getcurrentDate(@RequestParam(value = "prj") String prj) {
try {
List<DTOMetric> metrics = metricsController.getAllMetricsCurrentEvaluation(prj);
return metrics.get(0).getDate();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
// if the response is null
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import com.upc.gessi.qrapids.app.domain.controllers.MetricsController;
import com.upc.gessi.qrapids.app.domain.controllers.QualityFactorsController;
import com.upc.gessi.qrapids.app.domain.models.QFCategory;
import com.upc.gessi.qrapids.app.presentation.rest.dto.DTOCategoryThreshold;
import com.upc.gessi.qrapids.app.presentation.rest.dto.DTOFactor;
import com.upc.gessi.qrapids.app.presentation.rest.dto.DTOMetric;
import com.upc.gessi.qrapids.app.presentation.rest.dto.DTOQualityFactor;
import com.upc.gessi.qrapids.app.presentation.rest.dto.*;
import com.upc.gessi.qrapids.app.domain.exceptions.CategoriesException;
import com.upc.gessi.qrapids.app.presentation.rest.services.helpers.Messages;
import org.elasticsearch.ElasticsearchStatusException;
Expand Down Expand Up @@ -189,4 +186,17 @@ public List<DTOMetric> getMetricsPredictionData(@RequestParam(value = "prj") Str
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, Messages.INTERNAL_SERVER_ERROR + e.getMessage());
}
}

@GetMapping("/api/qualityFactors/currentDate")
@ResponseStatus(HttpStatus.OK)
public LocalDate getcurrentDate(@RequestParam(value = "prj") String prj) {
try {
List<DTOFactor> qfs = qualityFactorsController.getAllFactorsEvaluation(prj);
return qfs.get(0).getDate();
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
// if the response is null
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,12 @@ List<DTOQualityFactor> getQualityFactorsHistoricalData(@RequestParam(value = "pr
@ResponseStatus(HttpStatus.OK)
public List<DTOStrategicIndicatorEvaluation> getStrategicIndicatorsPrediction(@RequestParam(value = "prj", required=false) String prj, @RequestParam("technique") String technique, @RequestParam("horizon") String horizon) {
try {
return strategicIndicatorsController.getStrategicIndicatorsPrediction(technique, "7", horizon, prj);
List<DTOStrategicIndicatorEvaluation> currentEvaluation = strategicIndicatorsController.getAllStrategicIndicatorsCurrentEvaluation(prj);
return strategicIndicatorsController.getStrategicIndicatorsPrediction(currentEvaluation, technique, "7", horizon, prj);
} catch (ElasticsearchStatusException e) {
logger.error(e.getMessage(), e);
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, Messages.PROJECT_NOT_FOUND);
} catch (IOException e) {
} catch (IOException | CategoriesException e) {
logger.error(e.getMessage(), e);
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, Messages.INTERNAL_SERVER_ERROR + e.getMessage());
}
Expand Down Expand Up @@ -392,7 +393,8 @@ public void newSICategories (@RequestBody List<Map<String, String>> categories)
private enum TrainType {
NONE, ONE, ALL
}
//TODO: assessSI

//TODO: assessSI
@RequestMapping("/api/assessStrategicIndicators")
@ResponseStatus(HttpStatus.OK)
public void assesStrategicIndicatorsLegacy(@RequestParam(value = "prj", required=false) String prj,
Expand Down Expand Up @@ -492,4 +494,17 @@ public List<DTORelationsSI> getQualityModel(@RequestParam("prj") String prj, @Re
public List<String> getForecastTechniques() {
return strategicIndicatorsController.getForecastTechniques();
}

@GetMapping("/api/strategicIndicators/currentDate")
@ResponseStatus(HttpStatus.OK)
public LocalDate getcurrentDate(@RequestParam(value = "prj") String prj) {
try {
List<DTOStrategicIndicatorEvaluation> si = strategicIndicatorsController.getAllStrategicIndicatorsCurrentEvaluation(prj);
return si.get(0).getDate();
} catch (IOException | CategoriesException e) {
logger.error(e.getMessage(), e);
}
// if the response is null
return null;
}
}
25 changes: 20 additions & 5 deletions src/main/resources/static/js/navScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,13 @@ function disableViewModeAndTimeOption () {

if (assessment === "QualityModel") $("#Assessment").attr("href", serverUrl + "/" + assessment + qmMode);
else if ( assessment === "Phases" ) $("#Assessment").attr("href", serverUrl + "/" + assessment);
else if (assessment === "DetailedStrategicIndicators" || assessment === "QualityFactors" ) $("#Assessment").attr("href", serverUrl + "/" + assessment + "/" + time + viewMode + representationMode);
else if (assessment === "DetailedStrategicIndicators" || assessment === "QualityFactors" ) {
if (time == "Current" && viewMode == "Chart") {
$("#Assessment").attr("href", serverUrl + "/" + assessment + "/" + time + viewMode + representationMode);
} else {
$("#Assessment").attr("href", serverUrl + "/" + assessment + "/" + time + viewMode);
}
}
else $("#Assessment").attr("href", serverUrl + "/" + assessment + "/" + time + viewMode);

$("#Prediction").attr("href", serverUrl + "/" + prediction + "/" + "PredictionChart");
Expand Down Expand Up @@ -467,10 +473,19 @@ function navBack(toDetailed) {
urlNav = "../QualityFactors/PredictionChart";
}
else {
if (toDetailed)
urlNav = "../DetailedStrategicIndicators/" + time + viewMode + representationMode;
else
urlNav = "../QualityFactors/" + time + viewMode + representationMode;
if (toDetailed) {
if (time == 'Current' && viewMode == 'Chart') {
urlNav = "../DetailedStrategicIndicators/" + time + viewMode + representationMode;
} else {
urlNav = "../DetailedStrategicIndicators/" + time + viewMode;
}
} else {
if (time == 'Current' && viewMode == 'Chart') {
urlNav = "../QualityFactors/" + time + viewMode + representationMode;
} else {
urlNav = "../QualityFactors/" + time + viewMode;
}
}
}
if (siid.length !== 0 && si.length !== 0) {
urlNav = urlNav + "?id=" + siid + "&name=" + si;
Expand Down
26 changes: 9 additions & 17 deletions src/main/resources/static/js/parseDataDetailedSICurrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ function getData() {
values = [];
categories = [];

getCategories();

//get data from API
jQuery.ajax({
dataType: "json",
Expand Down Expand Up @@ -83,25 +81,19 @@ function getData() {
warnings.push(messages);
}
$("#assessmentDate").text(assessmentDate.toLocaleDateString());
drawChart();
getFactorsCategories();
}
});
}

function getCategories() {
var serverUrl = sessionStorage.getItem("serverUrl");
var url = "/api/qualityFactors/categories";
if (serverUrl) {
url = serverUrl + url;
}
$.getJSON(url).then (function(cat) {
for (var i = 0; i < cat.length; i++) {
categories.push({
name: cat[i].name,
color: cat[i].color,
upperThreshold: cat[i].upperThreshold,
});
function getFactorsCategories() {
jQuery.ajax({
url: "../api/qualityFactors/categories",
type: "GET",
async: true,
success: function (response) {
categories = response;
drawChart();
}
console.log(categories);
});
}
Loading

0 comments on commit 765e2d6

Please sign in to comment.