Skip to content

Commit

Permalink
Document API usage of XtfFileMerger (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
domi-b authored Apr 15, 2024
2 parents 71b948b + 6c86c00 commit 04ed8cf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,23 @@ Beispiel `FailCase.xtf` (INTERLIS 2.4):
</ili:datasection>
</ili:transfer>
```

## API
Einige Funktionalitäten des Runners können auch über das Java API verwendet werden, beispielsweise zur direkten Integration in einem Unit-Test.

### Zusammenfügen von XTF-Dateien
Das Zusammenfügen der Fail-Cases mit den Basisdaten kann mit der Klasse `XtfFileMerger` durchgeführt werden.
Die Methode `merge` erwartet die Pfade zu den Basisdaten, den Anpassungen des Fail-Cases und der Ausgabedatei.
Die XTF-Datei des Fail-Cases ist dabei gleich aufgebaut wie bei der automatischen Ordner-basierten Ausführung des Runners.

Beispiel:
```java
import ch.geowerkstatt.interlis.testbed.runner.xtf.XtfFileMerger;

//...

void example() {
XtfFileMerger xtfMerger = new XtfFileMerger();
xtfMerger.merge(Path.of("path", "to", "base.xtf"), Path.of("path", "to", "failcase.xtf"), Path.of("path", "to", "output.xtf"));
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
* Defines a class that can be used to merge INTERLIS XTF files.
* <p>
* Supports XTF files using a single namespace for INTERLIS up to version 2.3
* as well as files for INTERLIS version 2.4 using multiple namespaces.
*/
public final class XtfFileMerger implements XtfMerger {
private static final Logger LOGGER = LogManager.getLogger();
private static final String BASKET_ID = "BID";
Expand All @@ -38,6 +44,14 @@ public XtfFileMerger() {
factory.setNamespaceAware(true);
}

/**
* {@inheritDoc}
* <p>
* The base file is expected to be a valid INTERLIS XTF file to which the patch data can be applied to.
* The patch file is expected to include a data section containing the elements to add, replace or delete.
* Object elements are identified by the id of their basket and the object id using the BID and TID attributes.
* The resulting data will be written to the output file.
*/
@Override
public boolean merge(Path baseFile, Path patchFile, Path outputFile) {
try {
Expand Down

0 comments on commit 04ed8cf

Please sign in to comment.