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 {
|
public DataTableData<DataManagementPlanListingModel> getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
UUID principalID = principal.getId();
|
UUID principalID = principal.getId();
|
||||||
QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
||||||
List<Integer> roles = new LinkedList<>();
|
List<Integer> roles = new LinkedList<>();
|
||||||
|
@ -119,16 +120,30 @@ public class DataManagementPlanManager {
|
||||||
.collect(Collectors.toSet()));
|
.collect(Collectors.toSet()));
|
||||||
return new DataManagementPlanListingModel().fromDataModelDatasets(item);
|
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 {
|
} else {
|
||||||
itemsFuture = pagedItems
|
itemsFuture = pagedItems
|
||||||
.selectAsync(item -> new DataManagementPlanListingModel().fromDataModelAssociatedProfiles(item))
|
.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) ->
|
CompletableFuture countFuture = authItems.countAsync().whenComplete((count, throwable) -> {
|
||||||
dataTable.setTotalCount(count)
|
logger.info("Count query took " + (System.currentTimeMillis() - startTime) + " millis");
|
||||||
);
|
dataTable.setTotalCount(count);
|
||||||
|
});
|
||||||
CompletableFuture.allOf(itemsFuture, countFuture).join();
|
CompletableFuture.allOf(itemsFuture, countFuture).join();
|
||||||
return dataTable;
|
return dataTable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,6 +192,14 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
return this;
|
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) {
|
public DataManagementPlanListingModel fromDataModelDatasets(DMP entity) {
|
||||||
this.fromDataModel(entity);
|
this.fromDataModel(entity);
|
||||||
this.status = entity.getStatus();
|
this.status = entity.getStatus();
|
||||||
|
|
Loading…
Reference in New Issue