Writing images and OLE objects

Important Note: Writing data in DOORS is a non trivial task when it comes to determine exactly what should be written and how, notably when an update of existing data is to be performed.
Rather than using the model writer, you are now strongly encouraged to use the commands framework, which allows a Java programmer to control the update of DOORS data with fine grained interactions.

Writing Images

An image can be inserted in a DOORS object. Here are the supported image file formats:

Here is a sample code that inserts an image in a DOORS Object:

    import java.awt.image.BufferedImage;
    import javax.imageio.ImageIO;
    import com.sodius.mdw.corext.model.ImportedImage;
    import com.sodius.mdw.metamodel.doors.*;
    com.sodius.mdw.metamodel.doors.Object object = ...;
    ImportedImage importedImage = ImportedImage.importFile(imageFile, null);

Writing OLE Objects

OLE objects can be inserted in a DOORS Object Text. In that case the Object.objectText attribute must contains HTML tags that references the OLE objects, e.g.:

    <html><body><p><object data="path_to_ole_object"/></p></body></html>

Here is a sample code that sets an OLE Object Text:

    import com.sodius.mdw.core.model.RichText;
    import com.sodius.mdw.metamodel.doors.*;
    com.sodius.mdw.metamodel.doors.Object object = ...;
    object.setObjectText(RichText.valueOf("<html><body><p><object data=\"path_to_ole_object\"/></p></body></html>"));

When writing the model into DOORS, an AttachmentResolver is used to retrieve the physical location of OLE objects files to be inserted in DOORS:

    import com.sodius.mdw.metamodel.doors.*;
    import com.sodius.mdw.metamodel.doors.richtext.AttachmentResolver;
    import com.sodius.mdw.metamodel.doors.richtext.RichTextUtils;
    File myFolder = new File(<folder containing OLE object files>);
    AttachmentResolver resolver = RichTextUtils.createAttachmentResolver(myFolder);
    Map<String, Object> options = new HashMap<String, Object>();
    options.put("doors.attachmentResolver", resolver);
    myDoorsModel.write("Application", null, options);

Related reference
Writing DOORS data