Skip to content

Commit

Permalink
fix for MID-9066 duplicated action in objectCollectionView
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Sep 19, 2023
1 parent 33bd5d3 commit de33942
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,14 @@ public static String getTargetNameOrOid(ObjectReferenceType ref) {
}
return ref.getOid();
}

public static boolean referencesOidEqual(ObjectReferenceType ref1, ObjectReferenceType ref2) {
if (ref1 == null || ref2 == null) {
return false;
}
if (ref1.getOid() == null || ref2.getOid() == null) {
return false;
}
return ref1.getOid().equals(ref2.getOid());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,17 @@ private void compileObjectType(CompiledObjectCollectionView existingView, GuiObj
private void compileActions(CompiledObjectCollectionView existingView, GuiObjectListViewType objectListViewType) {
List<GuiActionType> newActions = objectListViewType.getAction();
for (GuiActionType newAction : newActions) {
// TODO: check for action duplication/override
existingView.getActions().add(newAction); // No need to clone, CompiledObjectCollectionView is not prism
// TODO: check for action override
if (!alreadyExist(existingView, newAction)) {
existingView.getActions().add(newAction); // No need to clone, CompiledObjectCollectionView is not prism
}
}
}

private boolean alreadyExist(CompiledObjectCollectionView view, GuiActionType action) {
return view.getActions()
.stream()
.anyMatch(a -> ObjectReferenceTypeUtil.referencesOidEqual(a.getTaskTemplateRef(), action.getTaskTemplateRef()));
}

private void compileColumns(CompiledObjectCollectionView existingView, GuiObjectListViewType objectListViewType) {
Expand Down

0 comments on commit de33942

Please sign in to comment.