Skip to content

Commit

Permalink
adding new construction association fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Mar 6, 2024
1 parent 5b3337e commit 414df92
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected void performSelectedObjects() {
selectedItems.getObject().forEach(item -> {
try {

PrismContainerValueWrapper<ResourceObjectAssociationType> valueWrapper;
PrismContainerValueWrapper<ResourceObjectAssociationType> valueWrapper = null;

Optional<PrismContainerValueWrapper<ResourceObjectAssociationType>> match = associationContainer.getValues().stream().filter(
value -> {
Expand All @@ -224,9 +224,21 @@ protected void performSelectedObjects() {
}
return item.associationName.equivalent(value.getRealValue().getRef().getItemPath());
}).findFirst();

boolean createNewAssociationValue = false;

if (match.isPresent()) {
valueWrapper = match.get();

PrismPropertyWrapper<ExpressionType> expression = valueWrapper.findProperty(
ItemPath.create(ResourceObjectAssociationType.F_OUTBOUND, MappingType.F_EXPRESSION));
if (ExpressionUtil.containsAssociationFromLinkElement(expression.getValue().getRealValue())) {
createNewAssociationValue = true;
}
} else {
createNewAssociationValue = true;
}
if (createNewAssociationValue) {

PrismContainerValue<ResourceObjectAssociationType> newValue = associationContainer.getItem().createNewValue();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public static JAXBElement<?> findFirstEvaluatorByName(ExpressionType expression,
return elements;
}
for (JAXBElement<?> element : expression.getExpressionEvaluator()) {
if (element != null && element.getName().equals(elementName)) {
if (element != null && QNameUtil.match(element.getName(), elementName)) {
elements.add(element);
}
}
Expand Down Expand Up @@ -350,6 +350,17 @@ public static void removeShadowRefEvaluatorValue(ExpressionType expression, Stri
expression.getExpressionEvaluator().addAll(elementList);
}

public static boolean containsAssociationFromLinkElement(ExpressionType expression) {
if (expression == null) {
return false;
}
List<JAXBElement<?>> elementList = findAllEvaluatorsByName(expression, SchemaConstantsGenerated.C_ASSOCIATION_FROM_LINK);
if (CollectionUtils.isEmpty(elementList)) {
return false;
}
return true;
}

private static String getShadowRefNodeOid(MapXNode shadowRefNode) {
if (shadowRefNode != null && shadowRefNode.containsKey(SHADOW_OID_KEY)) {
PrimitiveXNode shadowOidNode = (PrimitiveXNode) shadowRefNode.get(SHADOW_OID_KEY);
Expand Down

0 comments on commit 414df92

Please sign in to comment.