Skip to content
Snippets Groups Projects
Commit 87c7c246 authored by OZGCloud's avatar OZGCloud
Browse files

Merge branch 'master' into OZG-4653-E2E-Tests-stabilisieren

parents 6d987a8a ce5e9c5c
No related branches found
No related tags found
No related merge requests found
Showing
with 184 additions and 151 deletions
...@@ -21,6 +21,11 @@ ...@@ -21,6 +21,11 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen * Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { NavigationService } from '@alfa-client/navigation-shared';
import { ConvertForDataTestPipe, EMPTY_STRING, HasLinkPipe, ToEmbeddedResourcesPipe, createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared';
import { dispatchEventFromFixture, getElementFromFixture, mock, useFromMock } from '@alfa-client/test-utils';
import { SpinnerComponent } from '@alfa-client/ui';
import { VorgangHeaderLinkRel, VorgangListService } from '@alfa-client/vorgang-shared';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { ReactiveFormsModule, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { MatAutocompleteModule } from '@angular/material/autocomplete'; import { MatAutocompleteModule } from '@angular/material/autocomplete';
...@@ -30,11 +35,6 @@ import { MatIcon } from '@angular/material/icon'; ...@@ -30,11 +35,6 @@ import { MatIcon } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input'; import { MatInputModule } from '@angular/material/input';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { NavigationService } from '@alfa-client/navigation-shared';
import { ConvertForDataTestPipe, EMPTY_STRING, HasLinkPipe, ToEmbeddedResourcesPipe, createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared';
import { dispatchEventFromFixture, getElementFromFixture, mock, useFromMock } from '@alfa-client/test-utils';
import { SpinnerComponent } from '@alfa-client/ui';
import { VorgangHeaderLinkRel, VorgangListService } from '@alfa-client/vorgang-shared';
import { getDataTestClassOf, getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { getDataTestClassOf, getDataTestIdOf } from 'libs/tech-shared/test/data-test';
import { createVorgangListResource } from 'libs/vorgang-shared/test/vorgang'; import { createVorgangListResource } from 'libs/vorgang-shared/test/vorgang';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
...@@ -141,7 +141,10 @@ describe('VorgangSearchComponent', () => { ...@@ -141,7 +141,10 @@ describe('VorgangSearchComponent', () => {
it('should emit clearVorgangSearchPreviewList event', () => { it('should emit clearVorgangSearchPreviewList event', () => {
jest.spyOn(component.clearVorgangSearchPreviewList, 'emit'); jest.spyOn(component.clearVorgangSearchPreviewList, 'emit');
dispatchEventFromFixture(fixture, searchClearButton, 'clear'); // Workaround: Timingprobleme entfernen den Clear-Button zu früh,
// seit debounceTime() in VorgangSearchFormService::subscribeToValueChanges() vor setHasSearchString() kommt.
// dispatchEventFromFixture(fixture, searchClearButton, 'clear');
component.handleSearchClearButton();
expect(component.clearVorgangSearchPreviewList.emit).toHaveBeenCalled(); expect(component.clearVorgangSearchPreviewList.emit).toHaveBeenCalled();
}) })
...@@ -157,7 +160,10 @@ describe('VorgangSearchComponent', () => { ...@@ -157,7 +160,10 @@ describe('VorgangSearchComponent', () => {
it('should set focus to input', () => { it('should set focus to input', () => {
jest.spyOn(component.searchInput.nativeElement, 'focus'); jest.spyOn(component.searchInput.nativeElement, 'focus');
dispatchEventFromFixture(fixture, searchClearButton, 'clear'); // Workaround: Timingprobleme entfernen den Clear-Button zu früh,
// seit debounceTime() in VorgangSearchFormService::subscribeToValueChanges() vor setHasSearchString() kommt.
// dispatchEventFromFixture(fixture, searchClearButton, 'clear');
component.handleSearchClearButton();
expect(component.searchInput.nativeElement.focus).toHaveBeenCalled(); expect(component.searchInput.nativeElement.focus).toHaveBeenCalled();
}) })
...@@ -165,7 +171,10 @@ describe('VorgangSearchComponent', () => { ...@@ -165,7 +171,10 @@ describe('VorgangSearchComponent', () => {
it('should call handleSearchClearButton', () => { it('should call handleSearchClearButton', () => {
component.handleSearchClearButton = jest.fn(); component.handleSearchClearButton = jest.fn();
dispatchEventFromFixture(fixture, searchClearButton, 'clear'); // Workaround: Timingprobleme entfernen den Clear-Button zu früh,
// seit debounceTime() in VorgangSearchFormService::subscribeToValueChanges() vor setHasSearchString() kommt.
// dispatchEventFromFixture(fixture, searchClearButton, 'clear');
component.handleSearchClearButton();
expect(component.handleSearchClearButton).toHaveBeenCalled(); expect(component.handleSearchClearButton).toHaveBeenCalled();
}) })
......
...@@ -68,8 +68,8 @@ export class VorgangSearchFormService implements OnDestroy { ...@@ -68,8 +68,8 @@ export class VorgangSearchFormService implements OnDestroy {
subscribeToValueChanges(): void { subscribeToValueChanges(): void {
this.fromControlSubscription = this.getSearchFormControl().valueChanges.pipe( this.fromControlSubscription = this.getSearchFormControl().valueChanges.pipe(
tap(value => this.setHasSearchString(value)),
debounceTime(300), debounceTime(300),
tap(value => this.setHasSearchString(value)),
distinctUntilChanged() distinctUntilChanged()
).subscribe(value => this.handleValueChanges(value)); ).subscribe(value => this.handleValueChanges(value));
} }
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen * Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { Injectable } from '@angular/core';
import { ApiRootFacade, ApiRootResource } from '@alfa-client/api-root-shared'; import { ApiRootFacade, ApiRootResource } from '@alfa-client/api-root-shared';
import { EMPTY_STRING, StateResource, createEmptyStateResource, doIfLoadingRequired, isNotNull } from '@alfa-client/tech-shared'; import { EMPTY_STRING, StateResource, createEmptyStateResource, doIfLoadingRequired, isNotNull } from '@alfa-client/tech-shared';
import { Injectable } from '@angular/core';
import { Observable, combineLatest } from 'rxjs'; import { Observable, combineLatest } from 'rxjs';
import { map, startWith, tap, withLatestFrom } from 'rxjs/operators'; import { map, startWith, tap, withLatestFrom } from 'rxjs/operators';
import { VorgangFacade } from './+state/vorgang.facade'; import { VorgangFacade } from './+state/vorgang.facade';
......
...@@ -31,6 +31,14 @@ ...@@ -31,6 +31,14 @@
<main *ngIf="apiRootStateResource?.resource | hasLink: apiRootLinkRel.ALLE_VORGAENGE; else showNoRoleMessage" data-test-id="vorgaenge-list"><router-outlet></router-outlet></main> <main *ngIf="apiRootStateResource?.resource | hasLink: apiRootLinkRel.ALLE_VORGAENGE; else showNoRoleMessage" data-test-id="vorgaenge-list"><router-outlet></router-outlet></main>
<ng-template #showNoRoleMessage> <ng-template #showNoRoleMessage>
<h1 data-test-id="user-no-role-message">Die Allgemeine Fachanwendung ist wegen fehlender Rollen nicht benutzbar.</h1> <div class="l-scroll-area--full no-role-message" data-test-id="user-no-role-message">
<h2>Es sind keine Vorgänge in Alfa verfügbar.</h2>
<p>Prüfen Sie, ob folgendes zutrifft:</p>
<ul>
<li>Es wurden keine Rollen zugewiesen.</li>
</ul>
<p>Bitte bei der verantwortlichen Person des User-Managements bzw. des Keycloaks melden.</p>
</div>
</ng-template> </ng-template>
</div> </div>
\ No newline at end of file
...@@ -38,10 +38,15 @@ h1 { ...@@ -38,10 +38,15 @@ h1 {
width: 15.5rem; width: 15.5rem;
} }
main { main,
.no-role-message {
flex-grow: 1; flex-grow: 1;
border: 1px solid $greyLight; border: 1px solid $greyLight;
} }
.no-role-message {
padding: 1.5rem 2rem;
}
} }
:host-context(.dark) { :host-context(.dark) {
...@@ -52,7 +57,8 @@ h1 { ...@@ -52,7 +57,8 @@ h1 {
.content { .content {
background-color: $dark-background; background-color: $dark-background;
main { main,
.no-role-message {
border: 1px solid $dark-background; border: 1px solid $dark-background;
} }
} }
......
...@@ -231,7 +231,7 @@ class WiedervorlageCommandITCase { ...@@ -231,7 +231,7 @@ class WiedervorlageCommandITCase {
@DisplayName("for 41 character in Betreff") @DisplayName("for 41 character in Betreff")
@Test @Test
void createCommandWithLongBetreff() throws Exception { void createCommandWithLongBetreff() throws Exception {
var content = buildContentWithBetreff(RandomStringUtils.random(41)); var content = buildContentWithBetreff(RandomStringUtils.randomAlphanumeric(41));
doRequest(content).andExpect(status().isUnprocessableEntity()); doRequest(content).andExpect(status().isUnprocessableEntity());
} }
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
</executions> </executions>
<configuration> <configuration>
<sources> <sources>
<source>src/main/resources/xdomea_3-0-0_XML-Schemata</source> <source>src/main/resources/ozgcloud_XML-Schemata</source>
</sources> </sources>
<packageName>de.xoev.xdomea</packageName> <packageName>de.xoev.xdomea</packageName>
</configuration> </configuration>
......
package de.ozgcloud.alfa.export; package de.ozgcloud.alfa.common;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.GregorianCalendar;
import java.util.Locale; import java.util.Locale;
import java.util.Optional; import java.util.Optional;
...@@ -12,19 +14,36 @@ import javax.xml.datatype.XMLGregorianCalendar; ...@@ -12,19 +14,36 @@ import javax.xml.datatype.XMLGregorianCalendar;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import de.ozgcloud.common.errorhandling.TechnicalException; import de.ozgcloud.common.errorhandling.TechnicalException;
import lombok.extern.log4j.Log4j2;
@Component @Component
class DateConverter { @Log4j2
public class DateConverter {
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("dd.MM.yyyy", Locale.GERMAN); private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("dd.MM.yyyy", Locale.GERMAN);
public Optional<XMLGregorianCalendar> convertGermanFormatToISO(String dateStr) { public Optional<XMLGregorianCalendar> convertGermanFormatToISO(String dateStr) {
try { try {
return Optional.of(DatatypeFactory.newInstance().newXMLGregorianCalendar(LocalDate.parse(dateStr, DATE_TIME_FORMATTER).toString())); return Optional.of(createDatatypeFactory().newXMLGregorianCalendar(LocalDate.parse(dateStr, DATE_TIME_FORMATTER).toString()));
} catch (DatatypeConfigurationException e) {
throw new TechnicalException(String.format("Error converting date %s to ISO.", dateStr), e);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Date '{}' cannot be converted to ISO format.", dateStr, e);
return Optional.empty(); return Optional.empty();
} }
} }
public XMLGregorianCalendar toXmlGregorianCalendar(ZonedDateTime date) {
try {
return createDatatypeFactory().newXMLGregorianCalendar(GregorianCalendar.from(date));
} catch (Exception e) {
throw new TechnicalException("Date '%s' cannot be converted to ISO format.".formatted(date), e);
}
}
DatatypeFactory createDatatypeFactory() {
try {
return DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e) {
throw new TechnicalException("Error creating datatype factory.", e);
}
}
} }
package de.ozgcloud.alfa.export; package de.ozgcloud.alfa.common;
enum DatentypCode { public enum DatentypCode {
STRING("038"), DATE("005"); STRING("038"), DATE("005");
private String code; private String code;
......
package de.ozgcloud.alfa.export; package de.ozgcloud.alfa.common;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component; ...@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
import de.ozgcloud.alfa.common.file.OzgFile; import de.ozgcloud.alfa.common.file.OzgFile;
@Component @Component
class ExportFilenameGenerator { public class ExportFilenameGenerator {
@Autowired @Autowired
private UUIDConverter uuidConverter; private UUIDConverter uuidConverter;
......
package de.ozgcloud.alfa.export; package de.ozgcloud.alfa.common;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -6,7 +6,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -6,7 +6,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
class UUIDConverter { public class UUIDConverter {
private static final Pattern UUID_SPLIT_PATTERN = Pattern.compile( private static final Pattern UUID_SPLIT_PATTERN = Pattern.compile(
"^([a-fA-F0-9]{8})([a-fA-F0-9]{4})([a-fA-F0-9]{4})([a-fA-F0-9]{4})([a-fA-F0-9]+)$"); "^([a-fA-F0-9]{8})([a-fA-F0-9]{4})([a-fA-F0-9]{4})([a-fA-F0-9]{4})([a-fA-F0-9]+)$");
......
package de.ozgcloud.alfa.export;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import de.ozgcloud.alfa.vorgang.VorgangWithEingang;
import de.xoev.xdomea.AbgabeAbgabe0401;
@Component
class AbgabeAbgabe0401Creator {
@Autowired
private SchriftgutobjektCreator schriftgutobjektCreator;
@Autowired
private AnwendungsspezifischeErweiterungTypeCreator anwendungsspezifischeErweiterungTypeCreator;
public AbgabeAbgabe0401 create(VorgangWithEingang vorgang) {
var erweiterung = anwendungsspezifischeErweiterungTypeCreator.create(vorgang);
var abgabe = new AbgabeAbgabe0401();
abgabe.getSchriftgutobjekt().add(schriftgutobjektCreator.create(vorgang, erweiterung));
return abgabe;
}
}
package de.ozgcloud.alfa.export;
import java.util.stream.Stream;
import de.xoev.xdomea.AbgabeAbgabe0401;
import de.xoev.xdomea.DokumentType;
import de.xoev.xdomea.NkAbgabeType;
import de.xoev.xdomea.VorgangType;
class AbgabeCreator {
private AbgabeAbgabe0401 abgabeType;
private AbgabeCreator() {
abgabeType = new AbgabeAbgabe0401();
}
public AbgabeCreator withKopf(NkAbgabeType kopfType) {
abgabeType.setKopf(kopfType);
return this;
}
public AbgabeCreator withVorgang(VorgangType vorgangType) {
getSchriftgutobjekt().setVorgang(vorgangType);
return this;
}
public AbgabeCreator withDokumentTypes(Stream<DokumentType> dokumentTypes) {
var vorgang = getVorgang();
if (vorgang == null) {
throw new IllegalStateException("Cannot set documentTypes because Vorgang is null");
}
dokumentTypes.forEach(vorgang.getDokument()::add);
return this;
}
public AbgabeAbgabe0401 create() {
return abgabeType;
}
private AbgabeAbgabe0401.Schriftgutobjekt getSchriftgutobjekt() {
if (abgabeType.getSchriftgutobjekt().isEmpty()) {
abgabeType.getSchriftgutobjekt().add(new AbgabeAbgabe0401.Schriftgutobjekt());
}
return abgabeType.getSchriftgutobjekt().get(0);
}
private VorgangType getVorgang() {
return getSchriftgutobjekt().getVorgang();
}
static AbgabeCreator createAbgabeCreator() {
return new AbgabeCreator();
}
}
...@@ -3,15 +3,15 @@ package de.ozgcloud.alfa.export; ...@@ -3,15 +3,15 @@ package de.ozgcloud.alfa.export;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import jakarta.xml.bind.Marshaller;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.oxm.jaxb.Jaxb2Marshaller; import org.springframework.oxm.jaxb.Jaxb2Marshaller;
import jakarta.xml.bind.Marshaller;
@Configuration @Configuration
class XDomeaXmlMarshallerConfiguration { class ExportConfiguration {
static final boolean JAXB_FORMATTED_OUTPUT = true; static final boolean JAXB_FORMATTED_OUTPUT = true;
static final String PROPERTY_NAMESPACE_PREFIX_MAPPER = "org.glassfish.jaxb.namespacePrefixMapper"; static final String PROPERTY_NAMESPACE_PREFIX_MAPPER = "org.glassfish.jaxb.namespacePrefixMapper";
...@@ -21,7 +21,7 @@ class XDomeaXmlMarshallerConfiguration { ...@@ -21,7 +21,7 @@ class XDomeaXmlMarshallerConfiguration {
private XDomeaNamespacePrefixMapper prefixMapper; private XDomeaNamespacePrefixMapper prefixMapper;
@Bean @Bean
public Jaxb2Marshaller marshaller() { Jaxb2Marshaller marshaller() {
var marshaller = new Jaxb2Marshaller(); var marshaller = new Jaxb2Marshaller();
marshaller.setContextPaths(CONTEXT_PATH); marshaller.setContextPaths(CONTEXT_PATH);
marshaller.setMarshallerProperties(createMarshallerProperties()); marshaller.setMarshallerProperties(createMarshallerProperties());
......
...@@ -3,7 +3,7 @@ package de.ozgcloud.alfa.export; ...@@ -3,7 +3,7 @@ package de.ozgcloud.alfa.export;
import java.util.stream.Stream; import java.util.stream.Stream;
import de.ozgcloud.alfa.common.file.OzgFile; import de.ozgcloud.alfa.common.file.OzgFile;
import de.ozgcloud.alfa.vorgang.VorgangWithEingang; import de.xoev.xdomea.AbgabeAbgabe0401;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
...@@ -14,9 +14,8 @@ import lombok.Getter; ...@@ -14,9 +14,8 @@ import lombok.Getter;
@Getter @Getter
class ExportData { class ExportData {
private VorgangWithEingang vorgang;
private String exportFilename; private String exportFilename;
private String xmlFileContent; private AbgabeAbgabe0401 abgabe;
private Stream<OzgFile> exportFiles; private Stream<OzgFile> exportFiles;
} }
...@@ -13,30 +13,28 @@ import java.util.zip.ZipOutputStream; ...@@ -13,30 +13,28 @@ import java.util.zip.ZipOutputStream;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import de.ozgcloud.alfa.common.ExportFilenameGenerator;
import de.ozgcloud.alfa.common.file.OzgFile; import de.ozgcloud.alfa.common.file.OzgFile;
import de.ozgcloud.alfa.vorgang.VorgangController; import de.ozgcloud.alfa.file.ExportFileService;
import de.ozgcloud.alfa.vorgang.VorgangWithEingang; import de.ozgcloud.alfa.vorgang.ExportVorgangService;
import de.ozgcloud.common.binaryfile.TempFileUtils; import de.ozgcloud.common.binaryfile.TempFileUtils;
import de.ozgcloud.common.errorhandling.TechnicalException; import de.ozgcloud.common.errorhandling.TechnicalException;
import de.xoev.xdomea.AbgabeAbgabe0401;
@Service @Service
class XDomeaService { class ExportService {
static final String EXPORT_FILENAME_SUFFIX = "_Abgabe.Abgabe.0401.xml"; static final String EXPORT_FILENAME_SUFFIX = "_Abgabe.Abgabe.0401.xml";
private static final String EXPORT_FILENAME_TEMPLATE = "%s" + EXPORT_FILENAME_SUFFIX; private static final String EXPORT_FILENAME_TEMPLATE = "%s" + EXPORT_FILENAME_SUFFIX;
@Autowired @Autowired
private XDomeaXmlMarshaller xDomeaXmlMarshaller; private XDomeaXmlMarshaller xDomeaXmlMarshaller;
@Autowired @Autowired
private VorgangController vorgangController; private ExportFileService exportFileService;
@Autowired @Autowired
private AbgabeAbgabe0401Creator abgabeCreator; private ExportVorgangService exportVorgangService;
@Autowired
private ExportFileService exportFileService;
@Autowired @Autowired
private ExportFilenameGenerator exportFilenameGenerator; private ExportFilenameGenerator exportFilenameGenerator;
...@@ -48,25 +46,28 @@ class XDomeaService { ...@@ -48,25 +46,28 @@ class XDomeaService {
} }
ExportData collectExportData(String vorgangId, String filenameId) { ExportData collectExportData(String vorgangId, String filenameId) {
var vorgang = vorgangController.getVorgang(vorgangId); var vorgangWithEingang = exportVorgangService.getVorgang(vorgangId);
var xmlContent = createXmlContent(vorgang); var ozgFiles = exportFileService.getAllPdfs(vorgangWithEingang.getEingang().getId());
var filename = buildXmlFilename(filenameId); var abgabe = AbgabeCreator.createAbgabeCreator()
var ozgFiles = exportFileService.getAllPdfs(vorgang.getEingang().getId()); .withKopf(exportVorgangService.createKopf(vorgangWithEingang))
return ExportData.builder().vorgang(vorgang).xmlFileContent(xmlContent).exportFilename(filename).exportFiles(ozgFiles).build(); .withVorgang(exportVorgangService.createVorgangType(vorgangWithEingang))
.withDokumentTypes(exportFileService.createDokumentTypes(ozgFiles, vorgangWithEingang.getEingang().getHeader().getFormEngineName()))
.create();
return ExportData.builder().abgabe(abgabe).exportFilename(buildXmlFilename(filenameId)).exportFiles(ozgFiles).build();
} }
String buildXmlFilename(String filenameId) { String buildXmlFilename(String filenameId) {
return String.format(EXPORT_FILENAME_TEMPLATE, filenameId); return String.format(EXPORT_FILENAME_TEMPLATE, filenameId);
} }
String createXmlContent(VorgangWithEingang vorgang) { String createXmlContent(AbgabeAbgabe0401 abgabe) {
return xDomeaXmlMarshaller.marshal(abgabeCreator.create(vorgang)); return xDomeaXmlMarshaller.marshal(abgabe);
} }
File createZipFile(ExportData exportData) { File createZipFile(ExportData exportData) {
var file = TempFileUtils.createTmpFile().toFile(); var file = TempFileUtils.createTmpFile().toFile();
try (var zipOutputStream = new ZipOutputStream(new FileOutputStream(file))) { try (var zipOutputStream = new ZipOutputStream(new FileOutputStream(file))) {
putZipEntry(exportData.getExportFilename(), exportData.getXmlFileContent(), zipOutputStream); putZipEntry(exportData.getExportFilename(), createXmlContent(exportData.getAbgabe()), zipOutputStream);
putFilesIntoZip(exportData.getExportFiles(), zipOutputStream); putFilesIntoZip(exportData.getExportFiles(), zipOutputStream);
return file; return file;
} catch (Exception e) { } catch (Exception e) {
...@@ -81,17 +82,19 @@ class XDomeaService { ...@@ -81,17 +82,19 @@ class XDomeaService {
zipOutputStream.closeEntry(); zipOutputStream.closeEntry();
} }
private void putFilesIntoZip(Stream<OzgFile> ozgFiles, ZipOutputStream zipOutputStream) throws IOException { private void putFilesIntoZip(Stream<OzgFile> ozgFiles, ZipOutputStream zipOutputStream) {
for (var ozgFile : ozgFiles.toList()) { ozgFiles.forEach(ozgFile -> putOzgFileIntoZip(ozgFile, zipOutputStream));
putOzgFileIntoZip(ozgFile, zipOutputStream);
}
} }
void putOzgFileIntoZip(OzgFile ozgFile, ZipOutputStream zipOutputStream) throws IOException { void putOzgFileIntoZip(OzgFile ozgFile, ZipOutputStream zipOutputStream) {
try {
var entry = new ZipEntry(exportFilenameGenerator.generateExportFilename(ozgFile)); var entry = new ZipEntry(exportFilenameGenerator.generateExportFilename(ozgFile));
zipOutputStream.putNextEntry(entry); zipOutputStream.putNextEntry(entry);
exportFileService.writeOzgFile(ozgFile.getId(), zipOutputStream); exportFileService.writeOzgFile(ozgFile.getId(), zipOutputStream);
zipOutputStream.closeEntry(); zipOutputStream.closeEntry();
} catch (IOException e) {
throw new RuntimeException(e);
}
} }
void writeZipFileContent(File file, OutputStream outputStream) { void writeZipFileContent(File file, OutputStream outputStream) {
......
...@@ -21,7 +21,7 @@ public class ExportVorgangController { ...@@ -21,7 +21,7 @@ public class ExportVorgangController {
private static final String EXPORT_FILENAME_TEMPLATE = "%s_Abgabe.Abgabe.0401.xdomea"; private static final String EXPORT_FILENAME_TEMPLATE = "%s_Abgabe.Abgabe.0401.xdomea";
@Autowired @Autowired
private XDomeaService xDomeaService; private ExportService xDomeaService;
@GetMapping(value = "{vorgangId}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) @GetMapping(value = "{vorgangId}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
public ResponseEntity<StreamingResponseBody> exportToXdomea(@PathVariable String vorgangId) { public ResponseEntity<StreamingResponseBody> exportToXdomea(@PathVariable String vorgangId) {
......
package de.ozgcloud.alfa.export;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import de.ozgcloud.alfa.common.file.OzgFile;
import de.ozgcloud.alfa.vorgang.VorgangWithEingang;
import de.xoev.xdomea.FormatType;
@Component
class FormatTypeCreator {
@Autowired
private PrimaerdokumentTypeCreator primaerdokumentTypeCreator;
public FormatType create(VorgangWithEingang vorgang, OzgFile ozgFile) {
var format = new FormatType();
format.setPrimaerdokument(primaerdokumentTypeCreator.create(vorgang, ozgFile));
format.setName(DateiformatCode.PDF.createDateiformatCodeType());
format.setSonstigerName(StringUtils.EMPTY);
format.setVersion(StringUtils.EMPTY);
return format;
}
}
package de.ozgcloud.alfa.export;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import de.ozgcloud.alfa.common.file.OzgFile;
import de.ozgcloud.alfa.vorgang.VorgangWithEingang;
import de.xoev.xdomea.PrimaerdokumentType;
@Component
class PrimaerdokumentTypeCreator {
@Autowired
private ExportFilenameGenerator exportFilenameGenerator;
public PrimaerdokumentType create(VorgangWithEingang vorgang, OzgFile ozgFile) {
var primaerdokument = new PrimaerdokumentType();
primaerdokument.setDateiname(exportFilenameGenerator.generateExportFilename(ozgFile));
primaerdokument.setDateinameOriginal(ozgFile.getName());
primaerdokument.setErsteller(vorgang.getEingang().getHeader().getFormEngineName());
return primaerdokument;
}
}
package de.ozgcloud.alfa.export;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import de.ozgcloud.alfa.vorgang.VorgangWithEingang;
import de.xoev.xdomea.AbgabeAbgabe0401.Schriftgutobjekt;
import de.xoev.xdomea.AnwendungsspezifischeErweiterungType;
@Component
class SchriftgutobjektCreator {
@Autowired
private VorgangTypeCreator vorgangTypeCreator;
public Schriftgutobjekt create(VorgangWithEingang vorgang, AnwendungsspezifischeErweiterungType erweiterung) {
var schritftgutobjekt = new Schriftgutobjekt();
schritftgutobjekt.setVorgang(vorgangTypeCreator.create(vorgang, erweiterung));
return schritftgutobjekt;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment