Skip to content

Commit

Permalink
MID-9582: fix refresh of search panel for resource objects table
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik authored and tonydamage committed Apr 30, 2024
1 parent 7f70bb3 commit 4065ee1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ protected VisibleEnableBehaviour getTitleVisibleBehaviour() {
}

private void createObjectTypeChoice() {
QName defaultObjectClass = getDefaultObjectClass();
resetSearch(defaultObjectClass);

boolean templateCategory = WebComponentUtil.isTemplateCategory(getObjectWrapperObject().asObjectable());

var objectTypes = new DropDownChoicePanel<>(ID_OBJECT_TYPE,
Model.of(getDefaultObjectClass()),
Model.of(defaultObjectClass),
() -> {
List<QName> resourceObjectClassesDefinitions = getObjectDetailsModels().getResourceObjectClassesDefinitions();
return Objects.requireNonNullElseGet(resourceObjectClassesDefinitions, ArrayList::new);
Expand All @@ -103,14 +106,37 @@ private void createObjectTypeChoice() {
objectTypes.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(getShadowTable());
resetSearch(getSelectedObjectClass());
getShadowTable().refreshTable(target);
}
});
objectTypes.setOutputMarkupId(true);
add(objectTypes);
}

private void resetSearch(QName currentObjectClass) {
ResourceContentStorage storage = getPageBase().getSessionStorage().getResourceContentStorage(null);

QName storedObjectClass = storage.getContentSearch().getObjectClass();
String storedResourceOid = storage.getContentSearch().getResourceOid();
String wrapperResourceOid = getObjectWrapper().getOid();
if (storedObjectClass == null
|| !QNameUtil.match(currentObjectClass, storedObjectClass)
|| StringUtils.isEmpty(wrapperResourceOid)
|| !wrapperResourceOid.equals(storedResourceOid)) {
storage.setSearch(null);
storage.getContentSearch().setResourceOid(wrapperResourceOid);
storage.getContentSearch().setObjectClass(currentObjectClass);
}
}

protected QName getDefaultObjectClass() {
ResourceContentStorage storage = getPageBase().getSessionStorage().getResourceContentStorage(null);
if (getObjectWrapper().getOid() != null
&& getObjectWrapper().getOid().equals(storage.getContentSearch().getResourceOid())
&& storage.getContentSearch().getObjectClass() != null) {
return storage.getContentSearch().getObjectClass();
}
return getObjectDetailsModels().getDefaultObjectClass();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class ResourceContentSearchDto implements Serializable, DebugDumpable {
private ShadowKindType kind;
private String intent;
private QName objectClass;
private String resourceOid;

private boolean isUseObjectClass = false;

Expand Down Expand Up @@ -58,6 +59,14 @@ public void setObjectClass(QName objectClass) {
this.objectClass = objectClass;
}

public String getResourceOid() {
return resourceOid;
}

public void setResourceOid(String resourceOid) {
this.resourceOid = resourceOid;
}

public boolean isUseObjectClass() {
return isUseObjectClass;
}
Expand All @@ -77,6 +86,7 @@ public String debugDump(int indent) {
DebugUtil.debugDumpWithLabelLn(sb, "intent", intent, indent+1);
DebugUtil.debugDumpWithLabelLn(sb, "objectClass", objectClass, indent+1);
DebugUtil.debugDumpWithLabel(sb, "isUseObjectClass", isUseObjectClass, indent+1);
DebugUtil.debugDumpWithLabel(sb, "resourceOid", resourceOid, indent+1);
return sb.toString();
}

Expand Down

0 comments on commit 4065ee1

Please sign in to comment.