Skip to content

Commit

Permalink
Merged in DSC-1488_fix_version_mantainance (pull request DSpace#1566)
Browse files Browse the repository at this point in the history
DSC-1488

Approved-by: Vincenzo Mecca
Approved-by: Giuseppe Digilio
  • Loading branch information
Mattia Vianelli authored and atarix83 committed Jan 22, 2024
2 parents 733343c + 522b661 commit 342107a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,13 @@ private boolean isMetadataFieldPresent(DSpaceObject item, MetadataField metadata
}

private boolean isBitstreamPresent(Context context, Item item, CrisLayoutFieldBitstream field) {
Map<String, String> filters = Map.of(field.getMetadataField().toString('.'), field.getMetadataValue());

Map<String, String> filters = Map.of();

if (field.getMetadataField() != null) {
filters = Map.of(field.getMetadataField().toString('.'), field.getMetadataValue());
}

try {
return bitstreamService.findShowableByItem(context, item.getID(), field.getBundle(), filters).size() > 0;
} catch (SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,31 @@ public void testIiifBoxHasNoContentWithMetadataUndefined() {
assertFalse(crisLayoutBoxService.hasContent(context, box, item));
}

@Test
public void testSingleMetadataboxBitstreamWithoutField() throws SQLException {

CrisLayoutBox singleBitstreamBox = new CrisLayoutBox();
singleBitstreamBox.setShortname("File");
singleBitstreamBox.setType(null);

Item item = item();
Bitstream bitstream = mock(Bitstream.class);

CrisLayoutFieldBitstream fieldBitstream = new CrisLayoutFieldBitstream();
fieldBitstream.setBundle("ORIGINAL");
fieldBitstream.setMetadataValue(null);
fieldBitstream.setMetadataField(null);
fieldBitstream.setRendering("attachment");

singleBitstreamBox.addLayoutField(fieldBitstream);

when(bitstreamService.findShowableByItem(context, item.getID(), "ORIGINAL", Map.of()))
.thenReturn(List.of(bitstream));

assertThat(crisLayoutBoxService.hasContent(context, singleBitstreamBox, item), is(true));

}

private CrisLayoutBox crisLayoutMetadataBox(String shortname, MetadataField... metadataFields) {
return crisLayoutBox(shortname, CrisLayoutBoxTypes.METADATA.name(), metadataFields);
}
Expand Down

0 comments on commit 342107a

Please sign in to comment.