Skip to content

Commit

Permalink
Reports REST API improvements #260
Browse files Browse the repository at this point in the history
  • Loading branch information
dtaimanov committed Jun 18, 2020
1 parent 13e1ea5 commit 591ebb4
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public String loadReportsList() {
new View(Report.class)
.addProperty("id")
.addProperty("name")
.addProperty("code"))
.addProperty("code")
.addProperty("group"))
.setQueryString("select r from report$Report r where r.restAccess = true");
reportSecurityManager.applySecurityPolicies(loadContext, null, userSessionSource.getUserSession().getCurrentOrSubstitutedUser());
List<Report> reports = dataManager.loadList(loadContext);
Expand Down Expand Up @@ -218,6 +219,7 @@ protected ReportInfo mapToReportInfo(Report report) {
reportInfo.id = report.getId().toString();
reportInfo.code = report.getCode();
reportInfo.name = report.getName();
reportInfo.group = report.getGroup().getId().toString();

if (entityStates.isLoaded(report, "templates")) {
if (report.getTemplates() != null) {
Expand Down Expand Up @@ -259,9 +261,27 @@ protected InputParameterInfo mapInputParameterInfo(ReportInputParameter paramete
if (parameter.getEnumerationClass() != null) {
inputParameterInfo.enumerationClass = parameter.getEnumerationClass();
}

if (parameter.getDefaultValue() != null) {
inputParameterInfo.defaultValue = transformDefaultValue(parameter);
}
return inputParameterInfo;
}

protected String transformDefaultValue(ReportInputParameter parameter) {
switch (parameter.getType()){
case ENTITY:
EntityLoadInfo info = EntityLoadInfo.parse(parameter.getDefaultValue());
if (info != null) return info.getId().toString();
break;
case DATE:
case TIME:
Object defParamValue = reportService.convertFromString(parameter.getParameterClass(), parameter.getDefaultValue());
return reportService.convertToString(resolveDatatypeActualClass(parameter), defParamValue);
}
return parameter.getDefaultValue();
}

protected UUID getReportIdFromString(String entityId) {
return (UUID) getIdFromString(entityId, metadata.getClassNN(Report.class));
}
Expand Down Expand Up @@ -349,6 +369,7 @@ protected class ReportInfo {
protected String id;
protected String name;
protected String code;
protected String group;

protected List<TemplateInfo> templates;
protected List<InputParameterInfo> inputParameters;
Expand All @@ -367,6 +388,7 @@ protected static class InputParameterInfo {
protected boolean hidden;
protected String entityMetaClass;
protected String enumerationClass;
protected String defaultValue;
}

protected static class ParameterValueInfo {
Expand Down

0 comments on commit 591ebb4

Please sign in to comment.