Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Mar 14, 2022
2 parents 12dc076 + 3c51011 commit 2dbc9fe
Show file tree
Hide file tree
Showing 73 changed files with 2,134 additions and 1,663 deletions.
169 changes: 62 additions & 107 deletions .editorconfig

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

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

import com.evolveum.midpoint.web.component.util.EnableBehaviour;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Application;
import org.apache.wicket.ajax.AjaxChannel;
Expand Down Expand Up @@ -163,13 +165,15 @@ protected void onComponentTag(ComponentTag tag) {
+ "}\n"
+ "})"));
password1.setRequired(false);
password1.add(new EnableBehaviour(this::canEditPassword));
password1.setOutputMarkupId(true);
password1.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
inputContainer.add(password1);

final PasswordTextField password2 = new SecureModelPasswordTextField(ID_PASSWORD_TWO, new PasswordModel(Model.of(new ProtectedStringType())));
password2.setRequired(false);
password2.setOutputMarkupId(true);
password2.add(new EnableBehaviour(this::canEditPassword));
inputContainer.add(password2);

password1.add(new AjaxFormComponentUpdatingBehavior("change") {
Expand Down Expand Up @@ -347,6 +351,10 @@ public ValuePolicyType run() {
return valuePolicyType;
}

protected boolean canEditPassword() {
return true;
}

private <F extends FocusType> ValuePolicyType searchValuePolicy(PrismObject<F> object, Task task) {
try {
CredentialsPolicyType credentials = getPageBase().getModelInteractionService().getCredentialsPolicy(object, task, task.getResult());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@
import java.util.ArrayList;
import java.util.List;

import com.evolveum.midpoint.schema.util.cases.CorrelationCaseUtil;

import com.evolveum.midpoint.schema.util.cases.OwnerOptionIdentifier;

import com.evolveum.midpoint.util.exception.SchemaException;

import org.jetbrains.annotations.Nullable;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.model.api.correlator.FullCorrelationContext;
import com.evolveum.midpoint.model.api.CorrelationProperty;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.cases.CorrelationCaseUtil;
import com.evolveum.midpoint.schema.util.cases.OwnerOptionIdentifier;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.CommonException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand All @@ -33,7 +30,7 @@
/**
* Represents the whole correlation context: a set of options, including "new owner" one.
*/
public class CorrelationContextDto implements Serializable {
class CorrelationContextDto implements Serializable {

private static final Trace LOGGER = TraceManager.getTrace(CorrelationContextDto.class);

Expand Down Expand Up @@ -63,7 +60,7 @@ public class CorrelationContextDto implements Serializable {
*
* Correspond to rows in the correlation options table.
*/
private final List<CorrelationPropertyDefinition> correlationProperties = new ArrayList<>();
private final List<CorrelationProperty> correlationProperties = new ArrayList<>();

CorrelationContextDto(CaseType aCase, PageBase pageBase, Task task, OperationResult result) throws CommonException {
load(aCase, pageBase, task, result);
Expand Down Expand Up @@ -129,21 +126,9 @@ private void createCorrelationOptions(CaseType aCase) throws SchemaException {

private void createCorrelationPropertiesDefinitions(CaseType aCase, PageBase pageBase, Task task, OperationResult result)
throws CommonException {
FullCorrelationContext instantiationContext =
pageBase.getCorrelationService().getFullCorrelationContext(aCase.asPrismObject(), task, result);
CorrelationPropertiesDefinitionType propertiesBean = // TODO what if there's no definition?
instantiationContext.synchronizationBean.getCorrelationDefinition().getCorrelationProperties();
CorrelationOptionDto newOwnerOption = getNewOwnerOption();
if (propertiesBean != null) {
PrismObject<?> preFocus = newOwnerOption != null ? newOwnerOption.getObject() : null;
CorrelationPropertyDefinition.fillFromConfiguration(correlationProperties, propertiesBean, preFocus);
} else {
if (newOwnerOption == null) {
LOGGER.warn("Couldn't create property definitions from 'new owner' focus object because there's none");
} else {
CorrelationPropertyDefinition.fillFromObject(correlationProperties, newOwnerOption.getObject());
}
}
correlationProperties.clear();
correlationProperties.addAll(
pageBase.getCorrelationService().getCorrelationProperties(aCase, task, result));
}

@Nullable CorrelationOptionDto getNewOwnerOption() {
Expand All @@ -162,7 +147,7 @@ public List<String> getOptionHeaders() {
return optionHeaders;
}

public List<CorrelationPropertyDefinition> getCorrelationProperties() {
public List<CorrelationProperty> getCorrelationProperties() {
return correlationProperties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.evolveum.midpoint.gui.impl.page.admin.cases.component;

import com.evolveum.midpoint.model.api.CorrelationProperty;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.WorkItemId;
Expand Down Expand Up @@ -151,16 +152,16 @@ protected void populateItem(ListItem<CorrelationOptionDto> item) {
};
add(referenceIds);

ListView<CorrelationPropertyDefinition> rows = new ListView<>(ID_ROWS,
ListView<CorrelationProperty> rows = new ListView<>(ID_ROWS,
new PropertyModel<>(correlationCtxModel, CorrelationContextDto.F_CORRELATION_PROPERTIES)) {

@Override
protected void populateItem(ListItem<CorrelationPropertyDefinition> item) {
protected void populateItem(ListItem<CorrelationProperty> item) {
// First column contains the property name
item.add(
new Label(ID_ATTR_NAME,
new PropertyModel<>(
item.getModel(), CorrelationPropertyDefinition.F_DISPLAY_NAME)));
item.getModel(), CorrelationProperty.F_DISPLAY_NAME)));

// Here are columns for values for individual options
item.add(
Expand Down Expand Up @@ -193,21 +194,21 @@ private IModel<CorrelationContextDto> createCorrelationContextModel() {
}

private ListView<CorrelationOptionDto> createColumnsForPropertyRow(
IModel<CorrelationContextDto> contextModel, ListItem<CorrelationPropertyDefinition> rowItem) {
IModel<CorrelationContextDto> contextModel, ListItem<CorrelationProperty> rowItem) {

return new ListView<>(ID_COLUMNS, new PropertyModel<>(contextModel, CorrelationContextDto.F_CORRELATION_OPTIONS)) {
@Override
protected void populateItem(ListItem<CorrelationOptionDto> columnItem) {
CorrelationContextDto contextDto = contextModel.getObject();
CorrelationOptionDto optionDto = columnItem.getModelObject();
CorrelationPropertyDefinition propertyDefinition = rowItem.getModelObject();
CorrelationProperty correlationProperty = rowItem.getModelObject();

CorrelationPropertyValues valuesForOption = optionDto.getPropertyValues(propertyDefinition);
CorrelationPropertyValues valuesForOption = optionDto.getPropertyValues(correlationProperty);
Label label = new Label(ID_COLUMN, valuesForOption.format());

CorrelationOptionDto referenceOption = contextDto.getNewOwnerOption();
if (referenceOption != null && !optionDto.isNewOwner()) {
CorrelationPropertyValues referenceValues = referenceOption.getPropertyValues(propertyDefinition);
CorrelationPropertyValues referenceValues = referenceOption.getPropertyValues(correlationProperty);
Match match = referenceValues.match(valuesForOption);
label.add(
AttributeAppender.append("class", match.getCss()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
package com.evolveum.midpoint.gui.impl.page.admin.cases.component;

import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

import com.evolveum.midpoint.model.api.CorrelationProperty;
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.schema.route.ItemRoute;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectOwnerOptionType;

import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.util.MatchingUtil;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
Expand Down Expand Up @@ -68,22 +74,36 @@ public class CorrelationOptionDto implements Serializable {
/**
* Returns all real values matching given item path. The path should not contain container IDs.
*/
public CorrelationPropertyValues getPropertyValues(CorrelationPropertyDefinition def) {
Set<String> primaryValues;
Set<String> secondaryValues;
if (newOwner) {
primaryValues = getValuesForPath(def.getSourcePath());
secondaryValues = Set.of();
} else {
primaryValues = getValuesForPath(def.getPrimaryTargetPath());
secondaryValues = def.getSecondaryTargetPath() != null ?
getValuesForPath(def.getSecondaryTargetPath()) : Set.of();
public CorrelationPropertyValues getPropertyValues(CorrelationProperty correlationProperty) {
try {
if (newOwner) {
return new CorrelationPropertyValues(
correlationProperty.getSourceRealStringValues(),
Set.of());
} else {
return new CorrelationPropertyValues(
getValuesForRoute(correlationProperty.getPrimaryTargetRoute()),
getValuesForRoutes(correlationProperty.getSecondaryTargetRoutes()));
}
} catch (Exception e) {
return new CorrelationPropertyValues(Set.of(e.getMessage()), Set.of());
}
return new CorrelationPropertyValues(primaryValues, secondaryValues);
}

private @NotNull Set<String> getValuesForPath(ItemPath path) {
return MatchingUtil.getValuesForPath(object, path);
private Set<String> getValuesForRoutes(List<ItemRoute> routes) throws SchemaException {
Set<String> values = new HashSet<>();
for (ItemRoute route : routes) {
values.addAll(getValuesForRoute(route));
}
return values;
}

private @NotNull Set<String> getValuesForRoute(ItemRoute route) throws SchemaException {
return route.resolveFor(object.asObjectable()).stream()
.filter(Objects::nonNull)
.map(PrismValue::getRealValue)
.map(String::valueOf)
.collect(Collectors.toSet());
}

public @NotNull PrismObject<?> getObject() {
Expand Down

This file was deleted.

0 comments on commit 2dbc9fe

Please sign in to comment.