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()));
|
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.ACTIVE.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
query.where(((builder, root) -> builder.equal(root.get("isPublic"), criteria.getIsPublic())));
|
if (criteria.getIsPublic()) {
|
||||||
|
query.where(((builder, root) -> builder.equal(root.get("isPublic"), criteria.getIsPublic())));
|
||||||
|
}
|
||||||
/*if (criteria.getRole() != null) {
|
/*if (criteria.getRole() != null) {
|
||||||
if (criteria.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())) {
|
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()));
|
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")
|
@RequestMapping(method = RequestMethod.GET, value = {"/versions/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
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 {
|
@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));
|
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;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<VersionListingModel> getAllVersions(String groupId, Principal principal) {
|
public List<VersionListingModel> getAllVersions(String groupId, Principal principal, Boolean isPublic) {
|
||||||
UUID principalId = principal.getId();
|
UUID principalId = principal != null ? principal.getId() : null;
|
||||||
List<VersionListingModel> versions = new ArrayList<>();
|
List<VersionListingModel> versions = new ArrayList<>();
|
||||||
QueryableList<DMP> items = null;
|
QueryableList<DMP> items = null;
|
||||||
QueryableList<DMP> authItems = null;
|
QueryableList<DMP> authItems = null;
|
||||||
|
@ -330,10 +330,10 @@ public class DataManagementPlanManager {
|
||||||
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
|
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
|
||||||
criteria.setGroupIds(Collections.singletonList(UUID.fromString(groupId)));
|
criteria.setGroupIds(Collections.singletonList(UUID.fromString(groupId)));
|
||||||
criteria.setAllVersions(true);
|
criteria.setAllVersions(true);
|
||||||
criteria.setIsPublic(principalId == null);
|
criteria.setIsPublic(isPublic);
|
||||||
criteria.setOnlyPublic(principalId == null);
|
criteria.setOnlyPublic(isPublic);
|
||||||
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria);
|
items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria);
|
||||||
if (principalId != null) {
|
if (!isPublic) {
|
||||||
authItems = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, principalId, roles);
|
authItems = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, principalId, roles);
|
||||||
} else {
|
} else {
|
||||||
authItems = items;
|
authItems = items;
|
||||||
|
|
|
@ -58,8 +58,8 @@ export class DmpService {
|
||||||
return this.http.get<DmpOverviewModel>(this.actionUrl + 'publicOverview/' + id, { headers: this.headers })
|
return this.http.get<DmpOverviewModel>(this.actionUrl + 'publicOverview/' + id, { headers: this.headers })
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllVersions(id: string): Observable<VersionListingModel[]> {
|
getAllVersions(id: string, isPublic: boolean): Observable<VersionListingModel[]> {
|
||||||
return this.http.get<VersionListingModel[]>(this.actionUrl + 'versions/' + id, { headers: this.headers })
|
return this.http.get<VersionListingModel[]>(this.actionUrl + 'versions/' + id + '?public=' + isPublic, { headers: this.headers })
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock(id: String): Observable<DmpModel> {
|
unlock(id: String): Observable<DmpModel> {
|
||||||
|
|
|
@ -468,7 +468,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllVersions(dmp: DmpOverviewModel) {
|
getAllVersions(dmp: DmpOverviewModel) {
|
||||||
this.dmpService.getAllVersions(dmp.groupId)
|
this.dmpService.getAllVersions(dmp.groupId, this.isPublicView)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(items => {
|
.subscribe(items => {
|
||||||
this.versions = items;
|
this.versions = items;
|
||||||
|
@ -618,7 +618,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
viewVersions(rowId: String, rowLabel: String) {
|
viewVersions(rowId: String, rowLabel: String) {
|
||||||
if (this.dmp.isPublic && !this.isUserOwner) {
|
if (this.isPublicView) {
|
||||||
this.router.navigate(['/explore-plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
this.router.navigate(['/explore-plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
||||||
} else {
|
} else {
|
||||||
this.router.navigate(['/plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
this.router.navigate(['/plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
||||||
|
@ -630,7 +630,11 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
versionChanged(versionId: string): void {
|
versionChanged(versionId: string): void {
|
||||||
this.router.navigate(['/plans/overview/' + versionId]);
|
if (this.isPublicView) {
|
||||||
|
this.router.navigate(['/explore-plans/publicOverview/' + versionId]);
|
||||||
|
} else {
|
||||||
|
this.router.navigate(['/plans/overview/' + versionId]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openShareDialog(rowId: any, rowName: any) {
|
openShareDialog(rowId: any, rowName: any) {
|
||||||
|
|
Loading…
Reference in New Issue