Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring

This commit is contained in:
Diamantis Tziotzios 2019-04-02 11:43:24 +03:00
commit 3416bc931e
5 changed files with 21 additions and 9 deletions

View File

@ -16,6 +16,7 @@ import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.services.operations.DatabaseRepository; import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
import eu.eudat.logic.utilities.documents.word.WordBuilder; import eu.eudat.logic.utilities.documents.word.WordBuilder;
import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder; import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder;
import eu.eudat.models.HintedModelFactory; import eu.eudat.models.HintedModelFactory;
@ -39,6 +40,7 @@ import org.springframework.web.client.RestTemplate;
import javax.activation.MimetypesFileTypeMap; import javax.activation.MimetypesFileTypeMap;
import java.io.*; import java.io.*;
import java.math.BigInteger;
import java.net.URL; import java.net.URL;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -194,6 +196,7 @@ public class DatasetManager {
InputStream is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream(); InputStream is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
XWPFDocument document = new XWPFDocument(is); XWPFDocument document = new XWPFDocument(is);
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class)); eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
wordBuilder.addParagraphContent(datasetEntity.getLabel(), document, ParagraphStyle.TITLE, BigInteger.ZERO);
Map<String, Object> properties = new HashMap<>(); Map<String, Object> properties = new HashMap<>();
if (datasetEntity.getProperties() != null) { if (datasetEntity.getProperties() != null) {
JSONObject jobject = new JSONObject(datasetEntity.getProperties()); JSONObject jobject = new JSONObject(datasetEntity.getProperties());
@ -203,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()