Skip to content

Commit

Permalink
object template is passed from gui for focus correlation
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jul 19, 2023
1 parent 602e218 commit 8291f9e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.ItemPathType;

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

import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.LoadableDetachableModel;
Expand All @@ -50,9 +52,11 @@ public class PageCorrelationFocusIdentification extends PageAbstractAttributeVer
private static final String OPERATION_LOAD_ARCHETYPE = DOT_CLASS + "loadArchetype";
private static final String OPERATION_LOAD_OBJECT_TEMPLATE = DOT_CLASS + "loadObjectTemplate";
private static final String OPERATION_LOAD_SYSTEM_CONFIGURATION = DOT_CLASS + "loadSystemConfiguration";
private static final String OPERATION_CORRELATE = DOT_CLASS + "correlate";

private static final String ID_CORRELATE = "correlate";

private LoadableDetachableModel<ObjectTemplateType> objectTemplateModel;
private LoadableDetachableModel<List<ItemsSubCorrelatorType>> correlatorsModel;
private String archetypeOid;

Expand Down Expand Up @@ -101,13 +105,20 @@ private List<ItemPath> getCurrentCorrelationItemPathList() {
@Override
protected void initModels() {
super.initModels();
objectTemplateModel = new LoadableDetachableModel<>() {
private static final long serialVersionUID = 1L;
@Override
protected ObjectTemplateType load() {
var archetype = loadArchetype();
return loadObjectTemplateForArchetype(archetype);
}
};
correlatorsModel = new LoadableDetachableModel<>() {
private static final long serialVersionUID = 1L;

@Override
protected List<ItemsSubCorrelatorType> load() {
var archetype = loadArchetype();
var objectTemplate = loadObjectTemplateForArchetype(archetype);
var objectTemplate = objectTemplateModel.getObject();
if (objectTemplate == null) {
//todo show warning?
return Collections.emptyList();
Expand All @@ -125,7 +136,7 @@ protected void initCustomLayout() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
correlate();
correlate(target);
}
};
getForm().add(correlateButton);
Expand Down Expand Up @@ -192,7 +203,28 @@ protected ObjectQuery createStaticFormQuery() {
}


private void correlate() {
private void correlate(AjaxRequestTarget target) {
var task = createAnonymousTask(OPERATION_CORRELATE);
var result = new OperationResult(OPERATION_CORRELATE);
var user = createUser();
var objectTemplate = objectTemplateModel.getObject();
try {
getCorrelationService().correlate(user, objectTemplate, task, result);
} catch (Exception e) {
LoggingUtils.logException(LOGGER, "Couldn't determine correlation configuration.", e);
result.recordFatalError(e);
showResult(result);
target.add(getFeedbackPanel());
}


}

private UserType createUser() {
UserType user = new UserType();
user.setFamilyName(new PolyStringType("family"));
user.setFamilyName(new PolyStringType("family"));
return user;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public interface CorrelationService {
*/
@NotNull CompleteCorrelationResult correlate(
@NotNull FocusType preFocus,
@NotNull ObjectTemplateType objectTemplate,
@NotNull Task task,
@NotNull OperationResult result)
throws SchemaException, ExpressionEvaluationException, CommunicationException, SecurityViolationException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ public class CorrelationServiceImpl implements CorrelationService {
@Override
public @NotNull CompleteCorrelationResult correlate(
@NotNull FocusType preFocus,
@NotNull ObjectTemplateType objectTemplate,
@NotNull Task task,
@NotNull OperationResult result)
throws SchemaException, ExpressionEvaluationException, CommunicationException, SecurityViolationException,
ConfigurationException, ObjectNotFoundException {
CompleteContext ctx = getCompleteContext(preFocus, task, result);
CompleteContext ctx = getCompleteContext(preFocus, objectTemplate, task, result);
return correlate(ctx.correlatorContext, ctx.correlationContext, result);
}

Expand Down Expand Up @@ -358,6 +359,7 @@ void resolve(

private @NotNull CompleteContext getCompleteContext(
@NotNull FocusType preFocus,
@NotNull ObjectTemplateType objectTemplate,
@NotNull Task task,
@NotNull OperationResult result)
throws SchemaException, ConfigurationException, ObjectNotFoundException {
Expand All @@ -368,7 +370,7 @@ void resolve(
return CompleteContext.forFocus(
correlationDefinitionBean,
preFocus,
determineObjectTemplate(null, preFocus, task, result),
objectTemplate,
asObjectable(systemObjectCache.getSystemConfiguration(result)),
task);
}
Expand Down

0 comments on commit 8291f9e

Please sign in to comment.