Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring
This commit is contained in:
commit
3416bc931e
|
@ -16,6 +16,7 @@ import eu.eudat.logic.services.ApiContext;
|
|||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
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.xml.ExportXmlBuilder;
|
||||
import eu.eudat.models.HintedModelFactory;
|
||||
|
@ -39,6 +40,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
import javax.activation.MimetypesFileTypeMap;
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
@ -194,6 +196,7 @@ public class DatasetManager {
|
|||
InputStream is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
|
||||
XWPFDocument document = new XWPFDocument(is);
|
||||
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<>();
|
||||
if (datasetEntity.getProperties() != null) {
|
||||
JSONObject jobject = new JSONObject(datasetEntity.getProperties());
|
||||
|
@ -203,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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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' });
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue