Pymerase Docs - ArgoUML for Pymerase

Brandon King
Copyright © California Institute of Technology

Version 0.1.4
Apr 16, 2003


    1.1  Note: What this document is missing
    1.2  Purpose
    1.3  ArgoUML, XMI and Pymerase
    1.4  Naming Conventions
Tutorial: Dvd Example
    2.1  Introduction
    2.2  Step 1 - Getting familiar with ArgoUML
    2.3  Step 2 - Create new class
    2.4  Step 3 - Change name of namespace
    2.5  Step 4 - Change class name
    2.6  Step 5 - Create attributes for Dvd class
    2.7  Step 6 - Add Studio class and attributes
    2.8  Step 7 - Create Association
    2.9  Step 8 - Studio Association End
    2.10  Step 9 - Dvd Association End
    2.11  Step 10 - Save ArgoUML File
Using Pymerase
    3.1  What next?

1  Introduction

1.1  Note: What this document is missing

This document is a work in progress. We decided to release this document in it's current state because it does contain useful information about how to use ArgoUML with Pymerase. It curretly reads as a tutorial and is lacking some details on what not to do. We hope to add more details in the near future, until then I hope you find this document useful.

1.2  Purpose

The purpose of this documentation is to provide the users of Pymerase with enough information so that they can use UML for the design of their schema. This will be accomplished by providing both a description of the information required and a tutorial.

1.3  ArgoUML, XMI and Pymerase

Universal Modeling Language (UML) allows you to draw an Object Model which can then be used in the form of XML Metadata Interchange (XMI) by Pymerase to produce many different types of output using it's pluggable input/output module design. The ParseXMI input module of Pymerase reads in the Object Model and populates the Pymerase API with information that output modules require. Here is a list of just some of the output modules that currently exist and a brief discription.

Output Modules Description
CreateSQL SQL Statements for creating database
CreateDBAPI Python Database API for a given database
CreatePyTkWidgets Python Tkinter GUI Widgets
CreatePyTkDbWidgets Python Tk Database GUI Widgets

For the tutorial part of this document, we explain how to use ArgoUML to create an Object Model that has the information that Pymerase needs for it's output modules. The example will be a very simple Dvd Collection Database. The second example will demonstrate how to use the inheritance features of Pymerase.

Note that Pymerase, in it's current state, does not take advantage of all the features provided by UML. At the same time, UML does not provide all the information you may want to provide to Pymerase. Later, I will go over the features of ArgoUML which are currently used in Pymerase. If you find that UML does not provide all the information, you can use the CreateTableXML output module to create XML files that describes your model. These files can then be read by the parseGenexSchemaXML input module. This will provide you with a way of adding more information to your model.

1.4  Naming Conventions

When it comes to programming, naming conventions vary from programmer to programmer and from situation to situation. In the Java world, it's common to haveThisConvention while databases most commonly have_this_convention. This led to the development of Name Manglers in Pymerase. This allows different naming conventions to be converted to others. Here's a list of a least some of the NameManglers available.

Name Mangler Description
nullMangler Does not convert users naming convention
CapsWord CapitalizesFirstLetterOfEachWord, NoSpaces
underscore_word all_lower_case, underscore_for_seperation
English Word Capitalizes first word and uses spaces for seperation
alllowercasenospaces This is just a horrible naming convention in general, but it also prevents
the name manglers from converting to other name mangling schemes.

In some cases you may find you need to generate code to use with code or a database that uses allowercasenospaces convention. If this is the case, it is possible to get Pymerase to do what you want. It's just a little harder. You can accomplish this by using the nullMangler or creating your own mangler.

2  Tutorial: Dvd Example

2.1  Introduction

Before we jump in to the tutorial, let me describe the model we wish to create. The goal is quickly create a Database, Python DBAPI, and GUI for keeping track of Dvds in a collection. To keep it simple all we will just have two classes in our Dvd Database. The first will be a Dvd class which will contain the title of the movie, the year the movie was released, and a link to a single Studio class. The Studio class will contain the name of the studio which produced the movie. We will allow a Studio have 0 to N Dvds, but will only allow a Dvd to have 0 to 1 Studios.

Note that this may not be the best design for a Dvd Collection Database, but it does get across the point of how to use Pymerase and it will function. We would love to have more example databases or expansions on existing ones. If you would like to contribute, please visit and send a message to the mailing list.

2.2  Step 1 - Getting familiar with ArgoUML

The first step is to open ArgoUML and learn the basic features we will be using in this example. Figure 1 labels some of the buttons which we will use during the tutorial.

Figure 1: Getting Familiar with ArgoUML

2.3  Step 2 - Create new class

The second step is creating the first class. Press the button in Figure 2 to create a new class.

Figure 2: Create new class

2.4  Step 3 - Change name of namespace

Click on the 'Namespace' entry box that contains the text 'untitledModel' as shown in Figure 3. Then change the name from 'untitledModel' to the name of the DBAPI directory you want to use. In this case you would change the name to 'DvdAPI'. If you don't do this, you may have trouble using the generated DBAPI in the current version of Pymerase (CVS Checkout).

The reason behind this, is that we plan to implement packages into pymerase. Packages will allow you to define a particular section of your object model to make it more manageable. Currently, the implementation of Pymerase supports only one package, but that package needs to be named.

Figure 3: Change name of namespace

2.5  Step 4 - Change class name

Click on the class you created in step one and give the class the name 'Dvd' as shown in Figure 4.

Figure 4: Change class name

2.6  Step 5 - Create attributes for Dvd class

Click on the Dvd class and then press the 'Add Attribute' button shown in Figure 5. For the first attribute, the name should be 'title', and the type should be 'String'. For the second attribute, the name should be 'yearReleased', and the type should be 'int'. Your Dvd class should look similar to the one shown in the figure below.

Figure 5: Create attributes for Dvd class

2.7  Step 6 - Add Studio class and attributes

Create a Studio class with a name attribute of type 'String'. It should look similar to Figure 6.

Figure 6: Add Studio class and attributes

2.8  Step 7 - Create Association

Click on the association button shown in the figure below. Then click and hold down the left mouse button on the Dvd class and drag the mouse over the Studio class. Then release the mouse button over the Studio class. If everything went well, it should look like Figure 7.

Figure 7: Create Association

2.9  Step 8 - Studio Association End

Although we have an association, we are not done yet. It is currently set so that a Dvd object can have 1 to 1 Studios and a Studio can have 1 to 1 Dvds. To change this, click on the association. The properties should look similar to the previous figure. Once you've click on the association, you should see two 'Association Ends'. One called 'Dvd[1..1]' and the other 'Studio[1..1]'. Click on 'Studio[1..1]'. In the name entry box, type 'Studio'. This will become the name of the function you will call from a dvd object to get the studio object ( i.e. dvdObj.getStudio() ). Next change the multiplicity from '1..1' to '0..1'. Once you're done, it should look similar to Figure 8.

Figure 8: Studio Association End

2.10  Step 9 - Dvd Association End

Now we need to add similar information to the other end of the association. To do this, click on the association and then click on 'Dvd[1..1]'. Type 'Dvd' into the name entry box and change the multiplicity from '1..1' to '0..*'. Compare your diagram to Figure 9.

Figure 9: Dvd Association End

2.11  Step 10 - Save ArgoUML File

Save you ArgoUML file as 'dvd_example.zargo'.

3  Using Pymerase

3.1  What next?

I had originally intended to make this document into a tutorial on how to use Pymerase. Then I came up with a better example and turned it into the tutorial. This document is called 'Pymerase Docs - LinkDB Tutorial'. It picks up where we have left of here. What that document doesn't cover is the details on using ArgoUML with Pymerase, so I recommend continuing on that document.

If you wish to experiment on your own, I recomend looking at the examples that are included with Pymerase or using the document 'Pymerase Docs - Running Pymerase' as a reference. You are always welcome to e-mail the pymerase-devel mailing list if you need help.

File translated from TEX by TTH, version 2.92.
On 16 Apr 2003, 15:08.