Model fragments

You can divide a model into different physical resources, called fragments, to share parts of a model with multiple users, or to reduce the size of a larger model. Fragments can help you manage a model by providing more manageable sections that maintain the original logical structure. Fragments also provide performance benefits because they only load when their content is needed; this practice is particularly helpful when you load large models. Software development teams often work in parallel by sharing and controlling fragments in a configuration management system, which reduces the number of users working on a single file.

UMLModeler provides APIs that enable users to create or absorb fragments programmatically. UMLModeler.createFragmentSilently(URI, EModelElement, boolean) creates a fragment by moving the specified element from its current resource to a new resource based on the specified URI. The element becomes the root of the fragment.

UMLModeler.absorbFragmentSilently(Resource, boolean) reabsorbs the fragment into its parent resource.

ILogicalResource is a resource that consists of the root resource and its fragments. When you fragment an element into a new physical resource, it still belongs to the same logical resource. You can retrieve an EObject or a Resource's logical resource by using UMLModeler.getLogicalResource(EObject) and UMLModeler.getLogicalResource(Resource) respectively.

ILogicalResource provides several APIs that enables you to work with a fragmented model. You can retrieve its resources by using getAllResources(), getAllLoadedResources(), getModifiedResources() and fragments by using getAllFragments(), getLoadedFragments(). To retrieve a complete hierarchical structure of the logical resource, use getHierarchicalStructure() which returns ILogicalUnit. Each ILogicalUnit is represented by an EMF resource, and provides a method to retrieve its parent and children ILogicalUnits.

The elements that you can fragment include packages, classifiers, and diagrams; you cannot fragment profiles.

For more information about fragments, install the Fragment example.

Legal notices