Class MergeTools
java.lang.Object
com.ssgllc.fish.service.util.published.MergeTools
-
Method Summary
Modifier and TypeMethodDescriptionstatic <EntityT extends com.ssgllc.fish.domain.CasetivityEntity,DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO>
DoublecalculateMatchScore(DtoT a, DtoT b, String matchExpr) Find the match score between two entities without attempting to merge themstatic <DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO>
com.ssgllc.fish.service.dto.CasetivityMergeDTO<?> dryRunMerge(DtoT a, DtoT b) Dry run the result of merging two entities.static StringgetBlockingSetQuery(String entityName) Get the blocking set query configured for the given entity type.static <T extends com.ssgllc.fish.service.dto.CasetivityEntityDTO>
com.ssgllc.fish.dedupe.base.DedupeGroupDTO<T> getMatches(T dto) Find the existing entities matching a proposed one, using the existing dedupe configuration.static <EntityT extends com.ssgllc.fish.domain.CasetivityEntity,DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO>
com.ssgllc.fish.dedupe.base.DedupeGroupDTO<DtoT> getMatchesForBlockQueryAndMatchExpr(DtoT dto, String matchExprOverride, String blockQuery) Find the existing entities matching a proposed one, using a custom match expression and blocking set query It's recommended that you use the version that takes a blocking List instead, to avoid putting raw SQL in your scriptsstatic <T extends com.ssgllc.fish.service.dto.CasetivityEntityDTO>
com.ssgllc.fish.dedupe.base.DedupeGroupDTO<T> getMatchesForMatchExpr(T dto, String matchExprOverride) Find the existing entities matching a proposed one, using a custom match expressionstatic <EntityT extends com.ssgllc.fish.domain.CasetivityEntity,DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO>
com.ssgllc.fish.dedupe.base.DedupeGroupDTO<DtoT> getMatchesInBlockingSet(DtoT dto, List<DtoT> blockingSet) Find matches between a proposed entity and a given set, using the configured match expressionstatic <EntityT extends com.ssgllc.fish.domain.CasetivityEntity,DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO>
com.ssgllc.fish.dedupe.base.DedupeGroupDTO<DtoT> getMatchesInBlockingSetForMatchExpr(DtoT dto, List<DtoT> blockingSet, String matchExprOverride) Find matches between a proposed entity and a given set, using a custom match expressionstatic StringgetMatchExpression(String entityName) Get the match expression configured for the given entity type.static doublegetMatchThreshold(String entityName) Get the match score threshold configured for the given entity type.static doublegetNotMatchThreshold(String entityName) Get the not-match score threshold configured for the given entity type.static <DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO>
DtoTmerge(DtoT a, DtoT b) Merge two entities.
-
Method Details
-
dryRunMerge
public static <DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO> com.ssgllc.fish.service.dto.CasetivityMergeDTO<?> dryRunMerge(DtoT a, DtoT b) throws ClassNotFoundException Dry run the result of merging two entities. No changes to the database are committed.- Parameters:
a- first entity to merge withb- second entity to merge with- Returns:
- the merge result;
.getResult()on this gives the post-merge entity state - Throws:
ClassNotFoundException- if the entity type of the arguments isn't mergeable
-
merge
public static <DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO> DtoT merge(DtoT a, DtoT b) throws ClassNotFoundException Merge two entities. Triggers manual merge of two entities, based on completeness logic to decide which entity to keep/delete.- Parameters:
a- first entity to mergeb- second entity to merge- Returns:
- the merge result, gives the post-merge entity state
- Throws:
ClassNotFoundException- if the entity type of the arguments isn't mergeable
-
getMatches
public static <T extends com.ssgllc.fish.service.dto.CasetivityEntityDTO> com.ssgllc.fish.dedupe.base.DedupeGroupDTO<T> getMatches(T dto) throws ClassNotFoundException Find the existing entities matching a proposed one, using the existing dedupe configuration.- Parameters:
dto- entity to match- Returns:
- result object containing matches, potential matches, and match scores
- Throws:
ClassNotFoundException- if the given entity's type isn't mergeable
-
getMatchesForMatchExpr
public static <T extends com.ssgllc.fish.service.dto.CasetivityEntityDTO> com.ssgllc.fish.dedupe.base.DedupeGroupDTO<T> getMatchesForMatchExpr(T dto, String matchExprOverride) throws ClassNotFoundException Find the existing entities matching a proposed one, using a custom match expression- Parameters:
dto- entity to matchmatchExprOverride- String containing a (SPEL-based) match expression to use for this operation, if null, will use default setting for entity- Returns:
- result object containing matches, potential matches, and match scores
- Throws:
ClassNotFoundException- if the given entity's type isn't mergeable
-
getMatchesForBlockQueryAndMatchExpr
public static <EntityT extends com.ssgllc.fish.domain.CasetivityEntity,DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO> com.ssgllc.fish.dedupe.base.DedupeGroupDTO<DtoT> getMatchesForBlockQueryAndMatchExpr(DtoT dto, String matchExprOverride, String blockQuery) throws ClassNotFoundException Find the existing entities matching a proposed one, using a custom match expression and blocking set query It's recommended that you use the version that takes a blocking List instead, to avoid putting raw SQL in your scripts- Parameters:
dto- entity to matchmatchExprOverride- String containing a (SPEL-based) match expression to use for this operation, if null, will use default setting for entityblockQuery- String containing SQL query used to select which entities are considered for matching- Returns:
- result object containing matches, potential matches, and match scores
- Throws:
ClassNotFoundException- if the given entity's type isn't mergeable
-
getMatchesInBlockingSet
public static <EntityT extends com.ssgllc.fish.domain.CasetivityEntity,DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO> com.ssgllc.fish.dedupe.base.DedupeGroupDTO<DtoT> getMatchesInBlockingSet(DtoT dto, List<DtoT> blockingSet) throws ClassNotFoundException Find matches between a proposed entity and a given set, using the configured match expression- Parameters:
dto- entity to matchblockingSet- list of entities to compare, which can but don't need to exist in the database- Returns:
- object containing matches, potential matches, and match scores
- Throws:
ClassNotFoundException- if the given entity's type isn't mergeable
-
getMatchesInBlockingSetForMatchExpr
public static <EntityT extends com.ssgllc.fish.domain.CasetivityEntity,DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO> com.ssgllc.fish.dedupe.base.DedupeGroupDTO<DtoT> getMatchesInBlockingSetForMatchExpr(DtoT dto, List<DtoT> blockingSet, String matchExprOverride) throws ClassNotFoundException Find matches between a proposed entity and a given set, using a custom match expression- Parameters:
dto- entity to matchblockingSet- list of entities to compare, which can but don't need to exist in the databasematchExprOverride- String containing a (SPEL-based) match expression to use for this operation, if null, will use default setting for entity- Returns:
- object containing matches, potential matches, and match scores
- Throws:
ClassNotFoundException- if the given entity's type isn't mergeable
-
getMatchExpression
Get the match expression configured for the given entity type. Scores at or above the match threshold indicate an automatic match.- Parameters:
entityName- the entity type name (e.g."Person")- Returns:
- the SPEL-based match expression, or the system default if none is configured
-
getMatchThreshold
Get the match score threshold configured for the given entity type. Entities whose match score meets or exceeds this value are considered automatic matches.- Parameters:
entityName- the entity type name (e.g."Person")- Returns:
- the match threshold, or the system default if none is configured
-
getNotMatchThreshold
Get the not-match score threshold configured for the given entity type. Entities whose match score falls at or below this value are considered definite non-matches. Scores between this value and the match threshold are treated as possible matches.- Parameters:
entityName- the entity type name (e.g."Person")- Returns:
- the not-match threshold, or the system default if none is configured
-
getBlockingSetQuery
Get the blocking set query configured for the given entity type. The blocking set query is a SQL query used to select candidate entities for dedupe comparison.- Parameters:
entityName- the entity type name (e.g."Person")- Returns:
- the blocking set query string, or
nullif none is configured
-
calculateMatchScore
public static <EntityT extends com.ssgllc.fish.domain.CasetivityEntity,DtoT extends com.ssgllc.fish.service.dto.CasetivityEntityDTO> Double calculateMatchScore(DtoT a, DtoT b, String matchExpr) throws ClassNotFoundException Find the match score between two entities without attempting to merge them- Parameters:
a- first entity to compareb- second entity to comparematchExpr- match expression to use- Returns:
- the numeric match score
- Throws:
ClassNotFoundException- if the entity type of the arguments isn't mergeable
-