Skip to content

Commit

Permalink
add child records count to number of links in tab title. Refs #330
Browse files Browse the repository at this point in the history
  • Loading branch information
twagoo committed Jan 27, 2022
1 parent 92a6973 commit 5892e29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ public Integer getObject() {
final FieldNameService fieldNameService = VloWicketApplication.get().getFieldNameService();

final SolrDocument document = documentModel.getObject();
final Object partCount = document.getFieldValue(fieldNameService.getFieldName(FieldKey.HAS_PART_COUNT));
if (partCount instanceof Integer) {
return (Integer) partCount;
} else {
return 0;
if (document != null) {
final Object partCount = document.getFieldValue(fieldNameService.getFieldName(FieldKey.HAS_PART_COUNT));
if (partCount instanceof Integer) {
return (Integer) partCount;
}
}
return 0;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import eu.clarin.cmdi.vlo.wicket.model.NullFallbackModel;
import eu.clarin.cmdi.vlo.wicket.model.PermaLinkModel;
import eu.clarin.cmdi.vlo.wicket.model.RecordHasHierarchyModel;
import eu.clarin.cmdi.vlo.wicket.model.RecordMetadataLinksCountModel;
import eu.clarin.cmdi.vlo.wicket.model.SearchContextModel;
import eu.clarin.cmdi.vlo.wicket.model.SolrDocumentModel;
import eu.clarin.cmdi.vlo.wicket.model.SolrFieldStringModel;
Expand Down Expand Up @@ -203,14 +204,15 @@ public RecordPage(PageParameters params) {
add(new RecordStructuredMeatadataHeaderBehavior(documentModel));
}

final IModel<Integer> childRecordsCountModel = new RecordMetadataLinksCountModel(getModel());
linksCountLabelModel = new LoadableDetachableModel<String>() {
@Override
protected String load() {
final SolrDocument document = RecordPage.this.getModelObject();
if (document != null) {
final Object countValue = document.getFieldValue(fieldNameService.getFieldName(FieldKey.RESOURCE_COUNT));
if (countValue instanceof Integer) {
Long fieldValuesCount
final Long fieldValuesCount
= Streams.concat(
// landing page links
Optional.ofNullable(document.getFieldValues(fieldNameService.getFieldName(FieldKey.LANDINGPAGE))).map(f -> f.stream()).orElse(Stream.empty()),
Expand All @@ -220,7 +222,9 @@ protected String load() {
showFcsLinks
? Optional.ofNullable(document.getFieldValues(fieldNameService.getFieldName(FieldKey.SEARCH_SERVICE))).map(f -> f.stream()).orElse(Stream.empty())
: Stream.empty())
.collect(Collectors.counting());
.collect(Collectors.counting())
// add child records
+ childRecordsCountModel.getObject();
if (fieldValuesCount == 0) {
return ((Integer) countValue).toString();
} else {
Expand Down

0 comments on commit 5892e29

Please sign in to comment.