// to the item contained already in the model in order not to loose
// relations to any dependent objects that might be contained in
// or referenced by the item
// Get the item that belongs to the model
Item currentItem = getItemByQualifier(argItem.getQualifier(), true);
// Update the model item from the argument item
// Perform a flat copy only, the contained objects will remain the same
try
{
// copyFrom will overwrite the parent model information; save it
Model currentModel = currentItem.getModel();
// Copy the item data
currentItem.copyFrom(argItem, Copyable.COPY_DEEP);
// Repair hiearchy and establish links
currentItem.setModel(currentModel);
currentItem.maintainReferences(ModelObject.RESOLVE_GLOBAL_REFS | ModelObject.RESOLVE_LOCAL_REFS);
}
catch (CloneNotSupportedException e)
{
throw new ModelException("Clone", "Cannot update component '" + currentItem.getQualifier() + "': " + e.getMessage());
}
// Save the item file
saveItemToStore(currentItem);
// Instantiate classes referenced by the item if we are expected to
if (isInstantiateItems())
{
currentItem.instantiate();
}
}