Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ Improvements:
* [OLMIS-8235](https://openlmis.atlassian.net/browse/OLMIS-8235): Add override query parameter to Jasper template upload to safely replace an existing template.

Bugs:
* [OLMIS-8187](https://openlmis.atlassian.net/browse/OLMIS-8187) Fix duplicate rows in Periodic SOH report
* [OLMIS-8235](https://openlmis.atlassian.net/browse/OLMIS-8235): Fix template override wiping parameter API metadata (selectExpression, selectMethod etc.)
* [OLMIS-8187](https://openlmis.atlassian.net/browse/OLMIS-8187) Fix duplicate rows in Periodic SOH report — remove SELECT DISTINCT that was hiding identical legitimate movements
New functionality:
* [MW-1449](https://openlmis.atlassian.net/browse/MW-1449): Added Superset guest token endpoint for embedded dashboards. Dashboard reports now carry an optional `embeddedUuid` column referencing a Superset embedded dashboard. The new `/api/reports/superset/guest-token` endpoint exchanges an OpenLMIS user for a short-lived Superset guest token, gated by the `REPORTS_VIEW` right and a lookup against the dashboard's `embeddedUuid`.

Bugs:
* [OLMIS-8187](https://openlmis.atlassian.net/browse/OLMIS-8187) Fix duplicate rows in Periodic SOH report

1.5.0 / 2025-11-27
==================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,20 @@
}
}

private Map<String, JasperTemplateParameter> buildExistingParamMap(JasperTemplate template) {
Map<String, JasperTemplateParameter> map = new HashMap<>();
if (template.getTemplateParameters() != null) {
for (JasperTemplateParameter p : template.getTemplateParameters()) {
map.put(p.getName(), p);
}
}
return map;
}

private void processJrParameters(JasperTemplate jasperTemplate, JRParameter[] jrParameters)

Check failure on line 467 in src/main/java/org/openlmis/report/service/JasperTemplateService.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 19 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=OpenLMIS_openlmis-report&issues=AZ6ogoSQFKBm0xsu-ocf&open=AZ6ogoSQFKBm0xsu-ocf&pullRequest=28
throws ReportingException {
Map<String, JasperTemplateParameter> existingByName = buildExistingParamMap(jasperTemplate);

ArrayList<JasperTemplateParameter> parameters = new ArrayList<>();
Set<ReportImage> images = new HashSet<>();
int order = 0;
Expand All @@ -466,6 +478,10 @@
JasperTemplateParameter jasperTemplateParameter = createParameter(jrParameter);
jasperTemplateParameter.setTemplate(jasperTemplate);
jasperTemplateParameter.setDisplayOrder(order++);
JasperTemplateParameter existing = existingByName.get(jrParameter.getName());
if (existing != null) {
mergeDbOnlyFields(jasperTemplateParameter, existing);
}
parameters.add(jasperTemplateParameter);
} else if (Image.class.getName().equals(jrParameter.getValueClassName())) {
String name = jrParameter.getName();
Expand Down Expand Up @@ -547,6 +563,23 @@
return jasperTemplateParameter;
}

private void mergeDbOnlyFields(JasperTemplateParameter target, JasperTemplateParameter source) {
if (target.getSelectExpression() == null) {
target.setSelectExpression(source.getSelectExpression());
}
if (target.getSelectProperty() == null) {
target.setSelectProperty(source.getSelectProperty());
}
if (target.getDisplayProperty() == null) {
target.setDisplayProperty(source.getDisplayProperty());
}
if (target.getDescription() == null) {
target.setDescription(source.getDescription());
}
target.setSelectMethod(source.getSelectMethod());
target.setSelectBody(source.getSelectBody());
}

private void throwIfTemplateWithSameNameAlreadyExists(String name) throws ReportingException {
if (jasperTemplateRepository.findByName(name) != null) {
throw new ReportingException(ERROR_REPORTING_TEMPLATE_EXIST);
Expand Down
Loading