Fixed issues with elastic and last public version
This commit is contained in:
parent
f71f9b07e0
commit
a78044920a
|
@ -57,7 +57,9 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.ACTIVE.getValue()));
|
||||
}
|
||||
}
|
||||
if (criteria.getIsPublic()) {
|
||||
query.where(((builder, root) -> builder.equal(root.get("isPublic"), criteria.getIsPublic())));
|
||||
}
|
||||
/*if (criteria.getRole() != null) {
|
||||
if (criteria.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())) {
|
||||
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.OWNER.getValue()));
|
||||
|
|
|
@ -161,9 +161,9 @@ public class DMPs extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/versions/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<VersionListingModel>>> getVersions(@PathVariable(value= "id") String groupId,
|
||||
ResponseEntity<ResponseItem<List<VersionListingModel>>> getVersions(@PathVariable(value= "id") String groupId, @RequestParam(value= "public") Boolean isPublic,
|
||||
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||
List<VersionListingModel> versions = this.dataManagementPlanManager.getAllVersions(groupId, principal);
|
||||
List<VersionListingModel> versions = this.dataManagementPlanManager.getAllVersions(groupId, principal, isPublic);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<VersionListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(versions));
|
||||
}
|
||||
|
||||
|
|
|
@ -321,8 +321,8 @@ public class DataManagementPlanManager {
|
|||
return data;
|
||||
}
|
||||
|
||||
public List<VersionListingModel> getAllVersions(String groupId, Principal principal) {
|
||||
UUID principalId = principal.getId();
|
||||
public List<VersionListingModel> getAllVersions(String groupId, Principal principal, Boolean isPublic) {
|
||||
UUID principalId = principal != null ? principal.getId() : null;
|
||||
List<VersionListingModel> versions = new ArrayList<>();
|
||||
QueryableList<DMP> items = null;
|
||||
QueryableList<DMP> authItems = null;
|
||||
|
@ -330,10 +330,10 @@ public class DataManagementPlanManager {
|
|||
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
|
||||
criteria.setGroupIds(Collections.singletonList(UUID.fromString(groupId)));
|
||||
criteria.setAllVersions(true);
|
||||
criteria.setIsPublic(principalId == null);
|
||||
criteria.setOnlyPublic(principalId == null);
|
||||
criteria.setIsPublic(isPublic);
|
||||
criteria.setOnlyPublic(isPublic);
|
||||
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria);
|
||||
if (principalId != null) {
|
||||
if (!isPublic) {
|
||||
authItems = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, principalId, roles);
|
||||
} else {
|
||||
authItems = items;
|
||||
|
|
|
@ -58,8 +58,8 @@ export class DmpService {
|
|||
return this.http.get<DmpOverviewModel>(this.actionUrl + 'publicOverview/' + id, { headers: this.headers })
|
||||
}
|
||||
|
||||
getAllVersions(id: string): Observable<VersionListingModel[]> {
|
||||
return this.http.get<VersionListingModel[]>(this.actionUrl + 'versions/' + id, { headers: this.headers })
|
||||
getAllVersions(id: string, isPublic: boolean): Observable<VersionListingModel[]> {
|
||||
return this.http.get<VersionListingModel[]>(this.actionUrl + 'versions/' + id + '?public=' + isPublic, { headers: this.headers })
|
||||
}
|
||||
|
||||
unlock(id: String): Observable<DmpModel> {
|
||||
|
|
|
@ -468,7 +468,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
}
|
||||
|
||||
getAllVersions(dmp: DmpOverviewModel) {
|
||||
this.dmpService.getAllVersions(dmp.groupId)
|
||||
this.dmpService.getAllVersions(dmp.groupId, this.isPublicView)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe(items => {
|
||||
this.versions = items;
|
||||
|
@ -618,7 +618,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
// }
|
||||
|
||||
viewVersions(rowId: String, rowLabel: String) {
|
||||
if (this.dmp.isPublic && !this.isUserOwner) {
|
||||
if (this.isPublicView) {
|
||||
this.router.navigate(['/explore-plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
||||
} else {
|
||||
this.router.navigate(['/plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
||||
|
@ -630,8 +630,12 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
|||
}
|
||||
|
||||
versionChanged(versionId: string): void {
|
||||
if (this.isPublicView) {
|
||||
this.router.navigate(['/explore-plans/publicOverview/' + versionId]);
|
||||
} else {
|
||||
this.router.navigate(['/plans/overview/' + versionId]);
|
||||
}
|
||||
}
|
||||
|
||||
openShareDialog(rowId: any, rowName: any) {
|
||||
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
|
||||
|
|
Loading…
Reference in New Issue