Temporary removed async gets for datasets (TODO: make them async again)

This commit is contained in:
George Kalampokis 2020-07-21 17:30:12 +03:00
parent 9000da0ee4
commit a60151560b
2 changed files with 9 additions and 13 deletions

View File

@ -220,7 +220,7 @@ public class DashBoardManager {
datasetList = datasetRepository.getWithCriteria(datasetCriteria);
}
CompletableFuture future = CompletableFuture.runAsync(() -> {
/*CompletableFuture future = CompletableFuture.runAsync(() -> */{
recentActivityModels.addAll(dmpList
.withHint(HintedModelFactory.getHint(RecentDmpModel.class))
.orderBy((builder, root) -> builder.desc(root.get(tableRequest.getCriteria().getOrder())))
@ -238,10 +238,10 @@ public class DashBoardManager {
.select(item -> {
return new RecentDatasetModel().fromEntity(item);
}));
});
}/*);*/
CompletableFuture.allOf(future).join();
//CompletableFuture.allOf(future).join();
// CompletableFuture.allOf(dmps, datasets).join();
return recentActivityModels.stream().sorted(this.comparators.get(tableRequest.getCriteria().getOrder())).limit(tableRequest.getLength()).collect(Collectors.toList());

View File

@ -41,7 +41,6 @@ import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
import eu.eudat.models.data.listingmodels.DatasetListingModel;
import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
@ -70,6 +69,7 @@ import org.w3c.dom.NodeList;
import javax.activation.MimetypesFileTypeMap;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.transaction.Transactional;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
@ -188,16 +188,11 @@ public class DatasetManager {
DataTableData<DatasetListingModel> dataTable = new DataTableData<>();
CompletableFuture<List<DatasetListingModel>> itemsFuture = pagedItems.
selectAsync(this::mapModel).whenComplete((resultList, throwable) -> {
dataTable.setData(resultList);
});
dataTable.setData(pagedItems.select(this::mapModel));
CompletableFuture countFuture = authItems.countAsync().whenComplete((count, throwable) -> {
dataTable.setTotalCount(count);
});
dataTable.setTotalCount(authItems.count());
CompletableFuture.allOf(itemsFuture, countFuture).join();
//CompletableFuture.allOf(itemsFuture, countFuture).join();
return dataTable;
}
@ -260,7 +255,7 @@ public class DatasetManager {
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
if (datasetEntity.getDmp().getUsers()
.stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId())
.collect(Collectors.toList()).size() == 0)
.collect(Collectors.toList()).size() == 0 && !datasetEntity.getDmp().isPublic())
throw new UnauthorisedException();
eu.eudat.elastic.entities.Dataset datasetElastic;
try {
@ -1052,6 +1047,7 @@ public class DatasetManager {
}
}
@Transactional
private DatasetListingModel mapModel(Dataset item) {
DatasetListingModel listingModel = new DatasetListingModel().fromDataModel(item);
DatasetProfileCriteria criteria = new DatasetProfileCriteria();