package eu.eudat.managers; import eu.eudat.dao.entities.DatasetDao; import eu.eudat.dao.entities.ProjectDao; import eu.eudat.models.dataset.Dataset; import eu.eudat.models.dataset.DatasetTableRequest; import eu.eudat.models.helpers.DataTableData; import eu.eudat.models.listingmodels.DatasetListingModel; import eu.eudat.models.project.Project; import eu.eudat.models.project.ProjectTableRequest; import eu.eudat.queryable.QueryableList; import eu.eudat.utilities.builders.DomainModelConverter; import java.util.List; import java.util.UUID; /** * Created by ikalyvas on 12/15/2017. */ public class DatasetManager { public DataTableData getPaged(DatasetDao datatasetRepository, DatasetTableRequest datasetTableRequest) throws IllegalAccessException, InstantiationException{ QueryableList items = datatasetRepository.getWithCriteria(datasetTableRequest.getCriteria()); QueryableList pagedItems = PaginationManager.applyPaging( items ,datasetTableRequest); List datasets = new DomainModelConverter().fromDataModel( pagedItems.toList(), DatasetListingModel.class); DataTableData dataTable = new DataTableData(); dataTable.setData(datasets); dataTable.setTotalCount(items.count()); return dataTable; } public eu.eudat.models.dataset.Dataset getSingle(DatasetDao datatasetRepository, String id) throws InstantiationException, IllegalAccessException{ eu.eudat.models.dataset.Dataset dataset = new eu.eudat.models.dataset.Dataset(); dataset.fromDataModel(datatasetRepository.find(UUID.fromString(id))); return dataset; } }