2017-12-21 10:26:11 +01:00
|
|
|
package eu.eudat.managers;
|
|
|
|
|
2018-02-16 08:45:18 +01:00
|
|
|
import eu.eudat.builders.model.models.DataTableDataBuilder;
|
2017-12-21 10:26:11 +01:00
|
|
|
import eu.eudat.dao.entities.DatasetProfileDao;
|
|
|
|
import eu.eudat.entities.DatasetProfile;
|
|
|
|
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteItem;
|
|
|
|
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteRequest;
|
2018-01-03 11:44:54 +01:00
|
|
|
import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
|
|
|
|
import eu.eudat.models.datasetprofile.DatasetProfileTableRequestItem;
|
2018-01-25 16:24:21 +01:00
|
|
|
import eu.eudat.models.helpers.common.DataTableData;
|
2017-12-21 10:26:11 +01:00
|
|
|
import eu.eudat.queryable.QueryableList;
|
2018-02-16 08:45:18 +01:00
|
|
|
import eu.eudat.services.ApiContext;
|
2017-12-21 10:26:11 +01:00
|
|
|
|
|
|
|
import java.util.List;
|
2018-02-16 08:45:18 +01:00
|
|
|
import java.util.stream.Collectors;
|
2017-12-21 10:26:11 +01:00
|
|
|
|
2018-02-01 10:08:06 +01:00
|
|
|
|
2017-12-21 10:26:11 +01:00
|
|
|
public class DatasetProfileManager {
|
|
|
|
|
2018-02-16 08:45:18 +01:00
|
|
|
public static List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileDao datasetProfileRepository, DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException {
|
2017-12-21 10:26:11 +01:00
|
|
|
QueryableList<DatasetProfile> items = datasetProfileRepository.getWithCriteria(datasetProfileAutocompleteRequest.getCriteria());
|
2018-02-16 08:45:18 +01:00
|
|
|
List<DatasetProfileAutocompleteItem> datasetProfiles = items.toList().stream().map(item -> new DatasetProfileAutocompleteItem().fromDataModel(item)).collect(Collectors.toList());
|
2017-12-21 10:26:11 +01:00
|
|
|
return datasetProfiles;
|
|
|
|
}
|
2018-01-03 11:44:54 +01:00
|
|
|
|
2018-02-16 08:45:18 +01:00
|
|
|
public static DataTableData<DatasetProfileListingModel> getPaged(ApiContext apiContext, DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws Exception {
|
|
|
|
QueryableList<DatasetProfile> items = apiContext.getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
|
|
|
|
QueryableList<DatasetProfile> pagedItems = PaginationManager.applyPaging(items, datasetProfileTableRequestItem);
|
|
|
|
List<DatasetProfileListingModel> datasetProfiles = pagedItems.toList().stream().map(item -> new DatasetProfileListingModel().fromDataModel(item)).collect(Collectors.toList());
|
|
|
|
return apiContext.getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(datasetProfiles).totalCount(items.count()).build();
|
2018-01-03 11:44:54 +01:00
|
|
|
}
|
|
|
|
|
2018-02-16 08:45:18 +01:00
|
|
|
public static List<DatasetProfileListingModel> getAll(DatasetProfileDao datasetProfileRepository) throws IllegalAccessException, InstantiationException {
|
2018-01-03 11:44:54 +01:00
|
|
|
QueryableList<DatasetProfile> items = datasetProfileRepository.getAll();
|
2018-02-16 08:45:18 +01:00
|
|
|
List<DatasetProfileListingModel> datasetProfiles = items.toList().stream().map(item -> new DatasetProfileListingModel().fromDataModel(item)).collect(Collectors.toList());
|
2018-01-03 11:44:54 +01:00
|
|
|
return datasetProfiles;
|
|
|
|
}
|
2017-12-21 10:26:11 +01:00
|
|
|
}
|