Skip to content

Commit

Permalink
Merge branch 'post-3.7-fixes' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
…into post-3.7-fixes
  • Loading branch information
katkav committed Feb 14, 2018
2 parents 658683e + 7f98211 commit e83a188
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 6 deletions.
Expand Up @@ -221,6 +221,7 @@ public void setObjectToAdd(PrismObject<T> objectToAdd) {
}
}

@NotNull
public Collection<? extends ItemDelta<?,?>> getModifications() {
return modifications;
}
Expand Down
Expand Up @@ -23,6 +23,8 @@
import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.PrismValue;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.util.LocalizableMessage;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -1129,4 +1131,12 @@ Object executeAdHocProvisioningScript(String resourceOid, String language, Strin
*/
Boolean isEvaluateNew();

/**
* Returns all non-negative values from all focus mappings (targeted to given path)
* from all non-negative evaluated assignments.
*
* Highly experimental. Use at your own risk.
*/
@NotNull
Collection<PrismValue> collectAssignedFocusMappingsResults(@NotNull ItemPath path) throws SchemaException;
}
Expand Up @@ -32,6 +32,7 @@
import com.evolveum.midpoint.model.api.expr.MidpointFunctions;
import com.evolveum.midpoint.model.common.ConstantsManager;
import com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluationContext;
import com.evolveum.midpoint.model.common.mapping.Mapping;
import com.evolveum.midpoint.model.impl.ModelObjectResolver;
import com.evolveum.midpoint.model.impl.lens.EvaluatedAssignmentImpl;
import com.evolveum.midpoint.model.impl.lens.LensContext;
Expand All @@ -41,10 +42,7 @@
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.crypto.EncryptionException;
import com.evolveum.midpoint.prism.crypto.Protector;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.DeltaSetTriple;
import com.evolveum.midpoint.prism.delta.ItemDelta;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.*;
import com.evolveum.midpoint.prism.marshaller.ItemPathHolder;
import com.evolveum.midpoint.prism.match.DefaultMatchingRule;
import com.evolveum.midpoint.prism.match.PolyStringOrigMatchingRule;
Expand Down Expand Up @@ -100,6 +98,7 @@
import static com.evolveum.midpoint.schema.util.LocalizationUtil.toLocalizableMessage;
import static com.evolveum.midpoint.schema.util.ObjectTypeUtil.createObjectRef;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType.RUNNABLE;
import static java.util.Collections.emptySet;
import static java.util.Collections.singleton;

/**
Expand Down Expand Up @@ -1647,4 +1646,29 @@ public Boolean isEvaluateNew() {
}
return scriptContext.isEvaluateNew();
}

@Override
@NotNull
public Collection<PrismValue> collectAssignedFocusMappingsResults(@NotNull ItemPath path) throws SchemaException {
LensContext<ObjectType> lensContext = ModelExpressionThreadLocalHolder.getLensContext();
if (lensContext == null) {
throw new IllegalStateException("No lensContext");
}
DeltaSetTriple<EvaluatedAssignmentImpl<?>> evaluatedAssignmentTriple = lensContext.getEvaluatedAssignmentTriple();
if (evaluatedAssignmentTriple == null) {
return emptySet();
}
Collection<PrismValue> rv = new HashSet<>();
for (EvaluatedAssignmentImpl<?> evaluatedAssignment : evaluatedAssignmentTriple.getNonNegativeValues()) {
for (Mapping<?, ?> mapping : evaluatedAssignment.getFocusMappings()) {
if (path.equivalent(mapping.getOutputPath())) {
PrismValueDeltaSetTriple<?> outputTriple = mapping.getOutputTriple();
if (outputTriple != null) {
rv.addAll(outputTriple.getNonNegativeValues());
}
}
}
}
return rv;
}
}
Expand Up @@ -30,6 +30,7 @@

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.query.FilterUtils;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.QueryJaxbConvertor;
import com.evolveum.midpoint.prism.util.CloneUtil;
Expand Down Expand Up @@ -491,7 +492,7 @@ protected QueryType getObjectQueryTypeFromTaskObjectRef(Task task) {
return null;
}
SearchFilterType filterType = objectRef.getFilter();
if (filterType == null) {
if (filterType == null || FilterUtils.isFilterEmpty(filterType)) {
return null;
}
QueryType queryType = new QueryType();
Expand Down
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2010-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.repo.sql.closure;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.repo.api.RepoAddOptions;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Test;

import static org.testng.AssertJUnit.assertFalse;

/**
* MID-4407
*
* @author mederly
*/
@ContextConfiguration(locations = {"../../../../../../ctx-test.xml"})
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class OrgClosureOverwriteAddTest extends AbstractOrgClosureTest {

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

private static final int[] ORG_CHILDREN_IN_LEVEL = { 1, 1 };
private static final int[] USER_CHILDREN_IN_LEVEL = null;
private static final int[] PARENTS_IN_LEVEL = { 0, 1 };

private OrgClosureTestConfiguration configuration;

public OrgClosureOverwriteAddTest() {
configuration = new OrgClosureTestConfiguration();
configuration.setCheckChildrenSets(true);
configuration.setCheckClosureMatrix(true);
configuration.setDeletionsToClosureTest(1);
configuration.setOrgChildrenInLevel(ORG_CHILDREN_IN_LEVEL);
configuration.setUserChildrenInLevel(USER_CHILDREN_IN_LEVEL);
configuration.setParentsInLevel(PARENTS_IN_LEVEL);
}

@Test
public void test100AddWithOverwrite() throws Exception {
OperationResult opResult = new OperationResult("===[ test100AddWithOverwrite ]===");

_test100LoadOrgStructure();
_test150CheckClosure();

String parentOid = orgsByLevels.get(0).get(0);
String childOid = orgsByLevels.get(1).get(0);
PrismObject<OrgType> childOrg = repositoryService.getObject(OrgType.class, childOid, null, opResult);
childOrg.asObjectable().getParentOrgRef().clear();

LOGGER.info("+++ adding object with 'overwrite' option +++");
repositoryService.addObject(childOrg, RepoAddOptions.createOverwrite(), opResult);

orgGraph.removeEdge(childOid, parentOid);
checkOrgGraph();
boolean problem = checkClosureMatrix();
assertFalse("Closure problem was detected", problem);
}

@Override
public OrgClosureTestConfiguration getConfiguration() {
return configuration;
}
}
1 change: 1 addition & 0 deletions repo/repo-sql-impl-test/testng-integration.xml
Expand Up @@ -39,6 +39,7 @@
<class name="com.evolveum.midpoint.repo.sql.ListAccountShadowOwnerTest"/>
<class name="com.evolveum.midpoint.repo.sql.OrgStructTest"/>
<class name="com.evolveum.midpoint.repo.sql.closure.OrgClosureCorrectnessTest"/>
<class name="com.evolveum.midpoint.repo.sql.closure.OrgClosureOverwriteAddTest"/>
<class name="com.evolveum.midpoint.repo.sql.SearchTest"/>
<class name="com.evolveum.midpoint.repo.sql.CleanupTest"/>
<class name="com.evolveum.midpoint.repo.sql.SearchShadowOwnerTest"/>
Expand Down
Expand Up @@ -179,7 +179,7 @@ private <T extends ObjectType> String overwriteAddObjectAttempt(PrismObject<T> o
if (originalOid != null) {
try {
oldObject = objectRetriever.getObjectInternal(session, object.getCompileTimeClass(), originalOid, null, true, result);
ObjectDelta<T> delta = object.diff(oldObject);
ObjectDelta<T> delta = oldObject.diff(object, false, true);
modifications = delta.getModifications();

LOGGER.trace("overwriteAddObjectAttempt: originalOid={}, modifications={}", originalOid, modifications);
Expand Down

0 comments on commit e83a188

Please sign in to comment.