* @return the update persistence root
*/
protected PersistenceRoot addPersistedComponent(PersistenceRoot root, PersistedComponent component)
{
Map<String, PersistedComponent> components = mapComponents(root);
PersistedComponent previous = components.remove(component.getOriginalName());
if(previous == null)
previous = components.remove(component.getName());
// Add the persisted component
components.put(component.getName(), component);
// Override with some previous information
if(previous != null)
{
// A added component should remain on added
if(previous.getModificationInfo() == ModificationInfo.ADDED
&& component.getModificationInfo() == ModificationInfo.MODIFIED)
component.setModificationInfo(ModificationInfo.ADDED);
// Just remove a previously added component
if(previous.getModificationInfo() == ModificationInfo.ADDED
&& component.getModificationInfo() == ModificationInfo.REMOVED)
components.remove(component.getName());
// Override the name
if(previous.getOriginalName() != null)
component.setOriginalName(previous.getOriginalName());
}
root.setComponents(new ArrayList<PersistedComponent>(components.values()));
return root;
}