Fixed consistency issues with the public statistics

This commit is contained in:
George Kalampokis 2020-07-31 12:20:29 +03:00
parent e07d79009a
commit f86ba70d24
1 changed files with 13 additions and 18 deletions

View File

@ -1,14 +1,18 @@
package eu.eudat.logic.managers;
import eu.eudat.criteria.RecentActivityCriteria;
import eu.eudat.data.dao.criteria.*;
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
import eu.eudat.data.dao.criteria.DatasetCriteria;
import eu.eudat.data.dao.criteria.GrantCriteria;
import eu.eudat.data.dao.criteria.OrganisationCriteria;
import eu.eudat.data.dao.entities.DMPDao;
import eu.eudat.data.dao.entities.DatasetDao;
import eu.eudat.data.dao.entities.OrganisationDao;
import eu.eudat.data.dao.entities.GrantDao;
import eu.eudat.data.entities.*;
import eu.eudat.data.dao.entities.OrganisationDao;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.entities.Grant;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.query.PaginationService;
import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.elastic.entities.Dmp;
import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder;
import eu.eudat.logic.services.ApiContext;
@ -22,8 +26,6 @@ import eu.eudat.models.data.dashboard.recent.model.RecentDmpModel;
import eu.eudat.models.data.dashboard.recent.tablerequest.RecentActivityTableRequest;
import eu.eudat.models.data.dashboard.searchbar.SearchBarItem;
import eu.eudat.models.data.dashboard.statistics.DashBoardStatistics;
import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel;
import eu.eudat.models.data.listingmodels.DatasetListingModel;
import eu.eudat.models.data.security.Principal;
import eu.eudat.queryable.QueryableList;
import eu.eudat.types.searchbar.SearchBarItemType;
@ -62,17 +64,12 @@ public class DashBoardManager {
public DashBoardStatistics getStatistics() {
DashBoardStatistics statistics = new DashBoardStatistics();
DataManagmentPlanPublicTableRequest publicTableRequest = new DataManagmentPlanPublicTableRequest();
DataManagementPlanPublicCriteria publicCriteria = new DataManagementPlanPublicCriteria();
DataManagementPlanCriteria publicCriteria = new DataManagementPlanCriteria();
publicCriteria.setIsPublic(true);
publicCriteria.setOnlyPublic(true);
publicCriteria.setAllVersions(false);
publicTableRequest.setCriteria(publicCriteria);
publicTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable());
List<DMP> dmps = publicTableRequest.applyCriteria().toList();
List<DMP> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(publicCriteria).toList();
// DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
@ -297,13 +294,11 @@ public class DashBoardManager {
int pos = -1;
for (int i = (recentActivityModels.size() / 2); i < recentActivityModels.size(); i++) {
RecentActivityModel recentActivityModel = recentActivityModels.remove(i);
while (pos < recentActivityModels.size()) {
pos++;
if (pos % 2 != 0) {
break;
}
}
recentActivityModels.add(pos, recentActivityModel);
}