public void add(Work work) {
//TODO optimize by getting rid of dupe works
if ( work instanceof UpdateWork ) {
//split in 2 to optimize the process (reader first, writer next
queue.add( new DeleteWork( work.getId(), work.getEntity() ) );
queue.add( new AddWork( work.getId(), work.getEntity(), work.getDocument() ) );
}
else {
queue.add( work );
}