public class CreateObjectFragment
extends com.sodius.mdw.internal.metamodel.doors.io.commands.CreateObjectFragmentImpl
When instantiating this command, an InsertLocation
can be used to determine the location where to insert the created object (e.g.
below another object).
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 module = ModuleRef.qualifiedName("/MyFolder/MyModule"); EditModuleCommand command = new EditModuleCommand(module, TerminationMode.SAVE_AND_CLOSE); CreateObjectFragment fragment = new CreateObjectFragment(); command.add(fragment); myCommandRunner.run(command);
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.
CreateObjectFragment fragment = new CreateObjectFragment(); myCommand.add(fragment); // obtain a reference on the object that is going to be created by the command ObjectRef object = ObjectRef.created(fragment); myCommand.add(new SetAttributeValueFragment(object, "Object Heading", "test")); myCommandRunner.run(myCommand);
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);
This class is not intended to be subclassed by clients but may be instantiated.
CommandRunner
,
EditModuleCommand
,
ObjectRef.created(ObjectFragment)
Constructor and Description |
---|
CreateObjectFragment()
Instantiates a fragment to create a new object in the DOORS formal module,
at top level in the module.
|
CreateObjectFragment(InsertLocation insertLocation)
Instantiates a fragment to create a new object in the DOORS formal module,
at the specified location.
|
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 debugDescription)
Associates a debug description to this fragment.
|
public CreateObjectFragment()
new CreateObjectFragment(InsertLocation.top())
.public CreateObjectFragment(InsertLocation insertLocation)
insertLocation
- the location in the module where to insert the created object.public String getDebugDescription()
ObjectFragment
getDebugDescription
in interface ObjectFragment
getDebugDescription
in class com.sodius.mdw.internal.metamodel.doors.io.commands.CreateObjectFragmentImpl
null
if none.ObjectFragment.setDebugDescription(String)
public void setDebugDescription(String debugDescription)
ObjectFragment
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.
setDebugDescription
in interface ObjectFragment
setDebugDescription
in class com.sodius.mdw.internal.metamodel.doors.io.commands.CreateObjectFragmentImpl
debugDescription
- the debug description for this fragment.public int getAbsoluteNumber()
ObjectFragment
getAbsoluteNumber
in interface ObjectFragment
getAbsoluteNumber
in class com.sodius.mdw.internal.metamodel.doors.io.commands.CreateObjectFragmentImpl
0
if the fragment has not been execute (and therefore the object has not been created).