public class CreateLinkFragment extends com.sodius.mdw.internal.metamodel.doors.io.commands.CreateLinkFragmentImpl implements ShareModuleFragment
The CreateLinkFragment(LinkRef, LinkKind)
constructor enables to create a fragment that will automatically create the link module, if
it does not already exist by the time the fragment is executed. This can be convenient to avoid having to check for the link module presence before
requesting the link creation, typically when no custom type or attribute needs to be defined in the link module.
For use cases that do not require a specific link module name to be used, the default link module reference can be obtained using
ModuleRef.defaultLinkModule()
. The default link module is configurable in the DOORS client.
This fragment is intended to be combined into an EditModuleCommand
instance.
Below is a snippet illustrating how to use this fragment (see CommandRunner
for a full snippet):
ModuleRef sourceModule = ModuleRef.qualifiedName("/MyFolder/MySourceModule"); ObjectRef sourceObject = ObjectRef.absoluteNumber(1); ModuleRef targetModule = ModuleRef.qualifiedName("/MyFolder/MyTargetModule"); ObjectRef targetObject = ObjectRef.absoluteNumber(5); ModuleRef linkModule = ModuleRef.defaultLinkModule(sourceModule, targetModule); LinkKind linkKind = LinkKind.MANY_TO_MANY_LITERAL; LinkRef link = LinkRef.link(sourceObject, linkModule, targetModule, targetObject); EditModuleCommand command = new EditModuleCommand(sourceModule, TerminationMode.SAVE_AND_CLOSE); command.add(new CreateLinkFragment(link, linkKind)); myCommandRunner.run(command);
This class is not intended to be subclassed by clients but may be instantiated.
CommandRunner
,
EditModuleCommand
,
ModuleRef.defaultLinkModule(ModuleRef, ModuleRef)
Constructor and Description |
---|
CreateLinkFragment(LinkRef link)
Instantiates a fragment to create a new link between two DOORS objects.
|
CreateLinkFragment(LinkRef link,
LinkKind linkKind)
Instantiates a fragment to create a new link between two DOORS objects,
with the specified link mapping for the link module to create on-demand.
|
public CreateLinkFragment(LinkRef link)
The link module is required to already exist by the time this fragment is executed. Use the constructor that takes a LinkKind
as
second parameter if the link module is to be created on-demand by this fragment.
link
- the link to create.CreateLinkFragment(LinkRef, LinkKind)
public CreateLinkFragment(LinkRef link, LinkKind linkKind)
If the referenced link module does not exist by the time this fragment is executed, it is automatically created by this fragment, with the specified link mapping assigned.
link
- the link to create.linkKind
- the link mapping to assign to the link module created on-demand.