Add criteria for the recent activity model
This commit is contained in:
parent
5db3485079
commit
325979a896
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.criteria.RecentActivityCriteria;
|
||||
import eu.eudat.logic.managers.DashBoardManager;
|
||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
|
@ -44,11 +45,11 @@ public class DashBoardController extends BaseController {
|
|||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DashBoardStatistics>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/dashboard/recentActivity"}, produces = "application/json")
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/dashboard/recentActivity"}, produces = "application/json")
|
||||
@Transactional
|
||||
public ResponseEntity<ResponseItem<List<RecentActivityModel>>> getNewRecentActivity(@RequestParam(name = "numOfActivities", required = false, defaultValue = "5") Integer numberOfActivities,
|
||||
public ResponseEntity<ResponseItem<List<RecentActivityModel>>> getNewRecentActivity(@RequestBody RecentActivityCriteria criteria, @RequestParam(name = "numOfActivities", required = false, defaultValue = "5") Integer numberOfActivities,
|
||||
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
|
||||
List<RecentActivityModel> statistics = dashBoardManager.getNewRecentActivity(principal, numberOfActivities);
|
||||
List<RecentActivityModel> statistics = dashBoardManager.getNewRecentActivity(criteria, principal, numberOfActivities);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<RecentActivityModel>>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package eu.eudat.criteria;
|
||||
|
||||
public class RecentActivityCriteria {
|
||||
private String like;
|
||||
private String order;
|
||||
|
||||
public String getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLike(String like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
public String getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(String order) {
|
||||
this.order = order;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.logic.managers;
|
||||
|
||||
import eu.eudat.criteria.RecentActivityCriteria;
|
||||
import eu.eudat.data.dao.criteria.*;
|
||||
import eu.eudat.data.dao.entities.DMPDao;
|
||||
import eu.eudat.data.dao.entities.DatasetDao;
|
||||
|
@ -182,16 +183,18 @@ public class DashBoardManager {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public List<RecentActivityModel> getNewRecentActivity(Principal principal, Integer numberofactivities) {
|
||||
public List<RecentActivityModel> getNewRecentActivity(RecentActivityCriteria criteria, Principal principal, Integer numberofactivities) {
|
||||
List<RecentActivityModel> recentActivityModels = new ArrayList<>();
|
||||
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
|
||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||
datasetCriteria.setLike(criteria.getLike());
|
||||
datasetCriteria.setAllVersions(false);
|
||||
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
||||
dataManagementPlanCriteria.setAllVersions(false);
|
||||
dataManagementPlanCriteria.setLike(criteria.getLike());
|
||||
|
||||
QueryableList<DMP> dmpList;
|
||||
QueryableList<Dataset> datasetList;
|
||||
|
@ -210,7 +213,7 @@ public class DashBoardManager {
|
|||
|
||||
CompletableFuture<List<RecentActivityModel>> dmps = dmpList
|
||||
.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
|
||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||
.orderBy((builder, root) -> builder.desc(root.get(criteria.getOrder())))
|
||||
.take(numberofactivities)
|
||||
.selectAsync(item -> {
|
||||
return new RecentDmpModel().fromEntity(item);
|
||||
|
@ -219,7 +222,7 @@ public class DashBoardManager {
|
|||
|
||||
CompletableFuture<List<RecentActivityModel>> datasets = datasetList
|
||||
.withHint(HintedModelFactory.getHint(DatasetListingModel.class))
|
||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||
.orderBy((builder, root) -> builder.desc(root.get(criteria.getOrder())))
|
||||
.take(numberofactivities)
|
||||
.selectAsync(item -> {
|
||||
return new RecentDatasetModel().fromEntity(item);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
export enum RecentActivityOrder {
|
||||
LABEL = "label",
|
||||
CREATED = "created",
|
||||
MODIFIED = "modified",
|
||||
STATUS = "status"
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
import { RecentActivityOrder } from '@app/core/common/enum/recent-activity-order';
|
||||
import { BaseCriteria } from '../base-criteria';
|
||||
|
||||
export class RecentActivityCriteria extends BaseCriteria{
|
||||
public order: RecentActivityOrder = RecentActivityOrder.MODIFIED;
|
||||
}
|
|
@ -5,6 +5,7 @@ import { environment } from '../../../../environments/environment';
|
|||
import { DashboardStatisticsModel } from '../../model/dashboard/dashboard-statistics-model';
|
||||
import { BaseHttpService } from '../http/base-http.service';
|
||||
import { ConfigurationService } from '../configuration/configuration.service';
|
||||
import { RecentActivityCriteria } from '@app/core/query/recent-activity/recent-activity-criteria';
|
||||
|
||||
@Injectable()
|
||||
export class DashboardService {
|
||||
|
@ -25,7 +26,7 @@ export class DashboardService {
|
|||
return this.http.get<DashboardStatisticsModel>(this.actionUrl + 'me/getStatistics', { headers: this.headers });
|
||||
}
|
||||
|
||||
getRecentAcitvity(): Observable<any[]> {
|
||||
return this.http.get<any[]>(this.actionUrl + 'recentActivity', {headers: this.headers});
|
||||
getRecentAcitvity(criteria: RecentActivityCriteria): Observable<any[]> {
|
||||
return this.http.post<any[]>(this.actionUrl + 'recentActivity', criteria, {headers: this.headers});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue