Prevent to map associated Profiles to DMPs when they are loaded ONLY for autocomplete (ref #226)
This commit is contained in:
parent
cd1d81c3dd
commit
4c02fc4c97
|
@ -96,6 +96,7 @@ public class DataManagementPlanManager {
|
|||
}
|
||||
|
||||
public DataTableData<DataManagementPlanListingModel> getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
||||
long startTime = System.currentTimeMillis();
|
||||
UUID principalID = principal.getId();
|
||||
QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
||||
List<Integer> roles = new LinkedList<>();
|
||||
|
@ -119,16 +120,30 @@ public class DataManagementPlanManager {
|
|||
.collect(Collectors.toSet()));
|
||||
return new DataManagementPlanListingModel().fromDataModelDatasets(item);
|
||||
})
|
||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
||||
.whenComplete((resultList, throwable) -> {
|
||||
logger.info("Select query took " + (System.currentTimeMillis() - startTime) + " millis");
|
||||
dataTable.setData(resultList);
|
||||
});
|
||||
} else if (fieldsGroup.equals("autocomplete")) {
|
||||
itemsFuture = pagedItems
|
||||
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModelAutoComplete(item))
|
||||
.whenComplete((resultList, throwable) -> {
|
||||
logger.info("Select query took " + (System.currentTimeMillis() - startTime) + " millis");
|
||||
dataTable.setData(resultList);
|
||||
});
|
||||
} else {
|
||||
itemsFuture = pagedItems
|
||||
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModelAssociatedProfiles(item))
|
||||
.whenComplete((resultList, throwable) -> dataTable.setData(resultList));
|
||||
.whenComplete((resultList, throwable) -> {
|
||||
logger.info("Select query took " + (System.currentTimeMillis() - startTime) + " millis");
|
||||
dataTable.setData(resultList);
|
||||
});
|
||||
}
|
||||
|
||||
CompletableFuture countFuture = authItems.countAsync().whenComplete((count, throwable) ->
|
||||
dataTable.setTotalCount(count)
|
||||
);
|
||||
CompletableFuture countFuture = authItems.countAsync().whenComplete((count, throwable) -> {
|
||||
logger.info("Count query took " + (System.currentTimeMillis() - startTime) + " millis");
|
||||
dataTable.setTotalCount(count);
|
||||
});
|
||||
CompletableFuture.allOf(itemsFuture, countFuture).join();
|
||||
return dataTable;
|
||||
}
|
||||
|
|
|
@ -192,6 +192,14 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
|||
return this;
|
||||
}
|
||||
|
||||
public DataManagementPlanListingModel fromDataModelAutoComplete(DMP entity) {
|
||||
this.id = entity.getId().toString();
|
||||
this.label = entity.getLabel();
|
||||
this.groupId = entity.getGroupId();
|
||||
this.creationTime = entity.getCreated();
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataManagementPlanListingModel fromDataModelDatasets(DMP entity) {
|
||||
this.fromDataModel(entity);
|
||||
this.status = entity.getStatus();
|
||||
|
|
Loading…
Reference in New Issue