Skip to content

Commit

Permalink
correlation context panel -> loadable detachable model instead of rea…
Browse files Browse the repository at this point in the history
…donly model to prevent repetitive loading of objects.
  • Loading branch information
katkav committed Oct 14, 2022
1 parent b90c203 commit 8de34a7
Showing 1 changed file with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.StringResourceModel;

Expand Down Expand Up @@ -231,25 +232,28 @@ private boolean isPanelForItemWork() {
}

private IModel<CorrelationContextDto> createCorrelationContextModel() {
return new ReadOnlyModel<>(() -> {
CaseType aCase = getObjectDetailsModels().getObjectType();
CaseCorrelationContextType correlationContext = aCase.getCorrelationContext();
if (correlationContext == null || CorrelationCaseUtil.getOwnerOptions(aCase) == null) {
return null;
}
return new LoadableDetachableModel<>() {
@Override
protected CorrelationContextDto load() {
CaseType aCase = getObjectDetailsModels().getObjectType();
CaseCorrelationContextType correlationContext = aCase.getCorrelationContext();
if (correlationContext == null || CorrelationCaseUtil.getOwnerOptions(aCase) == null) {
return null;
}

Task task = getPageBase().createSimpleTask(OP_LOAD);
OperationResult result = task.getResult();
try {
return new CorrelationContextDto(aCase, getPageBase(), task, result);
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load correlation context for {}", t, aCase);
return null;
} finally {
result.computeStatusIfUnknown();
getPageBase().showResult(result, false);
Task task = getPageBase().createSimpleTask(OP_LOAD);
OperationResult result = task.getResult();
try {
return new CorrelationContextDto(aCase, getPageBase(), task, result);
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load correlation context for {}", t, aCase);
return null;
} finally {
result.computeStatusIfUnknown();
getPageBase().showResult(result, false);
}
}
});
};
}

private ListView<CorrelationOptionDto> createColumnsForPropertyRow(
Expand Down

0 comments on commit 8de34a7

Please sign in to comment.