Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Feb 28, 2023
2 parents fc07b1c + 13fd05c commit 13c7dcb
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,29 +698,29 @@ public void yesPerformed(AjaxRequestTarget target) {
showMainPopup(dialog, target);
}

private void deleteAllTypeConfirmed(AjaxRequestTarget target) {
private void deleteAllTypeConfirmed(AjaxRequestTarget target, Class<? extends ObjectType> typeClass) {

LOGGER.debug("Deleting all of type {}", getType());
LOGGER.debug("Deleting all of type {}", typeClass);

OperationResult result = new OperationResult(OPERATION_DELETE_OBJECTS);
String taskOid = null;
try {
ObjectQuery query = null;
if (ObjectTypes.USER.getClassDefinition().equals(getType())) {
if (ObjectTypes.USER.getClassDefinition().equals(typeClass)) {
query = createDeleteAllUsersQuery();
}

QName type = ObjectTypes.getObjectType(getType()).getTypeQName();
QName type = ObjectTypes.getObjectType(typeClass).getTypeQName();

taskOid = deleteObjectsAsync(type, query, "Delete all of type " + type.getLocalPart(),
result);

info(getString("pageDebugList.messsage.deleteAllOfType", getType()));
info(getString("pageDebugList.messsage.deleteAllOfType", typeClass));
} catch (Exception ex) {
result.recomputeStatus();
result.recordFatalError(getString("pageDebugList.messsage.notDeleteObjects", getType()), ex);
result.recordFatalError(getString("pageDebugList.messsage.notDeleteObjects", typeClass), ex);

LoggingUtils.logUnexpectedException(LOGGER, "" + getType(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "" + typeClass, ex);
}

finishOperation(result, taskOid, target);
Expand Down Expand Up @@ -804,7 +804,7 @@ public void yesPerformed(AjaxRequestTarget target) {
DebugConfDialogDto dto = confDialogModel.getObject();
switch (dto.getOperation()) {
case DELETE_ALL_TYPE:
deleteAllTypeConfirmed(target);
deleteAllTypeConfirmed(target, dto.getType());
break;
case DELETE_SELECTED:
deleteSelectedConfirmed(target, dto.getObjects());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ private Set<? extends PrismValue> getPrismValuesAfter(@NotNull ItemPath path) {
return delta.getModifications().stream()
.map(itemDelta -> new ProcessedObjectItemDeltaImpl<>(itemDelta))
.filter(itemDelta -> filter.matches(itemDelta))
.filter(itemDelta -> !itemDelta.isPhantom())
.collect(Collectors.toList());
} else {
return List.of();
Expand Down Expand Up @@ -862,6 +863,11 @@ public ItemDelta<V, D> clone() {
ParameterizedEquivalenceStrategy.REAL_VALUE));
}

/** Either we have only operational data changed, or the delta is phantom one indeed. */
public boolean isPhantom() {
return getValuesWithStates().isEmpty();
}

@Override
public @NotNull Collection<ValueWithState> getValuesWithStates() {
List<ValueWithState> all = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ class ShadowUpdater {
@NotNull private final ModelBeans beans;
@NotNull private final List<ItemDelta<?, ?>> deltas = new ArrayList<>();

/** Only for simulation purposes. */
private final ShadowType shadowBefore;

ShadowUpdater(@NotNull SynchronizationContext<?> syncCtx, @NotNull ModelBeans beans) {
this.syncCtx = syncCtx;
this.beans = beans;
this.shadowBefore = isShadowSimulation() ? syncCtx.getShadowedResourceObject().clone() : null;
}

ShadowUpdater updateAllSyncMetadataRespectingMode() throws SchemaException {
Expand Down Expand Up @@ -195,7 +199,7 @@ void commit(OperationResult result) {
return;
}
try {
if (syncCtx.getTask().areShadowChangesSimulated()) {
if (isShadowSimulation()) {
commitToSimulation(result);
} else {
commitToRepository(result);
Expand All @@ -208,15 +212,18 @@ void commit(OperationResult result) {
deltas.clear();
}

private boolean isShadowSimulation() {
return syncCtx.getTask().areShadowChangesSimulated();
}

private void commitToSimulation(OperationResult result) {
Task task = syncCtx.getTask();
ShadowType shadow = syncCtx.getShadowedResourceObject();
SimulationTransaction simulationTransaction = task.getSimulationTransaction();
if (simulationTransaction == null) {
LOGGER.debug("Ignoring simulation data because there is no simulation transaction: {}: {}", shadow, deltas);
LOGGER.debug("Ignoring simulation data because there is no simulation transaction: {}: {}", shadowBefore, deltas);
} else {
simulationTransaction.writeSimulationData(
ShadowSimulationData.of(shadow, deltas), task, result);
ShadowSimulationData.of(shadowBefore, deltas), task, result);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ private void executeSimulatedClassificationAndReclassification(
.assertSize(0);
} else {
// Resource is development mode, task sees the development configuration.
// Hence, both re-classification and re-correlation occurs (the latter because the
// Hence, both re-classification and re-correlation occurs.
and("there is a re-classification delta");
// @formatter:off
assertProcessedObjects(simResult3)
Expand All @@ -943,6 +943,10 @@ private void executeSimulatedClassificationAndReclassification(
.end()
.assertSize(2); // temporarily
// @formatter:on

REPORT_SIMULATION_VALUES_CHANGED.export()
.withDefaultParametersValues(simResult3.getSimulationResultRef())
.execute(result);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.io.FileNotFoundException;
import java.net.ConnectException;

import static com.evolveum.midpoint.model.test.CommonInitialObjects.REPORT_SIMULATION_VALUES_CHANGED;
import static com.evolveum.midpoint.schema.constants.MidPointConstants.NS_RI;
import static com.evolveum.midpoint.schema.constants.SchemaConstants.RI_ACCOUNT_OBJECT_CLASS;

Expand Down Expand Up @@ -151,6 +152,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
RESOURCE_SIMPLE_DEVELOPMENT_TARGET.initAndTest(this, initTask, initResult);
RESOURCE_SIMPLE_PRODUCTION_SOURCE.initAndTest(this, initTask, initResult);
RESOURCE_SIMPLE_DEVELOPMENT_SOURCE.initAndTest(this, initTask, initResult);

REPORT_SIMULATION_VALUES_CHANGED.init(this, initTask, initResult);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public void test110DisableAndRenameUsers() throws Exception {
assertCsv(itemsLines2, "after")
.parse()
.display()
.assertRecords((a) -> a.hasSizeGreaterThan(50)); // too many
.assertRecords((a) -> a.hasSizeGreaterThan(40)); // too many

when("item-level report is created - 'name' only");
var itemsLines3 = REPORT_SIMULATION_ITEMS_CHANGED.export()
Expand Down

0 comments on commit 13c7dcb

Please sign in to comment.