Fixes the functionality to see finalized Datasets when not signed in.
This commit is contained in:
parent
29f9c0992f
commit
0d73fb2a8b
|
@ -14,4 +14,6 @@ public interface DatasetDao extends DatabaseAccessLayer<Dataset, UUID> {
|
|||
|
||||
QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal);
|
||||
|
||||
Dataset isPublicDataset(UUID id);
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package eu.eudat.data.dao.entities;
|
|||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
@ -20,9 +21,7 @@ import java.util.concurrent.CompletableFuture;
|
|||
public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDao {
|
||||
|
||||
@Autowired
|
||||
public DatasetDaoImpl(DatabaseService<Dataset> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
public DatasetDaoImpl(DatabaseService<Dataset> databaseService) { super(databaseService); }
|
||||
|
||||
@Override
|
||||
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
|
||||
|
@ -62,6 +61,14 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
|||
return getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class).withHint(hint).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset isPublicDataset(UUID id) {
|
||||
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
|
||||
query.where(((builder, root) -> builder.equal(root.get("id"), id)));
|
||||
|
||||
return query.withHint("datasetListingModel").getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) {
|
||||
if (principal.getId() == null) query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
|
||||
|
|
|
@ -101,6 +101,18 @@ public class DatasetWizardController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity getSinglePublic(@PathVariable String id) throws Exception {
|
||||
try {
|
||||
DatasetWizardModel dataset = this.datasetManager.getSinglePublic(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
|
|
|
@ -160,6 +160,20 @@ public class DatasetManager {
|
|||
return dataset;
|
||||
}
|
||||
|
||||
public DatasetWizardModel getSinglePublic(String id) throws Exception {
|
||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().isPublicDataset(UUID.fromString(id));
|
||||
|
||||
if (datasetEntity != null && datasetEntity.getStatus() == 1 && datasetEntity.getDmp().getStatus() == 1){
|
||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
||||
dataset.fromDataModel(datasetEntity);
|
||||
return dataset;
|
||||
}
|
||||
else {
|
||||
throw new Exception("Selected dataset is not public");
|
||||
}
|
||||
}
|
||||
|
||||
public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, eu.eudat.data.entities.Dataset datasetEntity) {
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(datasetEntity.getProfile());
|
||||
datasetprofile.setStatus(dataset.getStatus());
|
||||
|
|
|
@ -33,6 +33,10 @@ export class DatasetWizardService {
|
|||
return this.http.get<DatasetWizardModel>(this.actionUrl + id, { headers: this.headers }); // + 'getSingle/'
|
||||
}
|
||||
|
||||
public getSinglePublic(id: String): Observable<DatasetWizardModel> {
|
||||
return this.http.get<DatasetWizardModel>(this.actionUrl + 'public/' + id, { headers: this.headers }); // + 'getSingle/'
|
||||
}
|
||||
|
||||
public delete(id: string): Observable<DatasetWizardModel> {
|
||||
return this.http.delete<DatasetWizardModel>(this.actionUrl + id, { headers: this.headers });
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
|
||||
</button>
|
||||
</mat-menu>
|
||||
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
|
||||
<button mat-icon-button [matMenuTriggerFor]="actionsMenu" *ngIf="!publicMode">
|
||||
<mat-icon>more_vert</mat-icon>
|
||||
</button>
|
||||
|
||||
|
|
|
@ -24,11 +24,12 @@ import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item
|
|||
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
|
||||
import { DatasetDescriptionFormEditorModel } from '../../misc/dataset-description-form/dataset-description-form.model';
|
||||
import { DatasetWizardEditorModel } from './dataset-wizard-editor.model';
|
||||
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
|
||||
import { SnackBarNotificationLevel, UiNotificationService, SnackBarNotification } from '../../../core/services/notification/ui-notification-service';
|
||||
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
|
||||
import { DataTableRequest } from '../../../core/model/data-table/data-table-request';
|
||||
import { DatasetCopyDialogueComponent } from './dataset-copy-dialogue/dataset-copy-dialogue.component';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { error } from 'selenium-webdriver';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dataset-wizard-component',
|
||||
|
@ -41,6 +42,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
viewOnly = false;
|
||||
@ViewChild('stepper') stepper: MatStepper;
|
||||
editMode = false;
|
||||
publicMode = false;
|
||||
|
||||
DatasetStatus = DatasetStatus;
|
||||
dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||
|
@ -70,7 +72,6 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
super();
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.route
|
||||
.data
|
||||
|
@ -117,6 +118,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
this.itemId = params['id'];
|
||||
const dmpId = params['dmpId'];
|
||||
const newDmpId = queryParams['newDmpId'];
|
||||
const publicId = params['publicId'];
|
||||
if (this.itemId != null && newDmpId == null) {
|
||||
this.isNew = false;
|
||||
this.datasetWizardService.getSingle(this.itemId)
|
||||
|
@ -228,6 +230,45 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
// if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.
|
||||
this.loadDatasetProfiles();
|
||||
});
|
||||
} else if (publicId != null) {
|
||||
this.datasetWizardService.getSinglePublic(publicId)
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.catch((error: any) => {
|
||||
this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error);
|
||||
this.router.navigate(['/explore']);
|
||||
return Observable.of(null);
|
||||
})
|
||||
.subscribe(data => {
|
||||
if (data) {
|
||||
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
|
||||
if (this.datasetWizardModel.status === 1) {
|
||||
this.formGroup.disable();
|
||||
this.viewOnly = true;
|
||||
}
|
||||
this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp);
|
||||
this.loadDatasetProfiles();
|
||||
this.breadCrumbs = Observable.of([
|
||||
{
|
||||
parentComponentName: null,
|
||||
label: 'Datasets',
|
||||
url: '/datasets',
|
||||
notFoundResolver: [
|
||||
{
|
||||
parentComponentName: null,
|
||||
label: this.datasetWizardModel.dmp.project.label,
|
||||
url: '/projects/edit/' + this.datasetWizardModel.dmp.project.id
|
||||
},
|
||||
{
|
||||
parentComponentName: null,
|
||||
label: this.datasetWizardModel.dmp.label,
|
||||
url: '/plans/edit/' + this.datasetWizardModel.dmp.id,
|
||||
}]
|
||||
}]);
|
||||
}
|
||||
});
|
||||
this.publicMode = true;
|
||||
}
|
||||
else {
|
||||
this.datasetWizardModel = new DatasetWizardEditorModel();
|
||||
|
@ -246,10 +287,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
|
|||
this.availableProfiles = [];
|
||||
this.formGroup.get('profile').reset();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
this.route.params
|
||||
.pipe(takeUntil(this._destroyed))
|
||||
.subscribe((params: Params) => {
|
||||
|
|
|
@ -23,9 +23,9 @@ const routes: Routes = [
|
|||
},
|
||||
},
|
||||
{
|
||||
path: 'publicEdit/:id',
|
||||
path: 'publicEdit/:publicId',
|
||||
component: DatasetWizardComponent,
|
||||
canActivate: [AuthGuard],
|
||||
//canActivate: [AuthGuard],
|
||||
data: {
|
||||
public: true
|
||||
}
|
||||
|
@ -58,6 +58,10 @@ const routes: Routes = [
|
|||
{
|
||||
path: 'copy/:id',
|
||||
component: DatasetWizardComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
breadcrumb: true
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in New Issue