Skip to content

Commit

Permalink
Merge branch 'datatable-upload-issue' of https://github.com/biodiv-pl…
Browse files Browse the repository at this point in the history
  • Loading branch information
prakhar-s committed Nov 4, 2024
2 parents aa6970c + 2bbf218 commit 45ccaa9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,14 @@ public Long observationBulkUpload(HttpServletRequest request, ObservationBulkDTO
.getAllFilePathsByUser(filesDto).entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> (String) e.getValue()));

String batchSize = properties.getProperty("datatableBatchSize");

ObservationBulkUploadThread uploadThread = new ObservationBulkUploadThread(observationBulkData, request,
observationDao, observationBulkMapperHelper, esUpdate, userService, dataTable,
observationBulkData.getContributors(), observationImpl.getAllSpeciesGroup(), traitsList,
userGroupIbpList, licenseList, workbook, myImageUpload, resourceService, fileUploadApi,
dataTableService, tokenGenerator, observationBulkData.getUserGroup(), headers);
dataTableService, tokenGenerator, observationBulkData.getUserGroup(), headers,
Long.valueOf(batchSize));
Thread thread = new Thread(uploadThread);
thread.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@ public class ObservationBulkUploadThread implements Runnable {
private final XSSFWorkbook workbook;
private final Map<String, String> myImageUpload;
private final TokenGenerator tokenGenerator;
private final Long batchSize;

public ObservationBulkUploadThread(ObservationBulkDTO observationBulkData, HttpServletRequest request,
ObservationDAO observationDao, ObservationBulkMapperHelper observationBulkMapperHelper, ESUpdate esUpdate,
UserServiceApi userService, DataTableWkt dataTable, Long userId, List<SpeciesGroup> speciesGroupList,
List<TraitsValuePair> traitsList, List<UserGroupIbp> userGroupIbpList, List<License> licenseList,
XSSFWorkbook workbook, Map<String, String> myImageUpload, ResourceServicesApi resourceService,
UploadApi fileUploadApi, DataTableServiceApi dataTableService, TokenGenerator tokenGenerator,
String userGroup, Headers headers) {
String userGroup, Headers headers, Long batchSize) {
super();
this.observationBulkData = observationBulkData;
this.observationDao = observationDao;
Expand All @@ -92,6 +93,7 @@ public ObservationBulkUploadThread(ObservationBulkDTO observationBulkData, HttpS
this.tokenGenerator = tokenGenerator;
this.userGroup = userGroup;
this.myImageUpload = myImageUpload;
this.batchSize = batchSize;
}

public void run() {
Expand Down Expand Up @@ -124,7 +126,7 @@ public void run() {
observationIds.add(obsId);
}

if (observationIds.size() >= 200) {
if (observationIds.size() >= batchSize) {
String observationList = StringUtils.join(observationIds, ',');
ESBulkUploadThread updateThread = new ESBulkUploadThread(esUpdate, observationList);
Thread thread = new Thread(updateThread);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ classificationId=1
locationinfo_layer_view=lyr115_location_information
time_zone=Asia/Kolkata
pull_function=null_pull_function
datatableBatchSize=200

0 comments on commit 45ccaa9

Please sign in to comment.