public interface ObjectFragment extends ShareModuleFragment
This fragment is intended to be combined into an EditModuleCommand
instance.
The absolute number of the object can of course not be determined before the command fragment is executed. When attribute values need to be set on
the object within the same command that creates it, the ObjectRef.created(objectFragment)
method can be used to get a reference on the
object before the command is executed, as demonstrated in the following snippet.
ModuleRef module = ModuleRef.qualifiedName("/MyFolder/MyModule"); EditModuleCommand command = new EditModuleCommand(module, TerminationMode.SAVE_AND_CLOSE); CreateObjectFragment fragment = new CreateObjectFragment(); command.add(fragment); // obtain a reference on the object that is going to be created by the command ObjectRef object = ObjectRef.created(fragment); command.add(new SetAttributeValueFragment(object, "Object Heading", "test")); myCommandRunner.run(command);
Once the fragment is executed, the getAbsoluteNumber()
method gives the absolute number of the created object. This can be useful to
reference this object in other commands, later executed to edit this module. Below is a snippet illustrating the usage:
CreateObjectFragment fragment = new CreateObjectFragment(); myCommand.add(fragment); myCommandRunner.run(myCommand); String absoluteNumber = fragment.getAbsoluteNumber(); // the command has been executed, the absolute number is known ... ObjectRef object = ObjectRef.absoluteNumber(absoluteNumber); SetAttributeValueFragment fragment = new SetAttributeValueFragment(object, "Object Heading", "test"); mySecondCommand.add(fragment);
CommandRunner
,
EditModuleCommand
,
ObjectRef.created(ObjectFragment)
Modifier and Type | Method and Description |
---|---|
int |
getAbsoluteNumber()
Returns the absolute number of the object created when executing the command fragment.
|
String |
getDebugDescription()
Returns the debug description associated to this fragment, if any.
|
void |
setDebugDescription(String value)
Associates a debug description to this fragment.
|
String getDebugDescription()
null
if none.setDebugDescription(String)
void setDebugDescription(String value)
This debug description is not used for updating data in DOORS itsef. It is only meant to enhance the error reporting when an execution fails, for a developer to better understand what object failed to get created and for which reason.
A typical example is when creating an Object with rich text attributes having some attachments. Some of those attachments may need to be inserted as OLE objects and the corresponding application may fail at converting the data. In such case the DOORS Object is not yet created and the error message cannot refer to an absolute number for the developer to investigate the issue. This method can be used to associate a debug display for this object, to provide context for clear error reporting, describing the intent of this object or a reference to the resource that leads to this object creation.
value
- the debug description for this fragment.int getAbsoluteNumber()
0
if the fragment has not been execute (and therefore the object has not been created).