removed Pentaho from validation and template
This commit is contained in:
+4
-4
@@ -54,8 +54,8 @@ import org.springframework.stereotype.Component;
|
||||
@Scope("singleton")
|
||||
public class ReportsApiResource {
|
||||
|
||||
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "reportName", "reportType",
|
||||
"reportSubType", "reportCategory", "description", "reportSql", "coreReport", "useReport", "reportParameters"));
|
||||
private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "reportName", "reportType", "reportSubType",
|
||||
"reportCategory", "description", "reportSql", "coreReport", "useReport", "reportParameters"));
|
||||
|
||||
private final String resourceNameForPermissions = "REPORT";
|
||||
private final PlatformSecurityContext context;
|
||||
@@ -102,7 +102,7 @@ public class ReportsApiResource {
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
if (settings.isTemplate()) {
|
||||
result.appendedTemplate(this.readReportingService.getAllowedParameters());
|
||||
result.appendedTemplate(this.readReportingService.getAllowedParameters(), this.readReportingService.getAllowedReportTypes());
|
||||
}
|
||||
return this.toApiJsonSerializer.serialize(settings, result, this.RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class ReportsApiResource {
|
||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||
|
||||
final ReportData result = new ReportData();
|
||||
result.appendedTemplate(this.readReportingService.getAllowedParameters());
|
||||
result.appendedTemplate(this.readReportingService.getAllowedParameters(), this.readReportingService.getAllowedReportTypes());
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
return this.toApiJsonSerializer.serialize(settings, result, this.RESPONSE_DATA_PARAMETERS);
|
||||
|
||||
+2
-4
@@ -86,12 +86,10 @@ final public class ReportData {
|
||||
this.allowedParameters = null;
|
||||
}
|
||||
|
||||
public void appendedTemplate(final Collection<ReportParameterData> allowedParameters) {
|
||||
public void appendedTemplate(final Collection<ReportParameterData> allowedParameters, final Collection<String> allowedReportTypes) {
|
||||
|
||||
final List<String> reportTypes = new ArrayList<>();
|
||||
reportTypes.add("Table");
|
||||
reportTypes.add("Pentaho");
|
||||
reportTypes.add("Chart");
|
||||
reportTypes.addAll(allowedReportTypes);
|
||||
this.allowedReportTypes = reportTypes;
|
||||
|
||||
final List<String> reportSubTypes = new ArrayList<>();
|
||||
|
||||
+9
-9
@@ -19,6 +19,7 @@
|
||||
package org.apache.fineract.infrastructure.dataqueries.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -77,7 +78,7 @@ public final class Report extends AbstractPersistable<Long> {
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "report", orphanRemoval = true)
|
||||
private final Set<ReportParameterUsage> reportParameterUsages = new HashSet<>();
|
||||
|
||||
public static Report fromJson(final JsonCommand command) {
|
||||
public static Report fromJson(final JsonCommand command, final Collection<String> reportTypes) {
|
||||
|
||||
String reportName = null;
|
||||
String reportType = null;
|
||||
@@ -109,7 +110,7 @@ public final class Report extends AbstractPersistable<Long> {
|
||||
reportSql = command.stringValueOfParameterNamed("reportSql");
|
||||
}
|
||||
|
||||
return new Report(reportName, reportType, reportSubType, reportCategory, description, useReport, reportSql);
|
||||
return new Report(reportName, reportType, reportSubType, reportCategory, description, useReport, reportSql, reportTypes);
|
||||
}
|
||||
|
||||
protected Report() {
|
||||
@@ -117,7 +118,7 @@ public final class Report extends AbstractPersistable<Long> {
|
||||
}
|
||||
|
||||
public Report(final String reportName, final String reportType, final String reportSubType, final String reportCategory,
|
||||
final String description, final boolean useReport, final String reportSql) {
|
||||
final String description, final boolean useReport, final String reportSql, final Collection<String> reportTypes) {
|
||||
this.reportName = reportName;
|
||||
this.reportType = reportType;
|
||||
this.reportSubType = reportSubType;
|
||||
@@ -126,10 +127,10 @@ public final class Report extends AbstractPersistable<Long> {
|
||||
this.coreReport = false;
|
||||
this.useReport = useReport;
|
||||
this.reportSql = reportSql;
|
||||
validate();
|
||||
validate(reportTypes);
|
||||
}
|
||||
|
||||
public Map<String, Object> update(final JsonCommand command) {
|
||||
public Map<String, Object> update(final JsonCommand command, final Collection<String> reportTypes) {
|
||||
|
||||
final Map<String, Object> actualChanges = new LinkedHashMap<>(8);
|
||||
|
||||
@@ -184,7 +185,7 @@ public final class Report extends AbstractPersistable<Long> {
|
||||
}
|
||||
}
|
||||
|
||||
validate();
|
||||
validate(reportTypes);
|
||||
|
||||
if (!actualChanges.isEmpty()) {
|
||||
if (isCoreReport()) {
|
||||
@@ -214,15 +215,14 @@ public final class Report extends AbstractPersistable<Long> {
|
||||
return reportParameterUsage;
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
private void validate(final Collection<String> reportTypes) {
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("report");
|
||||
|
||||
baseDataValidator.reset().parameter("reportName").value(this.reportName).notBlank().notExceedingLengthOf(100);
|
||||
|
||||
baseDataValidator.reset().parameter("reportType").value(this.reportType).notBlank()
|
||||
.isOneOfTheseValues(new Object[] { "Table", "Pentaho", "Chart" });
|
||||
baseDataValidator.reset().parameter("reportType").value(this.reportType).notBlank().isOneOfTheseValues(reportTypes.toArray());
|
||||
|
||||
baseDataValidator.reset().parameter("reportSubType").value(this.reportSubType).notExceedingLengthOf(20);
|
||||
|
||||
|
||||
+2
@@ -42,4 +42,6 @@ public interface ReadReportingService {
|
||||
Collection<ReportParameterData> getAllowedParameters();
|
||||
|
||||
ReportData retrieveReport(final Long id);
|
||||
|
||||
Collection<String> getAllowedReportTypes();
|
||||
}
|
||||
+13
-1
@@ -45,6 +45,7 @@ import org.apache.fineract.infrastructure.dataqueries.data.ResultsetColumnHeader
|
||||
import org.apache.fineract.infrastructure.dataqueries.data.ResultsetRowData;
|
||||
import org.apache.fineract.infrastructure.dataqueries.exception.ReportNotFoundException;
|
||||
import org.apache.fineract.infrastructure.documentmanagement.contentrepository.FileSystemContentRepository;
|
||||
import org.apache.fineract.infrastructure.report.provider.ReportingProcessServiceProvider;
|
||||
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.apache.fineract.useradministration.domain.AppUser;
|
||||
import org.slf4j.Logger;
|
||||
@@ -69,15 +70,17 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
private final DataSource dataSource;
|
||||
private final PlatformSecurityContext context;
|
||||
private final GenericDataService genericDataService;
|
||||
private final ReportingProcessServiceProvider reportingProcessServiceProvider;
|
||||
|
||||
@Autowired
|
||||
public ReadReportingServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
|
||||
final GenericDataService genericDataService) {
|
||||
final GenericDataService genericDataService, final ReportingProcessServiceProvider reportingProcessServiceProvider) {
|
||||
|
||||
this.context = context;
|
||||
this.dataSource = dataSource;
|
||||
this.jdbcTemplate = new JdbcTemplate(this.dataSource);
|
||||
this.genericDataService = genericDataService;
|
||||
this.reportingProcessServiceProvider = reportingProcessServiceProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -389,6 +392,15 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getAllowedReportTypes() {
|
||||
final List<String> reportTypes = new ArrayList<>();
|
||||
reportTypes.add("Table");
|
||||
reportTypes.add("Chart");
|
||||
reportTypes.addAll(this.reportingProcessServiceProvider.findAllReportingTypes());
|
||||
return reportTypes;
|
||||
}
|
||||
|
||||
private static final class ReportParameterJoinMapper implements RowMapper<ReportParameterJoinData> {
|
||||
|
||||
public String schema(final Long reportId) {
|
||||
|
||||
+5
-3
@@ -61,18 +61,20 @@ public class ReportWritePlatformServiceImpl implements ReportWritePlatformServic
|
||||
private final ReportParameterUsageRepository reportParameterUsageRepository;
|
||||
private final ReportParameterRepository reportParameterRepository;
|
||||
private final PermissionRepository permissionRepository;
|
||||
private final ReadReportingService readReportingService;
|
||||
|
||||
@Autowired
|
||||
public ReportWritePlatformServiceImpl(final PlatformSecurityContext context,
|
||||
final ReportCommandFromApiJsonDeserializer fromApiJsonDeserializer, final ReportRepository reportRepository,
|
||||
final ReportParameterRepository reportParameterRepository, final ReportParameterUsageRepository reportParameterUsageRepository,
|
||||
final PermissionRepository permissionRepository) {
|
||||
final PermissionRepository permissionRepository, final ReadReportingService readReportingService) {
|
||||
this.context = context;
|
||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||
this.reportRepository = reportRepository;
|
||||
this.reportParameterRepository = reportParameterRepository;
|
||||
this.reportParameterUsageRepository = reportParameterUsageRepository;
|
||||
this.permissionRepository = permissionRepository;
|
||||
this.readReportingService = readReportingService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@@ -84,7 +86,7 @@ public class ReportWritePlatformServiceImpl implements ReportWritePlatformServic
|
||||
|
||||
this.fromApiJsonDeserializer.validate(command.json());
|
||||
|
||||
final Report report = Report.fromJson(command);
|
||||
final Report report = Report.fromJson(command, this.readReportingService.getAllowedReportTypes());
|
||||
final Set<ReportParameterUsage> reportParameterUsages = assembleSetOfReportParameterUsages(report, command);
|
||||
report.update(reportParameterUsages);
|
||||
|
||||
@@ -115,7 +117,7 @@ public class ReportWritePlatformServiceImpl implements ReportWritePlatformServic
|
||||
final Report report = this.reportRepository.findOne(reportId);
|
||||
if (report == null) { throw new ReportNotFoundException(reportId); }
|
||||
|
||||
final Map<String, Object> changes = report.update(command);
|
||||
final Map<String, Object> changes = report.update(command, this.readReportingService.getAllowedReportTypes());
|
||||
|
||||
if (changes.containsKey("reportParameters")) {
|
||||
final Set<ReportParameterUsage> reportParameterUsages = assembleSetOfReportParameterUsages(report, command);
|
||||
|
||||
+6
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.report.provider;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -58,6 +59,11 @@ public class ReportingProcessServiceProvider implements ApplicationContextAware
|
||||
this.initializeRegistry();
|
||||
}
|
||||
|
||||
public Collection<String> findAllReportingTypes() {
|
||||
return this.reportingProcessServices.keySet();
|
||||
|
||||
}
|
||||
|
||||
private void initializeRegistry() {
|
||||
if (this.reportingProcessServices == null) {
|
||||
this.reportingProcessServices = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user