Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
* 'master' of github.com:Evolveum/midpoint:
  fix of fields for association attributes
  • Loading branch information
katkav committed Oct 3, 2022
2 parents 5024141 + 780aff6 commit 57f833e
Show file tree
Hide file tree
Showing 14 changed files with 543 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public boolean isVisible() {
namespaceModeContainer.add(namespacePanel);

TextPanel<String> itemPathTextField = new TextPanel<String>(ID_ITEM_PATH_TEXT_FIELD, new PropertyModel<>(getModel(), "pathStringValue"));
itemPathTextField.add(new VisibleBehaviour(() -> switchToTextFieldEnabled && ItemPathPanelMode.TEXT_MODE.equals(panelMode)));
itemPathTextField.add(new VisibleBehaviour(() -> isTextFieldVisible()));
itemPathTextField.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
itemPathPanel.add(itemPathTextField);

Expand All @@ -245,6 +245,10 @@ protected String load() {

}

protected boolean isTextFieldVisible() {
return switchToTextFieldEnabled && ItemPathPanelMode.TEXT_MODE.equals(panelMode);
}

private void initItemPathLabel() {
WebMarkupContainer itemPathLabel = new WebMarkupContainer(ID_ITEM_PATH_CONTAINER);
itemPathLabel.setOutputMarkupId(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
*/
package com.evolveum.midpoint.gui.api.util;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.*;

import com.evolveum.midpoint.authentication.api.util.AuthUtil;

import com.evolveum.midpoint.gui.impl.factory.panel.AttributeMappingItemPathPanelFactory;
import com.evolveum.midpoint.schema.processor.*;
import com.evolveum.midpoint.util.DisplayableValue;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;

Expand All @@ -34,6 +38,11 @@
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.security.MidPointApplication;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.xml.namespace.QName;

/**
* @author katka
*/
Expand Down Expand Up @@ -323,4 +332,46 @@ private static boolean hasValueMetadata(PrismValue value) {
}
return false;
}

public static List<ResourceAttributeDefinition> searchAttributeDefinitions(
ResourceSchema schema, ResourceObjectTypeDefinitionType objectType) {
List<ResourceAttributeDefinition> allAttributes = new ArrayList<>();
if (objectType != null) {
@Nullable ResourceObjectTypeDefinition objectTypeDef = null;
if (objectType.getKind() != null && objectType.getIntent() != null) {

@NotNull ResourceObjectTypeIdentification identifier =
ResourceObjectTypeIdentification.of(objectType.getKind(), objectType.getIntent());
objectTypeDef = schema.getObjectTypeDefinition(identifier);

if (objectTypeDef != null) {
objectTypeDef.getAttributeDefinitions()
.forEach(attr -> allAttributes.add(attr));
}
}
if (objectTypeDef == null && objectType.getDelineation() != null && objectType.getDelineation().getObjectClass() != null) {

@NotNull Collection<ResourceObjectClassDefinition> defs = schema.getObjectClassDefinitions();
Optional<ResourceObjectClassDefinition> objectClassDef = defs.stream()
.filter(d -> QNameUtil.match(d.getTypeName(), objectType.getDelineation().getObjectClass()))
.findFirst();

if (!objectClassDef.isEmpty()) {
objectClassDef.get().getAttributeDefinitions().forEach(attr -> allAttributes.add(attr));
defs.stream()
.filter(d -> {
for (QName auxClass : objectType.getDelineation().getAuxiliaryObjectClass()) {
if (QNameUtil.match(d.getTypeName(), auxClass)) {
return true;
}
}
return false;
})
.forEach(d -> d.getAttributeDefinitions()
.forEach(attr -> allAttributes.add(attr)));
}
}
}
return allAttributes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@ public class AutoCompleteDisplayableValueConverter<T> implements IConverter<T> {

private final IModel<? extends List<DisplayableValue<T>>> values;

private final boolean strict;

public AutoCompleteDisplayableValueConverter(IModel<? extends List<DisplayableValue<T>>> values) {
this(values, true);
}

public AutoCompleteDisplayableValueConverter(IModel<? extends List<DisplayableValue<T>>> values, boolean strict) {
this.values = values;
this.strict = strict;
}

@Override
Expand All @@ -39,7 +46,14 @@ public T convertToObject(String value, Locale locale) throws ConversionException
if (displayValue.isPresent()) {
return displayValue.get().getValue();
}
throw new ConversionException("Cannot convert " + value);
if (strict) {
throw new ConversionException("Cannot convert " + value);
}
return valueToObject(value);
}

protected T valueToObject(String value) {
return null;
}

@Override
Expand All @@ -48,6 +62,10 @@ public String convertToString(T key, Locale locale) {
if (displayValue.isPresent()) {
return displayValue.get().getLabel();
}
return key == null ? "" : keyToString(key);
}

protected String keyToString(T key) {
return key.toString();
}
}

0 comments on commit 57f833e

Please sign in to comment.