no message
This commit is contained in:
parent
d617ad0bb1
commit
c40b24250a
|
@ -58,9 +58,10 @@ public class Datasets extends BaseController{
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasets/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<DatasetListingModel>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest,Principal principal) {
|
||||
public @ResponseBody
|
||||
ResponseItem<DataTableData<DatasetListingModel>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, Principal principal) {
|
||||
try {
|
||||
DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(this.getApiContext().getDatabaseRepository().getDatasetDao(), datasetTableRequest);
|
||||
DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(this.getApiContext(), datasetTableRequest, principal);
|
||||
return new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.OK).payload(dataTable);
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
|
|
@ -25,6 +25,7 @@ public interface DMPDao {
|
|||
DMP find(UUID id);
|
||||
|
||||
Long count();
|
||||
|
||||
QueryableList<DMP> getAuthenticated(QueryableList<DMP> query,UserInfo principal);
|
||||
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class DMPDaoImpl implements DMPDao {
|
|||
|
||||
@Override
|
||||
public QueryableList<DMP> getUserDmps(DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, UserInfo userInfo) {
|
||||
QueryableList<DMP> query = databaseService.getQueryable(DMP.class).where((builder, root) -> builder.equal(root.get("creator"),userInfo));
|
||||
QueryableList<DMP> query = databaseService.getQueryable(DMP.class).where((builder, root) -> builder.or(builder.equal(root.get("creator"),userInfo),builder.isMember(userInfo,root.get("users"))));
|
||||
if(datasetWizardAutocompleteRequest.getCriteria().getLike()!=null&&!datasetWizardAutocompleteRequest.getCriteria().getLike().isEmpty()){
|
||||
query.where((builder, root) -> builder.like(root.get("label"),"%"+datasetWizardAutocompleteRequest.getCriteria().getLike()+"%"));
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import eu.eudat.dao.Dao;
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.Project;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
|
@ -27,5 +28,6 @@ public interface DatasetDao {
|
|||
|
||||
Long count();
|
||||
|
||||
QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal);
|
||||
|
||||
}
|
|
@ -33,10 +33,14 @@ public class DatasetDaoImpl implements DatasetDao {
|
|||
@Override
|
||||
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
|
||||
QueryableList<Dataset> query = databaseService.getQueryable(Dataset.class, Dataset.getHints());
|
||||
if(criteria.getLike()!=null&&!criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"),"%"+criteria.getLike()+"%"));
|
||||
if(criteria.getStatus()!=null)query.where((builder, root) -> builder.equal(root.get("status"),criteria.getStatus()));
|
||||
if(criteria.getPeriodEnd()!=null)query.where((builder, root) -> builder.lessThan(root.get("created"),criteria.getPeriodEnd()));
|
||||
if(criteria.getPeriodStart()!=null)query.where((builder, root) -> builder.greaterThan(root.get("created"),criteria.getPeriodStart()));
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%"));
|
||||
if (criteria.getStatus() != null)
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), criteria.getStatus()));
|
||||
if (criteria.getPeriodEnd() != null)
|
||||
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
||||
if (criteria.getPeriodStart() != null)
|
||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||
return query;
|
||||
}
|
||||
|
||||
|
@ -54,5 +58,9 @@ public class DatasetDaoImpl implements DatasetDao {
|
|||
return this.databaseService.count(Dataset.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) {
|
||||
query.where((builder, root) -> builder.or(builder.equal(root.get("dmp").get("creator"), principal), builder.isMember(principal, root.get("dmp").get("users"))));
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ import eu.eudat.utilities.builders.DomainModelConverter;
|
|||
public class DataManagementPlanManager {
|
||||
|
||||
public DataTableData<DataManagementPlanListingModel> getPaged(ApiContext apiContext, DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||
UserInfo userInfo = apiContext.getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
QueryableList<DMP> items = apiContext.getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
||||
QueryableList<DMP> authItems = apiContext.getDatabaseRepository().getDmpDao().getAuthenticated(items, userInfo);
|
||||
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.dao.entities.*;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.criteria.DataRepositoryCriteria;
|
||||
import eu.eudat.models.criteria.RegistryCriteria;
|
||||
import eu.eudat.models.criteria.ServiceCriteria;
|
||||
|
@ -11,6 +12,7 @@ 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.models.security.Principal;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
@ -25,9 +27,12 @@ import java.util.UUID;
|
|||
*/
|
||||
public class DatasetManager {
|
||||
|
||||
public DataTableData<DatasetListingModel> getPaged(DatasetDao datatasetRepository, DatasetTableRequest datasetTableRequest) throws IllegalAccessException, InstantiationException{
|
||||
QueryableList<eu.eudat.entities.Dataset> items = datatasetRepository.getWithCriteria(datasetTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.entities.Dataset> pagedItems = PaginationManager.applyPaging( items ,datasetTableRequest);
|
||||
public DataTableData<DatasetListingModel> getPaged(ApiContext apiContext, DatasetTableRequest datasetTableRequest, Principal principal) throws IllegalAccessException, InstantiationException{
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
QueryableList<eu.eudat.entities.Dataset> items = apiContext.getDatabaseRepository().getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.entities.Dataset> authItems = apiContext.getDatabaseRepository().getDatasetDao().getAuthenticated(items,userInfo);
|
||||
QueryableList<eu.eudat.entities.Dataset> pagedItems = PaginationManager.applyPaging( authItems ,datasetTableRequest);
|
||||
if(datasetTableRequest.getWithHint())pagedItems.withHint("datasetFullyDetailed");
|
||||
List<DatasetListingModel> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, DatasetListingModel>().fromDataModel( pagedItems.toList(), DatasetListingModel.class);
|
||||
DataTableData<DatasetListingModel> dataTable = new DataTableData<DatasetListingModel>();
|
||||
|
|
Loading…
Reference in New Issue