Whether setting up a document library for a large organization or modeling a large system with a lot of detailed specification documents, it can be beneficial to organize these externally created documents in a model repository. We'll refer to this kind of model repository as a 'Document Library.'
This script creates Elements in a Package tree that reflects the directory tree structure being imported. It creates a Document Artifact element for each file and links it to the Element.Filename property. In cases where these files are of type .doc or .rtf - they are imported as Linked Documents and stored internally against the Document Artifact Element.
Using Enterprise Architect's traceability features, you can link imported source documents with any other form of documentation derived from them. You can also use Enterprise Architect to help you manage the workflow behind reviewing and publishing these documents. For example, from a source specification document, you might derive user guide documentation or product flyers. As these derived documents are linked to their source, you can define a process for managing how they are created, edited and approved prior to publication. You might use Enterprise Architect's Tagged Values, User (Role-based) Security, Workflow Scripting, Team Review, or Process Modeling features to do this.
You need to have the following installed on your machine:
- Enterprise Architect, version 8.0 or later
- Microsoft Word
How to Use the Script
The attached repository contains a script called "Document Import". Because it is implemented as an Enterprise Architect "Package Script", you can conveniently run it from the Context Menu in Enterprise Architect’s Project Browser.
To run the script:
- Right-click on a Package in the Project Browser
- Select Scripts | Import Documents from the context menu
You will be prompted to select the directory that contains the source documents.
For .doc and .rtf files, the script attempts to open MS Word, convert the document to RTF format and load it into the Element's Linked Document. For other files, the script simply creates an Element and stores the original file path, which can be launched from Enterprise Architect.
After the documents are imported, you can:
- Open a Word or RTF document using the Linked Document editor by pressing Ctrl+Alt+D
- Open the original document in its external application:
- Right-click on an element in the Project Browser
- Select Scripts | Open from the context menu
If your source documents share just one or a couple of formats such as .doc and .pdf, you can use an alternative short-cut that will open the original documents via the application that is registered in Enterprise Architect as a Programming Language editor.
The current script sets each Document Artifact's Language and Filename properties. The Language property is set to “Delphi”. The Filename is set to the full file path of the original document. By setting these two properties, Enterprise Architect will treat the document as a source code file, and enable shortcuts to open the file in an external editor (in this case it could be set as MS Word or OpenOffice).
Enterprise Architect has a source code engineering option for each language that specifies which editor to open for files of that language type. In the attached model, the Delphi Code Language Editor option is set to what is a common file path for a Word installation. You can change this to match your machine settings and favorite word processor via:
Tools | Options | Source Code Engineering | Delphi
You can reset the Editor option to something like:
C:\Program Files (x86)\OpenOffice.org 3\program\swriter.exe
C:\Program Files (x86)\Microsoft Office\OFFICE11\WinWord.exe
Having set this up you can then open the documents using the F10 key.
Note: You could alter the script to accommodate other commonly used document formats such as PDF by assigning these to another Language and altering the Editor path for that Language.