This module is a quick solution as well as exclusive for the management,organization and storage of generic Entities and their Addresses in a common web application. The module provides hooks to manage duplicated entries through the use of deduplication algorithm: a simple but efficient one has been already implemented
Often ,one of the first requirement in a management system , is to avoid the duplicate data into the database. Registry module provides ,through the use of DeduplicationStrategy ,an easy way to resolve this problem
As described above ,supposing you have a reasonable number of Entity,represented by Person or Corporation in your data storage, and would like to clean them from duplicates,
the first step to move is trying registry generic algorithm. In this way you can obtain , starting from a registered Entity, a list of possible duplicates to remove.
import net.smartlab.web.*; import net.smartlab.web.registry.*; public class MyAction extends Action { net.smartlab.web.registry.Domain domain=net.smartlab.web.registry.Domain.getInstance(); public String myMethod(ActionForm form, HttpServletRequest request, HttpServletResponse response, ActionMapping mapping) throws ActionException { try { Entity entity = (Entity)domain.findEntry(request.getParameter("id")); Collection duplicates = domain.listDuplicates(Entity entity); //your code here .... .... request.setAttribute("duplicates", duplicates); return "success"; } catch (BusinessException be) { throw new ActionException(be.getMessage(), be.getCause()); } } }
However a framework should allow for simplicity without force so if you need to implements your DuplicationStrategy and to integrate it with the existent code.
import net.smartlab.web.*; import net.smartlab.web.registry.*; public class YourBusinessDeduplicationStrategy implements DeduplicationStrategy { public DeduplicationCode digest(Entity entity){ //Insert here your code to digest the entity } public Criteria getCriteria(Criteria criteria, DeduplicationCode code) throws HibernateException{ //Insert here your code to get a right hibernate criteria. } }