Prior Work
Last year, we introduced versioning and document-updating for attribute resources; this allows attribute resources to have a “template type” (which roughly corresponds to a set of definitions) and a “template version.” When a template is updated, resources created with previous versions of the template may need to be updated. We provided an “update factory” to help developers implement the update process.
Upcoming Changes
Now, we are focusing on providing new but related functionality: the ability to copy a set of resources. Let’s compare the two processes:
- update a resource
- resource and component UUIDs are preserved (so external references are preserved as much as possible);
- template type is the same, but version number changes.
- only supports attributes at this point.
- copy a resource
- resource and component UUIDs are different (so both copies can be present in the resource manager at the same time);
- template type and version number are identical;
- extends to any type of resource that implements the API.
As part of this change (with a draft MR here), the API for setting/getting a resource’s template type and version are being moved to the base resource class (i.e., any resource that chooses to override the default methods can orovide a template type and version).
This changes also adds methods to the base resource class to do the following:
- clone(): called on a resource A, this will create a new resource B of the same type and (if the template type API is implemented) initialized with the same template but otherwise leaving B empty;
- copyInitialize(): called on an empty resource B, copy user content from A as directed by copy-options passed in. During this process, the copy-option data structure is updated with correspondences between original UUIDs (from A) and their mapping to objects in B with new UUIDs.
- copyFinalize(): called on an initialized resource B, this will complete the copy process by updating any relationship information between copied components (using the map populated in copyInitialize().
These methods allow for multiple resources to be copied at once while maintaining consistent relationships among all of them. For instance if a model resource M has associations from an attribute resource A to its components, copying both A and M (into B and N, respectively) will result in associations between the new resources (B and N). If only A was copied, then both the original and copy (A and B) would refer to components of M.
Future Work
After the draft work above is complete, we hope to use the same methods outlined above to implement “document updating.” That will require some generalization of the update API to (1) handle cases where updaters are available for resources and their components, (2) handle copying data even when template versions are mismatched, and (3) providing access to updaters during the copy process. This work is not yet scheduled.