-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repo-sqale: added modify support for Shadow.pendingOperations (count)
Implemented in CountItemDeltaProcessor which was the third class using the same code in process(), so FinalValueDeltaProcessor was added and JsonbPolysItemDeltaProcessor and ArrayItemDeltaProcessor are all subclasses implementing only setRealValues() and delete(). SimpleItemDeltaProcessor was removed, adds nothing to its superclass SinglePathItemDeltaProcessor which works just as well.
- Loading branch information
Showing
11 changed files
with
197 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...le/src/main/java/com/evolveum/midpoint/repo/sqale/delta/item/CountItemDeltaProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2010-2021 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.repo.sqale.delta.item; | ||
|
||
import java.util.Collection; | ||
import java.util.function.Function; | ||
|
||
import com.querydsl.core.types.dsl.NumberPath; | ||
|
||
import com.evolveum.midpoint.repo.sqale.update.SqaleUpdateContext; | ||
import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; | ||
|
||
/** | ||
* Delta processor for columns storing size of multi-value item. | ||
* | ||
* @param <T> expected type of the real value, but we don't care in this class | ||
*/ | ||
public class CountItemDeltaProcessor<T> extends FinalValueDeltaProcessor<T> { | ||
|
||
private final NumberPath<Integer> path; | ||
|
||
/** | ||
* @param <Q> entity query type from which the attribute is resolved | ||
* @param <R> row type related to {@link Q} | ||
*/ | ||
public <Q extends FlexibleRelationalPathBase<R>, R> CountItemDeltaProcessor( | ||
SqaleUpdateContext<?, Q, R> context, | ||
Function<Q, NumberPath<Integer>> rootToQueryItem) { | ||
super(context); | ||
this.path = rootToQueryItem.apply(context.entityPath()); | ||
} | ||
|
||
@Override | ||
public void setRealValues(Collection<?> values) { | ||
context.set(path, values.size()); | ||
} | ||
|
||
@Override | ||
public void delete() { | ||
context.set(path, 0); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...e/src/main/java/com/evolveum/midpoint/repo/sqale/delta/item/FinalValueDeltaProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (C) 2010-2021 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.repo.sqale.delta.item; | ||
|
||
import java.util.Collection; | ||
|
||
import com.evolveum.midpoint.prism.Item; | ||
import com.evolveum.midpoint.prism.PrismValue; | ||
import com.evolveum.midpoint.prism.delta.ItemDelta; | ||
import com.evolveum.midpoint.repo.sqale.delta.ItemDeltaValueProcessor; | ||
import com.evolveum.midpoint.repo.sqale.update.SqaleUpdateContext; | ||
import com.evolveum.midpoint.repo.sqlbase.RepositoryException; | ||
import com.evolveum.midpoint.repo.sqlbase.querydsl.FlexibleRelationalPathBase; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
|
||
/** | ||
* Common delta processor logic for storing based on the final value of the property. | ||
* When the delta processor is run, the modification has been already applied to the prism object. | ||
* This is typically used for storing multi-value item in a single column. | ||
* This may not be efficient when the amount of values is too big, but it has to be really big | ||
* to be of consequence (my wild guess is 100-1000 can be still OK). | ||
* | ||
* Subclasses have to implement {@link #setRealValues(Collection)} and {@link #delete()} methods. | ||
* | ||
* @param <T> expected type of the real value for the modification (after optional conversion) | ||
*/ | ||
public abstract class FinalValueDeltaProcessor<T> extends ItemDeltaValueProcessor<T> { | ||
|
||
/** | ||
* @param <Q> entity query type from which the attribute is resolved | ||
* @param <R> row type related to {@link Q} | ||
*/ | ||
public <Q extends FlexibleRelationalPathBase<R>, R> FinalValueDeltaProcessor( | ||
SqaleUpdateContext<?, Q, R> context) { | ||
super(context); | ||
} | ||
|
||
@Override | ||
public void process(ItemDelta<?, ?> modification) throws RepositoryException, SchemaException { | ||
Item<PrismValue, ?> item = context.findItem(modification.getPath()); | ||
Collection<?> realValues = item != null ? item.getRealValues() : null; | ||
|
||
if (realValues == null || realValues.isEmpty()) { | ||
delete(); | ||
} else { | ||
// Whatever the operation is, we just set the new value here. | ||
setRealValues(realValues); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
...e/src/main/java/com/evolveum/midpoint/repo/sqale/delta/item/SimpleItemDeltaProcessor.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.