|
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 ConventionsWhen 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.
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 Example2.1 IntroductionBefore 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 http://pymerase.sf.net/ and send a message to the mailing list.
2.2 Step 1 - Getting familiar with ArgoUMLThe 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.
2.3 Step 2 - Create new classThe second step is creating the first class. Press the button in Figure 2 to create a new class.
2.4 Step 3 - Change name of namespaceClick 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.
2.5 Step 4 - Change class nameClick on the class you created in step one and give the class the name 'Dvd' as shown in Figure 4.
2.6 Step 5 - Create attributes for Dvd classClick 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.
2.7 Step 6 - Add Studio class and attributesCreate a Studio class with a name attribute of type 'String'. It should look similar to Figure 6.
2.8 Step 7 - Create AssociationClick 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.
2.9 Step 8 - Studio Association EndAlthough 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.
2.10 Step 9 - Dvd Association EndNow 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.
2.11 Step 10 - Save ArgoUML FileSave you ArgoUML file as 'dvd_example.zargo'.
3 Using Pymerase3.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. |