Skip to content

Commit

Permalink
Add SQL Role Access Support
Browse files Browse the repository at this point in the history
  • Loading branch information
yamelsenih committed Sep 20, 2024
1 parent 39bbd95 commit 5fbff90
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/org/spin/report_engine/service/ReportBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.compiere.model.MPInstance;
import org.compiere.model.MProcess;
import org.compiere.model.MProcessPara;
import org.compiere.model.MRole;
import org.compiere.model.MTable;
import org.compiere.model.PO;
import org.compiere.model.Query;
Expand Down Expand Up @@ -182,14 +183,20 @@ private ReportInfo get(String transactionName) {
.withLimit(limit, offset)
.buildQuery()
;
int count = CountUtil.countRecords(queryDefinition.getCompleteQueryCount(), format.getTableName(), queryDefinition.getParameters());
// Add Access
String completeQuery = MRole.getDefault(Env.getCtx(), false).addAccessSQL(
queryDefinition.getCompleteQuery(), format.getTableName(), MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
String completeQueryCount = MRole.getDefault(Env.getCtx(), false).addAccessSQL(
queryDefinition.getCompleteQueryCount(), format.getTableName(), MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
// Count
int count = CountUtil.countRecords(completeQueryCount, format.getTableName(), queryDefinition.getParameters());
ReportInfo reportInfo = ReportInfo.newInstance(format, queryDefinition)
.withReportViewId(getReportViewId())
.withInstanceId(getInstanceId())
.withRecordCount(count)
.withSummary(isSummary())
;
DB.runResultSet(transactionName, queryDefinition.getCompleteQuery(), queryDefinition.getParameters(), resulset -> {
DB.runResultSet(transactionName, completeQuery, queryDefinition.getParameters(), resulset -> {
while (resulset.next()) {
format.getItems().forEach(item -> {
Map<String, Cell> cells = new HashMap<String, Cell>();
Expand Down

0 comments on commit 5fbff90

Please sign in to comment.