From 2c51468dfe5afe5ae5747ff3e32b378ee9658539 Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Tue, 26 Mar 2019 16:30:33 +0200 Subject: [PATCH] Adds Dataset Profile Versioning. --- .../eudat/data/entities/DatasetProfile.java | 39 ++---- .../main/java/eu/eudat/controllers/Admin.java | 20 +++- .../DatasetProfileNewVersionException.java | 9 ++ .../logic/managers/DatasetProfileManager.java | 40 ++++++- .../data/admin/composite/DatasetProfile.java | 13 +- .../DatasetProfileListingModel.java | 21 ++-- .../admin/dataset-profile/dataset-profile.ts | 1 + .../dataset-profile-criteria.ts | 2 + .../dataset-profile.service.ts | 9 +- .../dataset-profile.routing.ts | 10 +- .../editor/dataset-profile-editor-model.ts | 3 + .../dataset-profile-editor.component.html | 4 +- .../dataset-profile-editor.component.ts | 111 ++++++++++++------ .../dataset-profile-listing.component.html | 6 + .../dataset-profile-listing.component.ts | 54 +++++++-- 15 files changed, 231 insertions(+), 111 deletions(-) create mode 100644 dmp-backend/web/src/main/java/eu/eudat/exceptions/datasetprofile/DatasetProfileNewVersionException.java diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/entities/DatasetProfile.java b/dmp-backend/data/src/main/java/eu/eudat/data/entities/DatasetProfile.java index 09b6c6497..a78f5598f 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/entities/DatasetProfile.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/entities/DatasetProfile.java @@ -25,7 +25,6 @@ public class DatasetProfile implements DataEntity { private Status(short value) { this.value = value; } - public short getValue() { return value; } @@ -60,11 +59,9 @@ public class DatasetProfile implements DataEntity { @Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false) private String definition; - @Column(name = "\"Status\"", nullable = false) private Short status; - @Column(name = "\"Created\"") @Convert(converter = DateToUTCConverter.class) private Date created; @@ -76,90 +73,80 @@ public class DatasetProfile implements DataEntity { @Column(name = "\"Description\"") private String description; + @Column(name = "\"GroupId\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") + private UUID groupId; + + @Column(name = "\"Version\"", nullable = false) + private Short version; + public String getDescription() { return description; } - - public void setDescription(String description) { this.description = description; } - public Short getStatus() { return status; } - - public void setStatus(Short status) { this.status = status; } - public Date getCreated() { return created; } - - public void setCreated(Date created) { this.created = created; } - public Date getModified() { return modified; } - - public void setModified(Date modified) { this.modified = modified; } - public UUID getId() { return id; } - - public void setId(UUID id) { - this.id = id; - } + public void setId(UUID id) { this.id = id;} public String getLabel() { return label; } - public void setLabel(String label) { this.label = label; } - public String getDefinition() { return definition; } - public void setDefinition(String definition) { this.definition = definition; } - public Set getDataset() { return dataset; } - public void setDataset(Set dataset) { this.dataset = dataset; } + public UUID getGroupId() { return groupId; } + public void setGroupId(UUID groupId) { this.groupId = groupId;} + + public Short getVersion() { return version; } + public void setVersion(Short version) { this.version = version; } + @Override public String toString() { return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + "]"; } - @Override public void update(DatasetProfile entity) { - } @Override diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java index eed7ad863..3afea30b7 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java @@ -2,6 +2,7 @@ package eu.eudat.controllers; import eu.eudat.core.logger.Logger; import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; +import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException; import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption; import eu.eudat.logic.managers.AdminManager; import eu.eudat.logic.managers.DatasetProfileManager; @@ -67,12 +68,20 @@ public class Admin extends BaseController { return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE)); } + @Transactional + @RequestMapping(method = RequestMethod.POST, value = {"/newVersion/{id}"}, produces = "application/json") + public ResponseEntity newVersionDatasetProfile(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception { + try { + eu.eudat.data.entities.DatasetProfile modelDefinition = this.datasetProfileManager.createNewVersionDatasetProfile(id, profile); + return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId()); + } catch (DatasetProfileNewVersionException exception) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage())); + } + } + @RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json") public ResponseEntity> get(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) { - eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); - eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); - datasetprofile.setLabel(profile.getLabel()); - datasetprofile.setStatus(profile.getStatus()); + eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = this.datasetProfileManager.getDatasetProfile(id); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(datasetprofile)); } @@ -92,7 +101,7 @@ public class Admin extends BaseController { return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile)); } - @org.springframework.transaction.annotation.Transactional + @Transactional @RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json") public ResponseEntity> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) { eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(id); @@ -126,7 +135,6 @@ public class Admin extends BaseController { } } - @RequestMapping(method = RequestMethod.POST, value = {"/upload"}) public ResponseEntity setDatasetProfileXml(@RequestParam("file") MultipartFile file, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException, IOException { diff --git a/dmp-backend/web/src/main/java/eu/eudat/exceptions/datasetprofile/DatasetProfileNewVersionException.java b/dmp-backend/web/src/main/java/eu/eudat/exceptions/datasetprofile/DatasetProfileNewVersionException.java new file mode 100644 index 000000000..d55f1a73b --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/exceptions/datasetprofile/DatasetProfileNewVersionException.java @@ -0,0 +1,9 @@ +package eu.eudat.exceptions.datasetprofile; + +public class DatasetProfileNewVersionException extends RuntimeException { + + public DatasetProfileNewVersionException(String message) { + super(message); + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index 347e69513..4dab51aef 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -7,6 +7,7 @@ import eu.eudat.data.dao.entities.DatasetProfileDao; import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteRequest; import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem; +import eu.eudat.exceptions.datasetprofile.DatasetProfileNewVersionException; import eu.eudat.logic.builders.model.models.DataTableDataBuilder; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.operations.DatabaseRepository; @@ -49,6 +50,15 @@ public class DatasetProfileManager { this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository(); } + public eu.eudat.models.data.admin.composite.DatasetProfile getDatasetProfile(String id) { + eu.eudat.data.entities.DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); + eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); + datasetprofile.setLabel(profile.getLabel()); + datasetprofile.setStatus(profile.getStatus()); + + return datasetprofile; + } + public List getWithCriteria(DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException { QueryableList items = databaseRepository.getDatasetProfileDao().getWithCriteria(datasetProfileAutocompleteRequest.getCriteria()); List datasetProfiles = items.select(item -> new DatasetProfileAutocompleteItem().fromDataModel(item)); @@ -104,10 +114,7 @@ public class DatasetProfileManager { return result; } - public ResponseEntity getDocument(eu.eudat.models.data.user.composite.DatasetProfile datasetProfile, String label) throws IllegalAccessException, IOException, InstantiationException { - - FileEnvelope envelope = getXmlDocument(datasetProfile, label); InputStream resource = new FileInputStream(envelope.getFile()); System.out.println("Mime Type of " + envelope.getFilename() + " is " + @@ -137,7 +144,6 @@ public class DatasetProfileManager { return fileEnvelope; } - public eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile createDatasetProfileFromXml(MultipartFile multiPartFile) { ImportXmlBuilderDatasetProfile xmlBuilder = new ImportXmlBuilderDatasetProfile(); try { @@ -156,4 +162,30 @@ public class DatasetProfileManager { fos.close(); return convFile; } + + public eu.eudat.data.entities.DatasetProfile createNewVersionDatasetProfile(String id, eu.eudat.models.data.admin.composite.DatasetProfile profile) throws Exception { + // Getting the DatasetProfile which we will create its new version. + eu.eudat.data.entities.DatasetProfile oldDatasetProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); + + // Getting the DatasetProfile with the latest Version. + DatasetProfileCriteria criteria = new DatasetProfileCriteria(); + LinkedList list = new LinkedList<>(); + list.push(oldDatasetProfile.getGroupId()); + criteria.setGroupIds(list); + criteria.setAllVersions(false); + QueryableList datasetProfileQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria); + eu.eudat.data.entities.DatasetProfile latestVersionDatasetProfile = datasetProfileQueryableList.getSingle(); + + if (latestVersionDatasetProfile.getVersion().equals(oldDatasetProfile.getVersion())){ + eu.eudat.models.data.admin.composite.DatasetProfile sortedProfile = profile.toShort(); + eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(sortedProfile, apiContext); + modelDefinition.setLabel(oldDatasetProfile.getLabel()); + modelDefinition.setVersion((short) (oldDatasetProfile.getVersion() + 1)); + modelDefinition.setGroupId(oldDatasetProfile.getGroupId()); + apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition); + return modelDefinition; + } else { + throw new DatasetProfileNewVersionException("Version to update not the latest."); + } + } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/admin/composite/DatasetProfile.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/admin/composite/DatasetProfile.java index 9d257fc18..b80006228 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/admin/composite/DatasetProfile.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/admin/composite/DatasetProfile.java @@ -13,19 +13,16 @@ public class DatasetProfile { private List
sections; private List pages; private Short status; + private Short version; public List
getSections() { return sections; } - - public void setSections(List
sections) { - this.sections = sections; - } + public void setSections(List
sections) { this.sections = sections; } public String getLabel() { return label; } - public void setLabel(String label) { this.label = label; } @@ -33,7 +30,6 @@ public class DatasetProfile { public List getPages() { return pages; } - public void setPages(List pages) { this.pages = pages; } @@ -41,11 +37,13 @@ public class DatasetProfile { public Short getStatus() { return status; } - public void setStatus(Short status) { this.status = status; } + public Short getVersion() { return version; } + public void setVersion(Short version) { this.version = version; } + public void buildProfile(eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle) { this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class); this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class); @@ -62,6 +60,7 @@ public class DatasetProfile { shortProfile.setSections(shortSection); shortProfile.setPages(this.pages); shortProfile.setStatus(this.status); + shortProfile.setVersion(this.version); return shortProfile; } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileListingModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileListingModel.java index 4e8912646..b1bece0a6 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileListingModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/datasetprofile/DatasetProfileListingModel.java @@ -10,21 +10,17 @@ import java.util.UUID; public class DatasetProfileListingModel implements DataModel { private UUID id; - private String label; - private Short status; - private Date created; - private Date modified = new Date(); - private String description; + private Short version; + private UUID groupId; public UUID getId() { return id; } - public void setId(UUID id) { this.id = id; } @@ -32,7 +28,6 @@ public class DatasetProfileListingModel implements DataModel(this.actionUrl + 'addDmp', data); } @@ -46,18 +47,20 @@ export class DatasetProfileService { return this.http.post(this.actionUrl + 'datasetprofile/clone/' + id, {}); } + newVersion(id, data) { + return this.http.post(this.actionUrl + 'newVersion/' + id, data); + } + delete(id: string, data): Observable { //return this.http.post(this.actionUrl + 'addDmp/' + id, data); return this.http.delete(this.actionUrl + id, {}); } - - public downloadXML(id: string): Observable> { + downloadXML(id: string): Observable> { let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml') return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response', headers: headerXml }); } - uploadFile(file: FileList, labelSent: string): Observable> { const params = new BaseHttpParams(); params.interceptorContext = { diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts index 3fe6a4520..8f9b99fc5 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/dataset-profile.routing.ts @@ -16,6 +16,14 @@ const routes: Routes = [ path: 'clone/:cloneid', component: DatasetProfileEditorComponent }, + { + path: 'newversion/:newversionid', + component: DatasetProfileEditorComponent + }, + { + path: 'versions/:groupId', + component: DatasetProfileListingComponent, + }, { path: '', component: DatasetProfileListingComponent, @@ -26,4 +34,4 @@ const routes: Routes = [ imports: [RouterModule.forChild(routes)], exports: [RouterModule] }) -export class DatasetProfileRoutingModule { } \ No newline at end of file +export class DatasetProfileRoutingModule { } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor-model.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor-model.ts index 01fd7d981..4cf1a9fcd 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor-model.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor-model.ts @@ -11,12 +11,14 @@ export class DatasetProfileEditorModel extends BaseFormModel { public pages: Array = new Array(); public label: string; public status: number; + public version: number; fromModel(item: DatasetProfile): DatasetProfileEditorModel { if (item.sections) { this.sections = item.sections.map(x => new SectionEditorModel().fromModel(x)); } if (item.pages) { this.pages = item.pages.map(x => new PageEditorModel().fromModel(x)); } this.label = item.label; this.status = item.status; + this.version = item.version; return this; } @@ -38,6 +40,7 @@ export class DatasetProfileEditorModel extends BaseFormModel { formGroup.addControl('pages', this.formBuilder.array(pagesFormArray)); formGroup.addControl('label', new FormControl(this.label, Validators.required)); formGroup.addControl('status', new FormControl(this.status)); + formGroup.addControl('version', new FormControl(this.version)); return formGroup; } } diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html index 37648cb50..9b1557554 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.html @@ -1,6 +1,6 @@ 
- {{'GENERAL.VALIDATION.REQUIRED' | translate}} @@ -73,4 +73,4 @@
- \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts index 5dc800025..f8ecac49c 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/dataset-profile-editor.component.ts @@ -31,6 +31,7 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn form: FormGroup; previewerFormGroup: FormGroup; private datasetProfileId: string; + newVersionId: string; dataWizardModel: DatasetWizardModel; @ViewChild('stepper') stepper: MatHorizontalStepper; viewOnly = false; @@ -53,46 +54,66 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn this.route.paramMap.pipe(takeUntil(this._destroyed)).subscribe((paramMap: ParamMap) => { this.datasetProfileId = paramMap.get('id'); const cloneId = paramMap.get('cloneid'); + this.newVersionId = paramMap.get('newversionid'); if (this.datasetProfileId != null) { this.isNew = false; this.datasetProfileService.getDatasetProfileById(this.datasetProfileId) .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) .subscribe( - data => { - try { - this.dataModel = new DatasetProfileEditorModel().fromModel(data); - // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; - this.form = this.dataModel.buildForm(); - if (this.dataModel.status === DatasetProfileEnum.FINALIZED) { - this.form.disable(); - this.viewOnly = true; - } - this.prepareForm(); - } catch { - this.logger.error('Could not parse MasterItem: ' + data); - this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); + data => { + try { + this.dataModel = new DatasetProfileEditorModel().fromModel(data); + // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; + this.form = this.dataModel.buildForm(); + if (this.dataModel.status === DatasetProfileEnum.FINALIZED) { + this.form.disable(); + this.viewOnly = true; } - }, - error => this.onCallbackError(error) + this.prepareForm(); + } catch { + this.logger.error('Could not parse MasterItem: ' + data); + this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); + } + }, + error => this.onCallbackError(error) ); } else if (cloneId != null) { this.datasetProfileService.clone(cloneId) .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) .subscribe( - data => { - try { - this.dataModel = new DatasetProfileEditorModel().fromModel(data); - // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; - this.dataModel.status = DatasetProfileEnum.SAVED; - this.form = this.dataModel.buildForm(); - this.prepareForm(); - } catch { - this.logger.error('Could not parse MasterItem: ' + data); - this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); - } - }, - error => this.onCallbackError(error) + data => { + try { + this.dataModel = new DatasetProfileEditorModel().fromModel(data); + // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; + this.dataModel.status = DatasetProfileEnum.SAVED; + this.form = this.dataModel.buildForm(); + this.prepareForm(); + } catch { + this.logger.error('Could not parse MasterItem: ' + data); + this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); + } + }, + error => this.onCallbackError(error) + ); + } else if (this.newVersionId != null) { + this.datasetProfileService.getDatasetProfileById(this.newVersionId) + .pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed)) + .subscribe( + data => { + try { + this.dataModel = new DatasetProfileEditorModel().fromModel(data); + // this.isDeleted = this.masterItem.isActive === IsActive.Inactive; + this.form = this.dataModel.buildForm(); + this.form.get('version').setValue(this.form.get('version').value + 1); + this.form.controls['label'].disable(); + this.prepareForm(); + } catch { + this.logger.error('Could not parse MasterItem: ' + data); + this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error); + } + }, + error => this.onCallbackError(error) ); } else { this.dataModel = new DatasetProfileEditorModel(); @@ -155,6 +176,14 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn .subscribe(() => { this.router.navigate(['/dataset-profiles']); }); + } else if (this.newVersionId) { + this.datasetProfileService.newVersion(this.newVersionId, data) + .pipe(takeUntil(this._destroyed)) + .subscribe(() => { + this.router.navigate(['/dataset-profiles']); + }, + error => this.onCallbackErrorNewVersion(error) + ); } else { this.form.get('status').setValue(0); data = this.form.value; @@ -182,6 +211,10 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn this.router.navigate(['/master-items']); } + onCallbackErrorNewVersion(errorResponse: HttpErrorResponse) { + this.uiNotificationService.snackBarNotification(errorResponse.error.message, SnackBarNotificationLevel.Error); + } + onCallbackError(errorResponse: HttpErrorResponse) { // const error: HttpError = this.httpErrorHandlingService.getError(errorResponse); // if (error.statusCode === 400) { @@ -208,18 +241,18 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn this.datasetProfileService.delete(this.datasetProfileId, this.form.value) .pipe(takeUntil(this._destroyed)) .subscribe( - complete => { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/dataset-profiles']); - }, - error => { - this.onCallbackError(error); - if (error.error.statusCode == 674) { - this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Error); - } else { - this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error); - } + complete => { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success); + this.router.navigate(['/dataset-profiles']); + }, + error => { + this.onCallbackError(error); + if (error.error.statusCode == 674) { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Error); + } else { + this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error); } + } ); } }); diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html index c4ddd17d2..75e04772d 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/listing/dataset-profile-listing.component.html @@ -29,9 +29,15 @@ {{'DATASET-PROFILE-LISTING.COLUMNS.ACTIONS' | translate}} + +