This is an internal documentation. There is a good chance you’re looking for something else. See Disclaimer.
Duplicate
Config
The way duplicate entities are identified can be configured in the entity Duplicate_config. Duplicate_field
entities are grouped into Duplicate_field_group entities. Fields in a group are combined as AND conditions, while
groups themselves are combined as OR conditions. For each Duplicate_field a field to check and the
Duplicate_comparison_type have to be set. Currently there exist two options:
exactcheck fields for equality of their values
fuzzycheck fields for the similarity of their values by comparing their trigram scores
by default a similarity of 0.6 is required (see documentation of
pg_trgmfor what that exactly means)required similarity can be set in
nice2.duplicate.min.trigramSimilarityinapplication.propertiesaccents will be ignored (e.g. “ä” will be treated the same way as “a”)
Configs can be activated and deactivated through the actions on their list and detail forms.
After activating a config, a search for duplicates in the system is started. The results can be found
as Duplicate entities. These are kept up to date as long as the config is active. When a config is deactivated,
all duplicates generated by that config are deleted.
For each entity model, a filter can be contirbuted by setting a relation and unique ids to look for. Entities that contain any of the ids in the defined relation are excluded from the duplicate search. See example at the bottom of this page.
At this moment, Duplicate_config can only be created for User and Address.
Enabling duplicate search for new entity models
Note
Check the examples below if one of the steps is unclear.
Add dependency on
:core:duplicatemodule inbuild.gradleof the corresponding moduleDefine relation to filter new entity model by in a
@Configurationclass.Add initial values for
Duplicate_entity_modelfor the new entity model.Create relations from
Duplicateto new entity model, likeDuplicate_relAddress.Add the above relation to the detail form of the new entity model.
Deny all write rights on this new relation.
Add rights for manager role to see duplicates.
Set DuplicateListener to run for new entity model.
Create
Duplicate_config,Duplicate_field_groupandDuplicate_fieldentities.Activate the new
Duplicate_configonce you’re satisfied with it.
UserDuplicate_entity_model:
localized:
label: entities.User
fields:
unique_id: user
sorting: 10
active: true
config:
identifier: unique_id
priority: 30
Duplicate_relUser<field data="relDuplicate" scopes="read,update" ignore-copy="true"/>
User<?xml version="1.0" encoding="UTF-8"?>
<relation xmlns="http://nice2.tocco.ch/schema/relation.xsd">
<source entity-model="Duplicate">
<delete cascade="no"/>
</source>
<target entity-model="User">
<delete cascade="no"/>
</target>
<cardinality>n:n</cardinality>
</relation>
UserentityPath(Duplicate, relUser):
deny access(write);
entityPath(User, relDuplicate):
deny access(write);
entity(Duplicate):
grant access to usermanager;
User@Bean
public DuplicateFilterContribution userDuplicateFilterContribution() {
DuplicateFilterContribution contribution = new DuplicateFilterContribution();
contribution.setModel("User");
contribution.setRelationName("relUser_status");
contribution.setValuesToExclude("archive");
return contribution;
}
@Bean
public ListenerContribution<EntityFacadeListener> userDuplicateListenerContribution(@Qualifier("duplicateListener") EntityFacadeListener listener) {
ListenerContribution<EntityFacadeListener> contribution = new ListenerContribution<>();
contribution.setFilter("User");
contribution.setListener(listener);
return contribution;
}