wip mifosx-195 add list of parameters to reports template
This commit is contained in:
+9
-7
@@ -49,19 +49,19 @@ public class ReportsApiResource {
|
||||
private final String resourceNameForPermissions = "REPORT";
|
||||
private final PlatformSecurityContext context;
|
||||
private final ToApiJsonSerializer<ReportData> toApiJsonSerializer;
|
||||
private final ReadReportingService readExtraDataAndReportingService;
|
||||
private final ReadReportingService readReportingService;
|
||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
|
||||
@Autowired
|
||||
public ReportsApiResource(
|
||||
final PlatformSecurityContext context,
|
||||
final ReadReportingService readExtraDataAndReportingService,
|
||||
final ReadReportingService readReportingService,
|
||||
final ToApiJsonSerializer<ReportData> toApiJsonSerializer,
|
||||
PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
|
||||
final ApiRequestParameterHelper apiRequestParameterHelper) {
|
||||
this.context = context;
|
||||
this.readExtraDataAndReportingService = readExtraDataAndReportingService;
|
||||
this.readReportingService = readReportingService;
|
||||
this.toApiJsonSerializer = toApiJsonSerializer;
|
||||
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
|
||||
this.apiRequestParameterHelper = apiRequestParameterHelper;
|
||||
@@ -75,7 +75,7 @@ public class ReportsApiResource {
|
||||
context.authenticatedUser().validateHasReadPermission(
|
||||
resourceNameForPermissions);
|
||||
|
||||
final Collection<ReportData> result = this.readExtraDataAndReportingService
|
||||
final Collection<ReportData> result = this.readReportingService
|
||||
.retrieveReportList();
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper
|
||||
@@ -94,14 +94,15 @@ public class ReportsApiResource {
|
||||
context.authenticatedUser().validateHasReadPermission(
|
||||
resourceNameForPermissions);
|
||||
|
||||
final ReportData result = this.readExtraDataAndReportingService
|
||||
final ReportData result = this.readReportingService
|
||||
.retrieveReport(id);
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper
|
||||
.process(uriInfo.getQueryParameters());
|
||||
|
||||
if (settings.isTemplate()) {
|
||||
result.appendedTemplate();
|
||||
result.appendedTemplate(this.readReportingService
|
||||
.getAllowedParameters());
|
||||
}
|
||||
return this.toApiJsonSerializer.serialize(settings, result,
|
||||
RESPONSE_DATA_PARAMETERS);
|
||||
@@ -117,7 +118,8 @@ public class ReportsApiResource {
|
||||
resourceNameForPermissions);
|
||||
|
||||
ReportData result = new ReportData();
|
||||
result.appendedTemplate();
|
||||
result.appendedTemplate(this.readReportingService
|
||||
.getAllowedParameters());
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper
|
||||
.process(uriInfo.getQueryParameters());
|
||||
|
||||
+76
-65
@@ -11,76 +11,87 @@ import java.util.List;
|
||||
|
||||
final public class ReportData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportName;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportType;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportSubType;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportCategory;
|
||||
@SuppressWarnings("unused")
|
||||
private final String description;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportSql;
|
||||
@SuppressWarnings("unused")
|
||||
private final Boolean coreReport;
|
||||
@SuppressWarnings("unused")
|
||||
private final Boolean useReport;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<ReportParameterData> reportParameters;
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportName;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportType;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportSubType;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportCategory;
|
||||
@SuppressWarnings("unused")
|
||||
private final String description;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportSql;
|
||||
@SuppressWarnings("unused")
|
||||
private final Boolean coreReport;
|
||||
@SuppressWarnings("unused")
|
||||
private final Boolean useReport;
|
||||
@SuppressWarnings("unused")
|
||||
private final Collection<ReportParameterData> reportParameters;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private List<String> allowedReportTypes;
|
||||
@SuppressWarnings("unused")
|
||||
private List<String> allowedReportSubTypes;
|
||||
@SuppressWarnings("unused")
|
||||
private List<String> allowedReportTypes;
|
||||
@SuppressWarnings("unused")
|
||||
private List<String> allowedReportSubTypes;
|
||||
@SuppressWarnings("unused")
|
||||
private Collection<ReportParameterData> allowedParameters;
|
||||
|
||||
public ReportData(final Long id, final String reportName, final String reportType, final String reportSubType,
|
||||
final String reportCategory, final String description, final String reportSql, final Boolean coreReport,
|
||||
final Boolean useReport, final Collection<ReportParameterData> reportParameters) {
|
||||
this.id = id;
|
||||
this.reportName = reportName;
|
||||
this.reportType = reportType;
|
||||
this.reportSubType = reportSubType;
|
||||
this.reportCategory = reportCategory;
|
||||
this.description = description;
|
||||
this.reportParameters = reportParameters;
|
||||
this.reportSql = reportSql;
|
||||
this.coreReport = coreReport;
|
||||
this.useReport = useReport;
|
||||
this.allowedReportTypes = null;
|
||||
this.allowedReportSubTypes = null;
|
||||
}
|
||||
public ReportData(final Long id, final String reportName,
|
||||
final String reportType, final String reportSubType,
|
||||
final String reportCategory, final String description,
|
||||
final String reportSql, final Boolean coreReport,
|
||||
final Boolean useReport,
|
||||
final Collection<ReportParameterData> reportParameters) {
|
||||
this.id = id;
|
||||
this.reportName = reportName;
|
||||
this.reportType = reportType;
|
||||
this.reportSubType = reportSubType;
|
||||
this.reportCategory = reportCategory;
|
||||
this.description = description;
|
||||
this.reportParameters = reportParameters;
|
||||
this.reportSql = reportSql;
|
||||
this.coreReport = coreReport;
|
||||
this.useReport = useReport;
|
||||
this.allowedReportTypes = null;
|
||||
this.allowedReportSubTypes = null;
|
||||
this.allowedParameters = null;
|
||||
}
|
||||
|
||||
public ReportData() {
|
||||
this.id = null;
|
||||
this.reportName = null;
|
||||
this.reportType = null;
|
||||
this.reportSubType = null;
|
||||
this.reportCategory = null;
|
||||
this.description = null;
|
||||
this.reportParameters = null;
|
||||
this.reportSql = null;
|
||||
this.coreReport = null;
|
||||
this.useReport = null;
|
||||
this.allowedReportTypes = null;
|
||||
this.allowedReportSubTypes = null;
|
||||
}
|
||||
public ReportData() {
|
||||
this.id = null;
|
||||
this.reportName = null;
|
||||
this.reportType = null;
|
||||
this.reportSubType = null;
|
||||
this.reportCategory = null;
|
||||
this.description = null;
|
||||
this.reportParameters = null;
|
||||
this.reportSql = null;
|
||||
this.coreReport = null;
|
||||
this.useReport = null;
|
||||
this.allowedReportTypes = null;
|
||||
this.allowedReportSubTypes = null;
|
||||
this.allowedParameters = null;
|
||||
}
|
||||
|
||||
public void appendedTemplate() {
|
||||
public void appendedTemplate(
|
||||
final Collection<ReportParameterData> allowedParameters) {
|
||||
|
||||
List<String> reportTypes = new ArrayList<String>();
|
||||
reportTypes.add("Table");
|
||||
reportTypes.add("Pentaho");
|
||||
reportTypes.add("Chart");
|
||||
this.allowedReportTypes = reportTypes;
|
||||
List<String> reportTypes = new ArrayList<String>();
|
||||
reportTypes.add("Table");
|
||||
reportTypes.add("Pentaho");
|
||||
reportTypes.add("Chart");
|
||||
this.allowedReportTypes = reportTypes;
|
||||
|
||||
List<String> reportSubTypes = new ArrayList<String>();
|
||||
reportSubTypes.add("Bar");
|
||||
reportSubTypes.add("Pie");
|
||||
this.allowedReportSubTypes = reportSubTypes;
|
||||
}
|
||||
List<String> reportSubTypes = new ArrayList<String>();
|
||||
reportSubTypes.add("Bar");
|
||||
reportSubTypes.add("Pie");
|
||||
this.allowedReportSubTypes = reportSubTypes;
|
||||
|
||||
this.allowedParameters = allowedParameters;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+13
-11
@@ -5,18 +5,20 @@
|
||||
*/
|
||||
package org.mifosplatform.infrastructure.dataqueries.data;
|
||||
|
||||
/* used to show list of parameters used by a report and also for getting a list of parameters available (the reportParameterName is left null */
|
||||
final public class ReportParameterData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportParameterName;
|
||||
@SuppressWarnings("unused")
|
||||
private final String parameterName;
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
@SuppressWarnings("unused")
|
||||
private final String reportParameterName;
|
||||
@SuppressWarnings("unused")
|
||||
private final String parameterName;
|
||||
|
||||
public ReportParameterData(final Long id, final String reportParameterName, final String parameterName) {
|
||||
this.id = id;
|
||||
this.reportParameterName = reportParameterName;
|
||||
this.parameterName = parameterName;
|
||||
}
|
||||
public ReportParameterData(final Long id, final String reportParameterName,
|
||||
final String parameterName) {
|
||||
this.id = id;
|
||||
this.reportParameterName = reportParameterName;
|
||||
this.parameterName = parameterName;
|
||||
}
|
||||
}
|
||||
+14
-7
@@ -13,20 +13,27 @@ import javax.ws.rs.core.StreamingOutput;
|
||||
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.GenericResultsetData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.ReportData;
|
||||
import org.mifosplatform.infrastructure.dataqueries.data.ReportParameterData;
|
||||
|
||||
public interface ReadReportingService {
|
||||
|
||||
StreamingOutput retrieveReportCSV(String name, String type, Map<String, String> extractedQueryParams);
|
||||
StreamingOutput retrieveReportCSV(String name, String type,
|
||||
Map<String, String> extractedQueryParams);
|
||||
|
||||
GenericResultsetData retrieveGenericResultset(String name, String type, Map<String, String> extractedQueryParams);
|
||||
GenericResultsetData retrieveGenericResultset(String name, String type,
|
||||
Map<String, String> extractedQueryParams);
|
||||
|
||||
Response processPentahoRequest(String reportName, String outputType, Map<String, String> queryParams);
|
||||
Response processPentahoRequest(String reportName, String outputType,
|
||||
Map<String, String> queryParams);
|
||||
|
||||
String retrieveReportPDF(String name, String type, Map<String, String> extractedQueryParams);
|
||||
String retrieveReportPDF(String name, String type,
|
||||
Map<String, String> extractedQueryParams);
|
||||
|
||||
String getReportType(String reportName);
|
||||
String getReportType(String reportName);
|
||||
|
||||
Collection<ReportData> retrieveReportList();
|
||||
Collection<ReportData> retrieveReportList();
|
||||
|
||||
ReportData retrieveReport(final Long id);
|
||||
Collection<ReportParameterData> getAllowedParameters();
|
||||
|
||||
ReportData retrieveReport(final Long id);
|
||||
}
|
||||
+30
@@ -499,6 +499,17 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
return reportList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<ReportParameterData> getAllowedParameters() {
|
||||
|
||||
ReportParameterMapper rm = new ReportParameterMapper();
|
||||
String sql = rm.schema();
|
||||
Collection<ReportParameterData> parameters = this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||
return parameters;
|
||||
}
|
||||
|
||||
|
||||
private static final class ReportParameterJoinMapper implements RowMapper<ReportParameterJoinData> {
|
||||
|
||||
public String schema(final Long reportId) {
|
||||
@@ -560,4 +571,23 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
coreReport, useReport, reportParameterId, reportParameterName, parameterName);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ReportParameterMapper implements RowMapper<ReportParameterData> {
|
||||
|
||||
public String schema() {
|
||||
|
||||
return "select p.id as id, p.parameter_name as parameterName from stretchy_parameter p where ifnull(p.special,'') != 'Y' order by p.id";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportParameterData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
final Long id = rs.getLong("id");
|
||||
final String parameterName = rs.getString("parameterName");
|
||||
|
||||
return new ReportParameterData(id, null, parameterName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user