Fixes bug on public Dataset export created by refactoring.

This commit is contained in:
Diamantis Tziotzios 2019-04-02 10:53:38 +03:00
parent aadc212002
commit 3da8557389
5 changed files with 18 additions and 9 deletions

View File

@ -206,7 +206,8 @@ public class DatasetManager {
visibilityRuleService.setProperties(properties); visibilityRuleService.setProperties(properties);
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules()); visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService); wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService);
File exportFile = new File(datasetEntity.getLabel() + ".docx"); String label = datasetEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
File exportFile = new File(label + ".docx");
FileOutputStream out = new FileOutputStream(exportFile); FileOutputStream out = new FileOutputStream(exportFile);
document.write(out); document.write(out);
out.close(); out.close();

View File

@ -51,6 +51,7 @@ public class PagedDatasetProfile implements PropertiesGenerator {
datasetProfilePage.setSections(profile.getSections().stream().filter(item -> item.getPage().equals(page.getId())).collect(Collectors.toList())); datasetProfilePage.setSections(profile.getSections().stream().filter(item -> item.getPage().equals(page.getId())).collect(Collectors.toList()));
this.pages.add(datasetProfilePage); this.pages.add(datasetProfilePage);
} }
return this; return this;
} }

View File

@ -20,6 +20,6 @@ export class QuickWizardService {
} }
createQuickDatasetWizard(datasetCreateWizardModel: DatasetCreateWizardModel): Observable<DatasetCreateWizardModel> { createQuickDatasetWizard(datasetCreateWizardModel: DatasetCreateWizardModel): Observable<DatasetCreateWizardModel> {
return this.http.post<DatasetCreateWizardModel>(this.actionUrl + '/datasetcreate', datasetCreateWizardModel, { headers: this.headers }); return this.http.post<DatasetCreateWizardModel>(this.actionUrl + 'datasetcreate', datasetCreateWizardModel, { headers: this.headers });
} }
} }

View File

@ -55,6 +55,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
availableProfiles: DatasetProfileModel[] = []; availableProfiles: DatasetProfileModel[] = [];
itemId: string; itemId: string;
publicId: string;
downloadDocumentId: string;
isLinear = false; isLinear = false;
constructor( constructor(
@ -118,7 +120,10 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.itemId = params['id']; this.itemId = params['id'];
const dmpId = params['dmpId']; const dmpId = params['dmpId'];
const newDmpId = queryParams['newDmpId']; const newDmpId = queryParams['newDmpId'];
const publicId = params['publicId']; this.publicId = params['publicId'];
this.itemId ? this.downloadDocumentId = this.itemId : this.downloadDocumentId = this.publicId
if (this.itemId != null && newDmpId == null) { if (this.itemId != null && newDmpId == null) {
this.isNew = false; this.isNew = false;
this.datasetWizardService.getSingle(this.itemId) this.datasetWizardService.getSingle(this.itemId)
@ -230,8 +235,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
// if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP. // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.
this.loadDatasetProfiles(); this.loadDatasetProfiles();
}); });
} else if (publicId != null) { } else if (this.publicId != null) {
this.datasetWizardService.getSinglePublic(publicId) this.datasetWizardService.getSinglePublic(this.publicId)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.catch((error: any) => { .catch((error: any) => {
this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error); this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error);
@ -399,7 +404,9 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
} }
downloadPDF(): void { downloadPDF(): void {
this.datasetWizardService.downloadPDF(this.itemId)
this.datasetWizardService.downloadPDF(this.downloadDocumentId)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'application/pdf' }); const blob = new Blob([response.body], { type: 'application/pdf' });
@ -410,7 +417,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
} }
downloadDOCX(): void { downloadDOCX(): void {
this.datasetWizardService.downloadDOCX(this.itemId) this.datasetWizardService.downloadDOCX(this.downloadDocumentId)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'application/msword' }); const blob = new Blob([response.body], { type: 'application/msword' });
@ -422,7 +429,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
} }
downloadXML(): void { downloadXML(): void {
this.datasetWizardService.downloadXML(this.itemId) this.datasetWizardService.downloadXML(this.downloadDocumentId)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe(response => { .subscribe(response => {
const blob = new Blob([response.body], { type: 'application/xml' }); const blob = new Blob([response.body], { type: 'application/xml' });

View File

@ -140,7 +140,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
if (result) { if (result) {
this.datasetEditorWizardComponent.addDataset(); this.datasetEditorWizardComponent.addDataset();
} else if (result === false) { } else if (result === false) {
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value) this.quickWizardService.createQuickWizard(this.formGroup.value)
.pipe(takeUntil(this._destroyed)) .pipe(takeUntil(this._destroyed))
.subscribe( .subscribe(
complete => this.onCallbackSuccess() complete => this.onCallbackSuccess()