2017-12-15 00:01:26 +01:00
|
|
|
package eu.eudat.managers;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
import eu.eudat.dao.entities.ProjectDao;
|
|
|
|
import eu.eudat.models.helpers.DataTableData;
|
|
|
|
import eu.eudat.models.project.Project;
|
|
|
|
import eu.eudat.models.project.ProjectTableRequest;
|
2017-12-17 22:34:24 +01:00
|
|
|
import eu.eudat.queryable.QueryableList;
|
2017-12-15 00:01:26 +01:00
|
|
|
import eu.eudat.utilities.builders.DomainModelConverter;
|
|
|
|
|
|
|
|
public class ProjectManager {
|
|
|
|
|
|
|
|
public DataTableData<eu.eudat.models.project.Project> getPaged(ProjectDao projectRepository, ProjectTableRequest projectTableRequest) throws IllegalAccessException, InstantiationException{
|
2017-12-17 22:34:24 +01:00
|
|
|
QueryableList<eu.eudat.entities.Project> items = projectRepository.getWithCriteria(projectTableRequest.getCriteria());
|
|
|
|
QueryableList<eu.eudat.entities.Project> pagedItems = PaginationManager.applyPaging(items,projectTableRequest);
|
|
|
|
List<eu.eudat.models.project.Project> projects = new DomainModelConverter<eu.eudat.entities.Project, Project>().fromDataModel(pagedItems.toList(), eu.eudat.models.project.Project.class);
|
2017-12-15 00:01:26 +01:00
|
|
|
DataTableData<eu.eudat.models.project.Project> dataTable = new DataTableData<eu.eudat.models.project.Project>();
|
|
|
|
dataTable.setData(projects);
|
2017-12-18 17:26:38 +01:00
|
|
|
dataTable.setTotalCount(projects.size());
|
2017-12-15 00:01:26 +01:00
|
|
|
return dataTable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public eu.eudat.models.project.Project getSingle(ProjectDao projectRepository, String id) throws InstantiationException, IllegalAccessException{
|
|
|
|
eu.eudat.models.project.Project project = new eu.eudat.models.project.Project();
|
2017-12-17 22:34:24 +01:00
|
|
|
project.fromDataModel(projectRepository.find(UUID.fromString(id)));
|
2017-12-15 00:01:26 +01:00
|
|
|
return project;
|
|
|
|
}
|
|
|
|
}
|