org.kuali.student.r2.common.helper
Class EntityMergeHelper<E,INFO>

java.lang.Object
  extended by org.kuali.student.r2.common.helper.EntityMergeHelper<E,INFO>
Type Parameters:
E - The entity being merged into.
INFO - the dto providing the data to be merged.

public final class EntityMergeHelper<E,INFO>
extends Object

Helps perform merge operations that take place when an entity is loaded from the database and then updated from the dto content being provided through the service.

Author:
ocleirig

Nested Class Summary
static interface EntityMergeHelper.EntityMergeOptions<E,INFO>
          Options when merging the entity from the dto.
static class EntityMergeHelper.EntityMergeResult<E>
          The results of a merge are the merged list and the list of orphaned data.
static interface EntityMergeHelper.StringMergeOptions<E>
          Options for merging a list of strings into a list of entities.
 
Constructor Summary
EntityMergeHelper()
           
 
Method Summary
 EntityMergeHelper.EntityMergeResult<E> merge(List<E> entityList, List<INFO> infoList, EntityMergeHelper.EntityMergeOptions<E,INFO> options)
          Performs a Merge of the current entity list from the info list and options provided.
 EntityMergeHelper.EntityMergeResult<E> mergeStringList(List<E> entityList, List<String> stringList, EntityMergeHelper.StringMergeOptions<E> options)
          Merges a simple string list against a persisted list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityMergeHelper

public EntityMergeHelper()
Method Detail

mergeStringList

public EntityMergeHelper.EntityMergeResult<E> mergeStringList(List<E> entityList,
                                                              List<String> stringList,
                                                              EntityMergeHelper.StringMergeOptions<E> options)
Merges a simple string list against a persisted list. We assume that if the string value does not exist then we can delete the item.

Parameters:
entityList - the list of entities
stringList - the list of values
Returns:
the merge results.

merge

public EntityMergeHelper.EntityMergeResult<E> merge(List<E> entityList,
                                                    List<INFO> infoList,
                                                    EntityMergeHelper.EntityMergeOptions<E,INFO> options)
Performs a Merge of the current entity list from the info list and options provided. The results are the list of merged entities and a list of orphaned objects that can be deleted from the database.

Parameters:
entityList - the target list of entities
infoList - the source list of dto info objects.
options - the logic for extracting the keys and creating/merging the entities.
Returns:
the results of the merge.


Copyright © 2004-2012 The Kuali Foundation. All Rights Reserved.