Skip to content

Commit

Permalink
Fix asset extraction exporting (#4083)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
kbirk and github-actions[bot] authored Jul 9, 2024
1 parent 8a89705 commit 91d1f92
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public abstract class TerariumAsset extends TerariumEntity {
@JsonAlias("file_names")
@Type(JsonType.class)
@Column(columnDefinition = "json")
private List<String> fileNames = new ArrayList<>();
protected List<String> fileNames = new ArrayList<>();

@TSOptional
@Schema(accessMode = Schema.AccessMode.READ_ONLY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ public class DocumentAsset extends TerariumAsset {
@Column(columnDefinition = "json")
private List<DocumentExtraction> assets;

@Override
public List<String> getFileNames() {
final List<String> res = new ArrayList<>();
if (this.fileNames != null) {
for (final String fileName : fileNames) {
if (!res.contains(fileName)) {
res.add(fileName);
}
}
}
// ensure these are included in filenames
if (this.assets != null) {
for (final DocumentExtraction asset : assets) {
if (!res.contains(asset.getFileName())) {
res.add(asset.getFileName());
}
}
}
return res;
}

/**
* Get the DOI of a document
*
Expand Down Expand Up @@ -115,11 +136,6 @@ public DocumentAsset clone() {
clone.assets = new ArrayList<>();
for (final DocumentExtraction asset : this.assets) {
clone.assets.add(asset.clone());

// ensure the asset filename is added
if (!clone.getFileNames().contains(asset.getFileName())) {
clone.getFileNames().add(asset.getFileName());
}
}
}

Expand Down

0 comments on commit 91d1f92

Please sign in to comment.