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.buildVisibilityContext(pagedDatasetProfile.getRules());
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);
document.write(out);
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()));
this.pages.add(datasetProfilePage);
}
return this;
}

View File

@ -20,6 +20,6 @@ export class QuickWizardService {
}
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[] = [];
itemId: string;
publicId: string;
downloadDocumentId: string;
isLinear = false;
constructor(
@ -118,7 +120,10 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.itemId = params['id'];
const dmpId = params['dmpId'];
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) {
this.isNew = false;
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.
this.loadDatasetProfiles();
});
} else if (publicId != null) {
this.datasetWizardService.getSinglePublic(publicId)
} else if (this.publicId != null) {
this.datasetWizardService.getSinglePublic(this.publicId)
.pipe(takeUntil(this._destroyed))
.catch((error: any) => {
this.uiNotificationService.snackBarNotification(error.error.message, SnackBarNotificationLevel.Error);
@ -399,7 +404,9 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
}
downloadPDF(): void {
this.datasetWizardService.downloadPDF(this.itemId)
this.datasetWizardService.downloadPDF(this.downloadDocumentId)
.pipe(takeUntil(this._destroyed))
.subscribe(response => {
const blob = new Blob([response.body], { type: 'application/pdf' });
@ -410,7 +417,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
}
downloadDOCX(): void {
this.datasetWizardService.downloadDOCX(this.itemId)
this.datasetWizardService.downloadDOCX(this.downloadDocumentId)
.pipe(takeUntil(this._destroyed))
.subscribe(response => {
const blob = new Blob([response.body], { type: 'application/msword' });
@ -422,7 +429,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
}
downloadXML(): void {
this.datasetWizardService.downloadXML(this.itemId)
this.datasetWizardService.downloadXML(this.downloadDocumentId)
.pipe(takeUntil(this._destroyed))
.subscribe(response => {
const blob = new Blob([response.body], { type: 'application/xml' });

View File

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