Fix datatable put call with resource id

This commit is contained in:
Jose Alberto Hernandez
2022-11-24 15:41:22 +01:00
committed by Arnold Gálovics
parent a1a6435283
commit 729316e4a0
4 changed files with 41 additions and 33 deletions
@@ -21,7 +21,6 @@ package org.apache.fineract.infrastructure.dataqueries.handler;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
import org.apache.fineract.infrastructure.dataqueries.service.ReadWriteNonCoreDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -41,18 +40,8 @@ public class UpdateOneToManyDatatableEntryCommandHandler implements NewCommandSo
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
final CommandProcessingResult commandProcessingResult = this.writePlatformService
.updateDatatableEntryOneToMany(command.entityName(), command.entityId(), command.subentityId(), command);
return this.writePlatformService.updateDatatableEntryOneToMany(command.entityName(), command.entityId(), command.subentityId(),
command);
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
.withEntityId(command.entityId()) //
.withOfficeId(commandProcessingResult.getOfficeId()) //
.withGroupId(commandProcessingResult.getGroupId()) //
.withClientId(commandProcessingResult.getClientId()) //
.withSavingsId(commandProcessingResult.getSavingsId()) //
.withLoanId(commandProcessingResult.getLoanId()) //
.with(commandProcessingResult.getChanges()) //
.build();
}
}
@@ -1415,14 +1415,14 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
}
}
return new CommandProcessingResultBuilder() //
return new CommandProcessingResultBuilder().withCommandId(command.commandId()) //
.withEntityId(datatableId != null ? command.subentityId() : command.entityId()) //
.withOfficeId(commandProcessingResult.getOfficeId()) //
.withGroupId(commandProcessingResult.getGroupId()) //
.withClientId(commandProcessingResult.getClientId()) //
.withSavingsId(commandProcessingResult.getSavingsId()) //
.withLoanId(commandProcessingResult.getLoanId()) //
.with(changes) //
.build();
.with(changes).build();
}
@Transactional
@@ -1477,7 +1477,8 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
SQLInjectionValidator.validateSQLInput(whereClause);
String sql = "select * from " + sqlGenerator.escape(dataTableName) + " where " + whereClause;
// id only used for reading a specific entry that belongs to appTableId (in a one to many datatable)
// id only used for reading a specific entry that belongs to appTableId (in a
// one to many datatable)
if (multiRow && id != null) {
sql = sql + " and id = " + id;
}
@@ -1503,7 +1504,8 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
SQLInjectionValidator.validateSQLInput(whereClause);
String sql = "select * from " + sqlGenerator.escape(dataTableName) + " where " + whereClause;
// id only used for reading a specific entry that belongs to appTableId (in a one to many datatable)
// id only used for reading a specific entry that belongs to appTableId (in a
// one to many datatable)
if (multiRow && id != null) {
sql = sql + " and id = " + id;
}