12.07.2015 Views

XMI for AllFusion Component Modeler tutorial ... - SupportConnect

XMI for AllFusion Component Modeler tutorial ... - SupportConnect

XMI for AllFusion Component Modeler tutorial ... - SupportConnect

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Advantage JoeIntegrating Advantage Joe with <strong>AllFusion</strong><strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export3.1


This documentation and related computer software program (hereinafter referred to as the “Documentation”) is <strong>for</strong>the end user’s in<strong>for</strong>mational purposes only and is subject to change or withdrawal by Computer AssociatesInternational, Inc. (“CA”) at any time.This documentation may not be copied, transferred, reproduced, disclosed or duplicated, in whole or in part, withoutthe prior written consent of CA. This documentation is proprietary in<strong>for</strong>mation of CA and protected by the copyrightlaws of the United States and international treaties.Notwithstanding the <strong>for</strong>egoing, licensed users may print a reasonable number of copies of this documentation <strong>for</strong>their own internal use, provided that all CA copyright notices and legends are affixed to each reproduced copy. Onlyauthorized employees, consultants, or agents of the user who are bound by the confidentiality provisions of thelicense <strong>for</strong> the software are permitted to have access to such copies.This right to print copies is limited to the period during which the license <strong>for</strong> the product remains in full <strong>for</strong>ce andeffect. Should the license terminate <strong>for</strong> any reason, it shall be the user’s responsibility to return to CA the reproducedcopies or to certify to CA that same have been destroyed.To the extent permitted by applicable law, CA provides this documentation “as is” without warranty of any kind,including without limitation, any implied warranties of merchantability, fitness <strong>for</strong> a particular purpose ornoninfringement. In no event will CA be liable to the end user or any third party <strong>for</strong> any loss or damage, direct orindirect, from the use of this documentation, including without limitation, lost profits, business interruption,goodwill, or lost data, even if CA is expressly advised of such loss or damage.The use of any product referenced in this documentation and this documentation is governed by the end user’sapplicable license agreement.The manufacturer of this documentation is Computer Associates International, Inc.Provided with “Restricted Rights” as set <strong>for</strong>th in 48 C.F.R. Section 12.212, 48 C.F.R. Sections 52.227-19(c)(1) and (2) orDFARS Section 252.227-7013(c)(1)(ii) or applicable successor provisions.© 2003 Computer Associates International, Inc. (CA)All trademarks, trade names, service marks, and logos referenced herein belong to their respective companies.This product includes software developed by the Apache Software Foundation (http://www.apache.org); (c) 1999The Apache Software Foundation. All rights reserved. THE APACHE SOFTWARE IS PROVIDED "AS IS" ANDANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. INNO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, ORPROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE OF THE APACHE SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF SUCH DAMAGE.


ContentsChapter 1: Introduction ......................................................... 1-1Estimated Completion Time ..................................................................................................................................1-1Introduction .............................................................................................................................................................1-1<strong>XMI</strong> Object Mapping .......................................................................................................................................1-2Prerequisites......................................................................................................................................................1-2Document Conventions...................................................................................................................................1-2Chapter 2: Importing <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>Packages ........................................................................... 2-1Estimated Completion Time ..................................................................................................................................2-1Export Package from <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>...................................................................................2-1Use the <strong>XMI</strong> Import Wizard ..................................................................................................................................2-2Summary ..................................................................................................................................................................2-3Chapter 3: Refining the Imported <strong>Component</strong>Specification....................................................................... 3-1Estimated Completion Time ..................................................................................................................................3-1Refine the Class Specifications ..............................................................................................................................3-1Modify the Attributes ......................................................................................................................................3-1Modify the Identifiers......................................................................................................................................3-2Modify the Association ...................................................................................................................................3-3Review the Interface Specifications and Transition Classes..............................................................................3-5Create a Transition Class.................................................................................................................................3-6Review the Operations ....................................................................................................................................3-6Create an Interface Type Model ............................................................................................................................3-8Create a <strong>Component</strong> Specification........................................................................................................................3-8Trans<strong>for</strong>m the <strong>Component</strong> Specification .............................................................................................................3-9Contentsiii


Create a <strong>Component</strong> from a Java Class..............................................................................................................3-11Remove the Transition Objects............................................................................................................................3-11Summary ................................................................................................................................................................3-11Chapter 4: Creating Database Objects and PersistenceClasses................................................................................4-1Estimated Completion Time..................................................................................................................................4-1Create Database Table Objects and Persistence Classes ....................................................................................4-1Create the Data Definition Language File ...........................................................................................................4-2Create a Cloudscape Database and a Table.........................................................................................................4-2Summary ..................................................................................................................................................................4-3Chapter 5: Creating Business Logic ......................................5-1Estimated Completion Time..................................................................................................................................5-1Define Business Logic <strong>for</strong> the Implementation Class.........................................................................................5-1Set Import Statements .....................................................................................................................................5-1Detailing the createLocation Method............................................................................................................5-2Detailing the getLocationList Method ..........................................................................................................5-2Summary ..................................................................................................................................................................5-3Chapter 6: Build and Test .......................................................6-1Estimated Completion Time..................................................................................................................................6-1Build a <strong>Component</strong> Project....................................................................................................................................6-1Create a Web Application......................................................................................................................................6-2Build the Web Application Project .......................................................................................................................6-2Test the <strong>Component</strong>................................................................................................................................................6-3Summary ..................................................................................................................................................................6-4Chapter 7: Exporting to <strong>AllFusion</strong> <strong>Component</strong><strong>Modeler</strong> ..............................................................................7-1Estimated Completion Time..................................................................................................................................7-1Use the <strong>XMI</strong> Export Wizard ..................................................................................................................................7-1Import a Package to <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> ........................................................................................7-2Summary ..................................................................................................................................................................7-2Tutorial Summary...................................................................................................................................................7-3ivAdvantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Chapter1 IntroductionEstimated Completion TimeAllow yourself approximately 2 hours to complete this <strong>tutorial</strong>.IntroductionThe Advantage Joe product provides two wizards, <strong>XMI</strong> Import Wizard and <strong>XMI</strong>Export Wizard, to integrate the UML models developed by <strong>AllFusion</strong><strong>Component</strong> <strong>Modeler</strong> and Rational Rose® with the Advantage Joe product.This model integration technique is based on the <strong>XMI</strong> 1.1 and UML 1.3standards. A UML model is designed in <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> orRational Rose. When the modeling ef<strong>for</strong>ts are complete, the model is thenexported from the modeling tool to an <strong>XMI</strong> 1.1 /UML 1.3 file represented inXML <strong>for</strong>mat. You then execute the <strong>XMI</strong> Import Wizard and import the <strong>XMI</strong> fileinto an Advantage Joe model. EJB component development then proceeds usingthe Advantage Joe product.You can also choose to use the <strong>XMI</strong> Export Wizard to export an Advantage Joecomponent specification model to <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> or RationalRose.This <strong>tutorial</strong> introduces you to a process to follow when you have a UML modelcreated in the <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> product that didn’t use acomponent based development process. The <strong>tutorial</strong> provides instructions <strong>for</strong>:• Exporting a package from <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>• Using the <strong>XMI</strong> Import Wizard to import the package to an Advantage Joemodel• Refining the specification modelIntroduction 1–1


Introduction• Trans<strong>for</strong>ming the specification to implementation• Creating the persistence classes• Defining the business logic• Building and testing a Web application project• Using the <strong>XMI</strong> Export Wizard<strong>XMI</strong> Object MappingThough <strong>XMI</strong> is a standard, there are variations. The Advantage Joe wizard mapsthe UML objects in <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> to the Advantage JoeIn<strong>for</strong>mation Model objects as much as possible. Mapped objects includecomponents, classes, attributes, operations, associations, interfaces, actors, anduse cases. Some objects are not mapped however:• Objects that support multiple inheritance. The Java language does notsupport multiple inheritance. As a result, the <strong>XMI</strong> Import Wizard does notimport objects that have or support multiple inheritance.• Non-standard and “proprietary” <strong>XMI</strong> objects are not imported, and arereported in the wizard’s Status panel.• The current UML 1.3 DTD does not support import/export of UML notation<strong>for</strong> diagrams. Objects from the diagrams are imported where possible, butthe diagram elements themselves are not imported.PrerequisitesUsing the procedures described in this paper assumes that you have installed<strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> version 5.0 and have access to the Car RentalSystem workspace that is installed with the product.Document ConventionsThe instructions in this <strong>tutorial</strong> guide you through a sequence of steps toaccomplish each task. The typographic conventions include:• Boldface type calls attention to items you click or manipulate with themouse, such as menu items or buttons.• Courier type font identifies text that you type in a field, the name of akeyboard key, or message text displayed by a window or dialog box.• Italic type identifies the names of objects, fields, windows or dialog boxes,and wizards or tools.1–2 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Introduction• refers to the installation locationof the Advantage Joe product. The default location is:\CA\AdvantageJoe.Note: Throughout this <strong>tutorial</strong>, the term “click” refers to pressing the mouse’sprimary button. The term “right-click” refers to pressing the mouse’ssecondary button, usually on an object in the Project Tree or in a diagram.Introduction 1–3


Introduction1–4 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Chapter2Importing <strong>AllFusion</strong> <strong>Component</strong><strong>Modeler</strong> PackagesEstimated Completion TimeAllow yourself approximately 20 minutes to complete this chapter.Export Package from <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>Be<strong>for</strong>e you can import a component specification with the Advantage Joe wizard,you will need to create an export package in the <strong>AllFusion</strong> <strong>Component</strong><strong>Modeler</strong> software.1. Start <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> and open the existing workspace CarRental System.2. Select menu File <strong>XMI</strong> Export, the Export dialog displays.3. Click on Car Rental Analysis Model from the Select the package to be exportedlist.4. Set the directory path to an existing folder where you want to place theexported model. For example, you could specify:C:\<strong>XMI</strong>fromACM5. Select all the check box options, Export contained packages, <strong>XMI</strong> 1.1Compatible, and Create single file. Click the Export button to start theexport process.6. Open Microsoft Windows Explorer when the export process completes, andexpand the folder that you specified in step 4. You will see a new foldernamed Car Rental Analysis Model. This folder contains the file that you willuse in the next section with the Advantage Joe <strong>XMI</strong> Import Wizard.7. Exit the <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> product.Importing <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> Packages 2–1


Use the <strong>XMI</strong> Import WizardUse the <strong>XMI</strong> Import Wizard1. Start the Advantage Joe software and create a new model by selecting themenu File 2. Navigate to the directory:New…. The New…dialog box displays.\models.3. Type the model name JoeCarRental.jim in the File name field and clickSave.4. Select File Import from <strong>XMI</strong>…. Click Next when the <strong>XMI</strong> ImportWizard - Welcome panel displays. The Select the <strong>XMI</strong> File to Import paneldisplays.5. Type the location of the <strong>XMI</strong> file that was generated by <strong>AllFusion</strong><strong>Component</strong> <strong>Modeler</strong>:C:\<strong>XMI</strong>fromACM\Car Rental Analysis Model\Car Rental Analysis Model.xmlOr, you can click Browse to navigate to, and select, the <strong>XMI</strong> file, then clickOpen.6. Click Finish to start the import process.7. Verify that no error message displays on the Status panel when the importprocess completes, and then click Close.The <strong>XMI</strong> Import Wizard converts most of the objects used in the analysismodeling of <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> into an Advantage Joe model,such as, components, classes, interfaces, operations, attributes, associations,use cases, actors and data types. Please refer to the online help <strong>for</strong> moredetail about the <strong>XMI</strong> Import Wizard. Figure 2-1 shows a comparison of themodel in the <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> Project Workspace and theAdvantage Joe Project Tree.2–2 Advantage Joe Message Driven Beans


SummaryFigure 2-1 Model Object Comparison<strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> 5.0 TreeAdvantage Joe 3.1 Project TreeSummaryIn this chapter, you:• Exported a model from <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> to create the XML fileto be imported by the software• Created a new Advantage Joe model• Imported a component specification using the <strong>XMI</strong> Import WizardImporting <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> Packages 2–3


Summary2–4 Advantage Joe Message Driven Beans


Chapter3Refining the Imported <strong>Component</strong>SpecificationEstimated Completion TimeAllow yourself approximately 30 minutes to complete this chapter.Refine the Class SpecificationsAfter you import the Car Rental Analysis Model to an Advantage Joe model, youwill need to modify it and make some necessary updates be<strong>for</strong>e you trans<strong>for</strong>mthe specification model into a component implementation model.In the following procedures, you will focus on reviewing the Location class to adddetailed in<strong>for</strong>mation that is needed <strong>for</strong> the implementation steps later.Modify the AttributesYou need to review the precision, scale, and optionality in<strong>for</strong>mation <strong>for</strong> eachattribute. This in<strong>for</strong>mation is used to generate the SQL codes <strong>for</strong> creating a tableor rows and columns, and to generate the Java application to test your businessmethods.1. Right-click on the Location class in the Project Tree and selectProperties…. The Location – Class Properties dialog displays.2. Click the Attributes button to view the attributes in<strong>for</strong>mation of theLocation class. For the Location class, all of the attributes are text, mandatory,and have a default precision length of 255.3. Update the precision length by clicking on the Precision field <strong>for</strong> eachattribute and type in the number as shown in Figure 3-1.Refining the Imported <strong>Component</strong> Specification 3–1


Refine the Class SpecificationsFigure 3-1 Attributes View of Location ClassModify the IdentifiersThe unique identifier of a class specification becomes the primary key of the tableduring persistence generation. In this section, you’ll add a unique identifier tothe Location class.1. Click the Identifiers button, then click the Add entry icon by theIdentifiers list. Type LocationID as the Identifier Name.2. Select Name from the Available Attributes/Roles list and press the Moveleft icon. Your Identifiers View should resemble Figure 3-2.3–2 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Refine the Class SpecificationsFigure 3-2 Identifiers View of Location classModify the AssociationThe associations between persistent classes will be trans<strong>for</strong>med as referencesbetween tables. You will modify the associations of the Location class and deletethe associations that can’t be made persistent.1. Click the Associations button to see the associations of the Locationclass.2. Click on the null(Location, Car) under the Signature column and press theChange Entry icon to display the Association Properties dialog.3. Click the Association Name field and type owns. The properties of associationowns should resemble Figure 3-3.Refining the Imported <strong>Component</strong> Specification 3–3


Refine the Class SpecificationsFigure 3-3 The “owns” Association Properties Dialog4. Click OK to return to the Location – Class Properties dialog.5. Change the association name directly from the Location – Class Propertiesdialog by clicking the Association Name field of the null(RentalAgreement,Location) row. Type picks up at as the association name.6. Click the Association Name field of the null(Reservation, Location) row and typepicks up at as the association name.7. Since the RentalShop class is not a persistible class in this model, you willdelete the association between them by clicking on the null(RentalShop,Location) association and then click the8. Click the Apply button.Delete entry icon.9. The final result of your changes to the Location class Associations View shouldresemble Figure 3-4. Click OK to exit the Location – Class Properties dialog.3–4 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Review the Interface Specifications and Transition ClassesFigure 3-4 Associations View of Location ClassReview the Interface Specifications and Transition ClassesFor the development process that the Advantage Joe product uses, interfacespecifications define behavior as a collection of operations. But in other UMLmodeling tools such as <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>, a class may be used <strong>for</strong>this purpose. In the Car Rental Analysis Model of <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>,the RentalShop class owns all of the public operations that will be available to theclients in the model. You will need to copy the RentalShop class into a transitionclass. This transition class will then be trans<strong>for</strong>med and used as a componentimplementation object that contains the method stubs <strong>for</strong> the operations.During this process, you can also review the structure of the businesscomponents that you’re implementing. For example, the RentalShop class can beimplemented by several smaller scale components, such as, the Customer<strong>Component</strong>, the Rental <strong>Component</strong>, the Car <strong>Component</strong>, and the Location<strong>Component</strong>. In this exercise, you will only focus on implementing the Location<strong>Component</strong>.If you used the component based development process in <strong>AllFusion</strong> <strong>Component</strong><strong>Modeler</strong> during the analysis phase and you used interfaces to define theoperations of the classes, you can skip the following section, Create a TransitionClass, and proceed to the Review the Operations section.Refining the Imported <strong>Component</strong> Specification 3–5


Review the Interface Specifications and Transition ClassesCreate a Transition ClassYou will copy the Rental Shop class to a new class named Location<strong>Component</strong>, anddelete the operations that won’t be implemented by the Location<strong>Component</strong>.1. Right-click on RentalShop in the Project Tree and select Copy.2. Right-click on Car Rental Analysis Model andthen select Paste, a new class RentalShop1 is inserted in the ProjectTree.3. Right-click on RentalShop1 and select Rename, typeLocation<strong>Component</strong> and then press Enter.4. Expand the Location<strong>Component</strong>. Select all the operations by clicking thefirst operation and then press the Shift key and simultaneously click thelast operation.5. Press and hold the Ctrl key and click on these operations to de-select them,while the entire list of operations of Location<strong>Component</strong> is highlighted:• getReturnLocationList( )• createLocation( )• getLocationList( )6. Right-click on any place of the highlighted operations and select Delete.Click the Yes button on the Confirm Delete dialog.7. Right-click on Car Rental Analysis Model andselect Create Interfaces Interface Specification. Type ITempas the name of the interface and press Enter to create a temporary interface.The Specification to Implementation Wizard requires that the componentspecification to be implemented offer at least one interface. You will removethis transition object later in the <strong>tutorial</strong>.Review the OperationsFor the implementation, you may discover that the required input and output ofan operation is different from the earlier analysis phase. The createLocationoperation should contain one parameter that accepts an instance of the Locationclass and returns a text message to report the creation status. The getLocationListoperation should return an array of Location class.3–6 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Review the Interface Specifications and Transition ClassesNote: If you skipped the Create a Transition Class section because you used theinterfaces to define the operations in your analysis model in <strong>AllFusion</strong><strong>Component</strong> <strong>Modeler</strong>, then you will need to review the operations of the interfacein this section.1. Expand Location<strong>Component</strong> in the Project Tree, right-click oncreateLocation, and selectProperties….2. Set the Result Type to text and the Precision to 100.3. Click the Add entry icon next to the Parameters list and type the nameinLocation. Set the Type drop down list to Type or Array, then navigate toand select theCar Rental Analysis Model.Location class.4. Click OK to exit the Data type Selection dialog. The result should resembleFigure 3-5.Figure 3-5 createLocation – Operation Properties5. Click OK to exit createLocation – Operation Properties dialog box.6. Right-click on getLocationList in the Project Tree and selectProperties….7. Drop down the Result Type list and select Type or Array….Refining the Imported <strong>Component</strong> Specification 3–7


Create an Interface Type Model8. Navigate to and select the Car Rental Analysis Model.Location classand click the Collection Type drop down list to select array.9. Click OK in both the Data Type Selection and Operation Properties dialogboxes.Create an Interface Type ModelAn Interface Type Model defines the type model <strong>for</strong> a specific interface. One ofits main purposes is to define which class specifications are part of a component.When you run the Specification to Implementation Wizard during theimplementation, the wizard trans<strong>for</strong>m the classes you included in the InterfaceType Model into Java classes in the implementation model.1. Right-click on the ITemp interface (or the interface that you convertedfrom <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>) and selectDiagram.Interface Type Model2. Drag the Location<strong>Component</strong> and Location classes from the ProjectTree to the diagram.3. Close and save the diagram.Create a <strong>Component</strong> SpecificationA component specification acts as a “container” <strong>for</strong> analysis objects, interfacesand relationships.1. Right-click the Car Rental Analysis Model in theProject Tree and select Create, <strong>Component</strong>s, <strong>Component</strong>Specification….2. Name the new component specification Temp<strong>Component</strong> and press Enter.3. Right-click on Temp<strong>Component</strong> and select Properties….3–8 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Trans<strong>for</strong>m the <strong>Component</strong> Specification4. Click the Add entry icon by the Offers interfaces list. On the InterfaceSelection dialog, expand and select Car Rental Analysis Model.ITempand click OK twice to exit the Interface Selection and <strong>Component</strong> SpecificationProperties dialogs. The Temp<strong>Component</strong> is a transition object in thisexercise because this analysis model wasn’t originally built with acomponent based development process. You will delete this Temp<strong>Component</strong>once it is trans<strong>for</strong>med to a <strong>Component</strong> implementation object in a latersection.Trans<strong>for</strong>m the <strong>Component</strong> SpecificationNow your specification model is complete, you will use the Specification toImplementation Wizard to trans<strong>for</strong>m the specification objects to implementationobjects.1. Right-click on Temp<strong>Component</strong> and select ImplementSpecification….2. Click the Next button in the Welcome panel to displays the Select Packagepanel.3. Select the System Package and then click the New Package icon.Type the name com.myCarRentalShop.location and press Enter. YourSpecification to Implementation Wizard should resemble Figure 3-6.Refining the Imported <strong>Component</strong> Specification 3–9


Trans<strong>for</strong>m the <strong>Component</strong> SpecificationFigure 3-6 Specification to Implementation Wizard – Select Package4. Click Finish <strong>for</strong> the wizard to begin generating the implementation objects.When the trans<strong>for</strong>mation process is complete, click the Close button.5. Contract the Car Rental Analysis Model in theProject Tree.6. Expand the com.myCarRentalShop.location package to see theimplementation objects that were generated. Note that the wizardautomatically generated the public getter/setter methods <strong>for</strong> each LocationJava class attribute. The expanded Project Tree should resemble Figure 3-7.3–10 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Trans<strong>for</strong>m the <strong>Component</strong> SpecificationFigure 3-7 Post-Trans<strong>for</strong>mation Implementation StructureRefining the Imported <strong>Component</strong> Specification 3–11


Create a <strong>Component</strong> from a Java ClassCreate a <strong>Component</strong> from a Java ClassNow that you have the Location<strong>Component</strong> Java class, you will use the <strong>Component</strong>Wizard to create a component implementation object and an interface that willcontain the method stubs.1. Right-click on the Location<strong>Component</strong> Java class and chooseGenerate <strong>Component</strong>….2. Click Next on the <strong>Component</strong> Wizard – Welcome panel.3. Leave the Offers Interfaces field blank and the wizard creates an interface <strong>for</strong>you that contains all the public methods of the Location<strong>Component</strong> Java class.Click Finish to start the process, and click Close when the wizard completes.4. Note that you now have a newly created Location<strong>Component</strong> componentimplementation object and an ILocation<strong>Component</strong> Java interface. Expand theILocation<strong>Component</strong> Java interface object to view the operation stubs.Remove the Transition Objects1. Right-click on com.myCarRentalShop.location.Temp<strong>Component</strong> andselect Delete, click Yes on the Confirm Delete dialog box.2. Right-click the com.myCarRentalShop.ITemp Java interface and selectDelete, click Yes on the Confirm Delete dialog box.3. You now have the desired implementation structure.SummaryIn this chapter, you:• Refined the component specification• Created initial implementation objects from the component specificationusing the Specification to Implementation Wizard• Created a component from a Java class• Removed transition objects3–12 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Chapter4Creating Database Objects andPersistence ClassesEstimated Completion TimeAllow yourself approximately 15 minutes to complete this chapter.Create Database Table Objects and Persistence ClassesThe Persistence Generation Wizard enables your component to access data in aDBMS by generating supporting classes and component framework classes thatsupport Java Database Connectivity (JDBC).In this section you will run the Persistence Generation Wizard to generate a tableobject called Location that will be used in a later section to generate DDLstatements. The Persistence Generation Wizard also generates a Java package calledpersist that contains factory classes, interfaces, and peer classes to persist data to adatabase using JDBC.1. Navigate to the com.myCarRentalShop.location.Location<strong>Component</strong>package in the Project Tree and then right-click to selectPersistence….2. Click the Next button when the Welcome panel displays.Generate3. Ignore the warnings in the Invalid Selections(s) panel because theLocation<strong>Component</strong> class will not be made persistent. Click Next to displaythe Select Package <strong>for</strong> Tables panel.4. Click Next to confirm the table objects generation into the DBTablespackage.5. Click Next in the Select Classes panel to accept the Location class being storedin the database.Creating Database Objects and Persistence Classes 4–1


Summaryand then press Enter. (The single quotes and semicolon are parts of thecommand syntax.) The ij utility will not execute until you type the semicolonand press the Enter key. After this command executes successfully, the ij>prompt displays: ij(CONNECTION1)>.4. Type the command:RUN '\source\ddl\Location.sql';replacing the directory token with the actual location, and then press Enter.Executing this command creates the Location table in the RentalDB database.5. Exit the ij utility by typing exit; and then press Enter.6. Stop the Cloudscape database process with the command syntax:\j2sdkee1.3.1\bin\cloudscape -stopSummaryIn this chapter, you:• Used the Persistence Generation Wizard to create persistence classes anddatabase table objects• Used the DDL Generation Wizard to create data definition language to createSQL statements <strong>for</strong> a table in a Cloudscape database• Used the ij utility to create a Cloudscape database to contain the LocationtableCreating Database Objects and Persistence Classes 4–3


Summary4–4 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Chapter5Creating Business LogicEstimated Completion TimeAllow yourself approximately 15 minutes to complete this chapter.Define Business Logic <strong>for</strong> the Implementation ClassIn this section you will modify the Location<strong>Component</strong> implementation class. Youwill also write the Java logic in createLocation method to create a record <strong>for</strong> theLocation table, and getLocationList method to read a list of all Locations from thedatabase. The Advantage Joe product offers several features designed to facilitateyour coding ef<strong>for</strong>ts. You will use two of these features, Smart Expansions andSmart Macros, in this chapter.Set Import Statements1. Right-click on Location<strong>Component</strong> implementation object and selectEdit….2. Use the following code listing to verify the presence of, or to add, the importstatements to the beginning of the component implementation class whenthe Editor window opens:package com.myCarRentalShop.location;import java.io.Serializable;import com.cai.joe.component.I<strong>Component</strong>;import com.cai.joe.component.I<strong>Component</strong>Context;import com.cai.joe.component.*;import com.myCarRentalShop.location.persist.*;import java.util.Vector;import java.util.Enumeration;Creating Business Logic 5–1


Define Business Logic <strong>for</strong> the Implementation ClassDetailing the createLocation Method1. Drop down the method list at the top of the Editor window and select thecreateLocation(Location) method. The Editor positions the cursor at thebeginning of this method.2. Create a blank line in the createLocation method stub by positioning thecursor after the opening brace and then pressing the Enter key. Right-clickat the cursor position and select Smart Expansions Persistence pCreate. A Smart Expansions dialog box displays prompting you <strong>for</strong> the nameof the class you want to create.3. Type Location in the Enter the name of the class you want to create field andclick OK. The pCreate expansion inserts the necessary code and commentsinto the Editor window. Note that the "create" logic calls a method namedmapFromLocationToPersistentLocation(inLocation).4. Change the return ""; statement at the end of the createLocation(Location)method to:return "Location created successfully";5. Insert a blank line after the ending brace of the createLocation(Location)method so that you can create themapFromLocationToPersistentLocation(inLocation) method. To do this, positionthe cursor after the closing brace and press the Enter key. Press Ctrl-M toinvoke the GenerateMapping macro. The Generate mapping code dialog boxdisplays to prompt you <strong>for</strong> the names of the classes you want to map.6. Type Location in the From Class field and press the Tab key. The To Classfield is automatically set to PersistentLocation. Keep the Generate inversemapping checkbox selected and click the OK button. The macro generates themapFromLocationToPersistentLocation(Location fromLocation) method andmapFromPersistentLocationToLocation() method that will be called bygetLocationList() method.Detailing the getLocationList Method1. Drop down the method list at the top of the Editor window and select thegetLocationList() method.2. Create a blank line in the getLocationList() method stub by positioning thecursor after the opening brace and then pressing the Enter key. Delete theline that reads return null;.3. Indent the cursor correctly between the opening and closing brace and clickthe Persistence tab on the (toolbar) palette and then click pList. A SmartExpansions dialog box displays prompting you <strong>for</strong> the name of the class youwant to list.5–2 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Summary4. Type Location in the Enter the name of the class you want to list field and clickOK. The pList expansion inserts the necessary code and comments.5. Close the Editor window, select the Save to model radio button and thenclick the Yes button.SummaryIn this chapter, you:• Used the pCreate Smart Expansion to add code <strong>for</strong> the createLocation( )method• Used the GenerateMapping Smart Macro to create the mapping codeautomatically between the persistent classes <strong>for</strong> the createLocation( ) method• Used the pList Smart Macro to create the logic <strong>for</strong> the getLocationList( )methodCreating Business Logic 5–3


Summary5–4 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Chapter6Build and TestEstimated Completion TimeAllow yourself approximately 20 minutes to complete this chapter.Build a <strong>Component</strong> Project1. Right-click on com.myCarRentalShop.location package on the ProjectTree and select Project New….2. Click OK to accept the default name locationProject and the default packagingCreate Jar option.3. Right-click on the locationProject from the Project Tree and selectProperties…. The Project Properties dialog displays.4. Click the Standalone Properties view from the Views panel.5. Set the JDBC URL value to:jdbc:cloudscape:;databaseName=:\\\\j2sdkee1.3.1\\cloudscape\\RentalDB;create=true;autocommit=falseThe double back slash character (“\\”) is the correct delimiter <strong>for</strong> directoriesin this command and must be used <strong>for</strong> correct operation.6. Set the JDBC Driver value to:COM.cloudscape.core.JDBCDriver7. Accept all of the other default values and click OK.8. Right-click on the locationProject and select Build to start the BuildWizard.9. Click the Finish button to accept all defaults and execute the wizard.Build and Test 6–1


Create a Test Harness10. Click the Close button when the wizard completes.Create a Test HarnessYou have generated and built the component. Now you need to generate a Javaapplication to test it. To facilitate this, you will use the Test Harness Wizard togenerate your Java application.1. Right-click on Location<strong>Component</strong> implementation object from theProject Tree and selectGenerate Test Harness….2. When the Test Harness Wizard starts, click the Next button if the Welcomepanel displays. The Select Methods panel displays.3. Select the createLocation(Location) method. Press and hold the Ctrl keyand then select the getLocationList( ) method. You do not need to selectgetReturnLocationList( ) since its business logic wasn’t implemented. ClickNext to display the Select How To Invoke Method panel.4. Select the Invoke the method directly option and then click Next to displaythe Select Package For Java Classes penel.5. Click the Finish button to accept the default location,com.myCarRentalShop.testharness, and to execute the wizard.6. Click the Close button when the wizard completes.Build the Test Harness ProjectThe Test Harness classpath needs to reference the jar <strong>for</strong> your component inorder to establish proper data transfer. In this step, you will create a project tocontain the Test Harness and then modify its properties be<strong>for</strong>e building it.1. Right-click on the testharness Java package from the Project Tree and selectProject New….2. Click OK to accept the default name testharnessProject and the defaultpackaging Create Jar option.3. Right-click on the testharnessProject from the Project Tree and selectProperties….4. Click on the Edit Project Classpath icon by the Classpath field. Click theAdd Entry icon and then select:\\output\locationProject\location.jarAdd Jar/Zip. Navigate to and select:6–2 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Test the <strong>Component</strong>and then click the Add button.5. Click OK twice to exit the Edit Classpath and testharnessProject – ProjectProperties dialogs.6. Right-click on the testharnessProject from the Project Tree and selectBuild to start the Build Wizard.7. Click the Finish button to accept all defaults and execute the wizard.8. Click the Close button when the wizard completes.Test the <strong>Component</strong>You are now ready to use the Java application generated by the Test HarnessWizard to test your component.1. Expand all the packages in the testharnessProject until you can rightclick on Location<strong>Component</strong>Frame and select the Test… option. TheOutput: Location<strong>Component</strong>Fram panel displays on the Project Window alongwith a Java application user interface titled Location<strong>Component</strong>.2. Select the Task menu option, and then select CreateLocation from theLocation<strong>Component</strong> window. The CreateLocation window now displays.3. Click Location under the Parameters node in the left-hand pane of theCreateLocation window. Type the following in<strong>for</strong>mation in the fields:Name: Rental Car Shop 1Address: 101 Main StreetCity: MyCityState: MyStateZipCode: 100014. Click the CreateLocation button. Your application returns the messagestring: "Location created successfully."5. Select the Task menu on the Location<strong>Component</strong> window and selectGetLocationList to display the GetLocationList window.6. Click the Location menu option located under the Results menu option onthe GetLocationList window.7. Click the GetLocationList button located in the bottom right corner of theGetLocationList window. The application returns all of the stored locations inthe database8. Right-click on the Project Window that hosts the Output tabs and select Closeto close the output windows. Right-click on the remaining tabs and selectClose.Build and Test 6–3


SummarySummaryIn this chapter, you:• Built the locationProject and its classes using the Build Wizard• Used the Test Harness Wizard to create an initial Java application userinterface <strong>for</strong> testing your component• Tested your component using the generated Java application and the testingfacility6–4 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Chapter7Exporting to <strong>AllFusion</strong><strong>Component</strong> <strong>Modeler</strong>Estimated Completion TimeAllow yourself approximately 10 minutes to complete this chapter.Use the <strong>XMI</strong> Export WizardYou now have an Advantage Joe implementation model that implements andrefines the analysis model you built with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>. Youalso have a specification that has been converted to a component-baseddevelopment specification. The Advantage Joe <strong>XMI</strong> Export Wizard can export themodified specification <strong>for</strong> you to import it back to <strong>AllFusion</strong> <strong>Component</strong><strong>Modeler</strong> so you can keep the results of different modeling phases together.The Advantage Joe <strong>XMI</strong> Export Wizard exports only the objects in theSpecification Packages. You can use the resulting file to import specificationobjects to the other UML modeling tools.1. Select File Export to <strong>XMI</strong>… to start the <strong>XMI</strong> Export Wizard. Click Nextwhen the Welcome panel displays to move to the Select the Target <strong>XMI</strong> Filepanel. The default <strong>XMI</strong> File name is the model’s name with .xml extensionand is placed in the model’s directory.2. Click the Finish button to accept the default <strong>XMI</strong> file name\models\JoeCarRental.xmland start the export process.3. Click Close when the <strong>XMI</strong> export completes.4. Exit the Advantage Joe product by selecting File Exit.Exporting to <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> 7–1


Import a Package to <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>Import a Package to <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>1. Start the <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> software and open the existingworkspace Car Rental System.2. Select menu File <strong>XMI</strong> Import. The Import dialog displays.3. Select the Import from File System radio button option.4. Click the Next button to display the Select XML file to Import panel.5. Type the location of your <strong>XMI</strong> file, \models\JoeCarRental.xml,or use the Browse button toselect the file. Click the Next button.6. Select Car Rental System as the import location.7. Click Finish to start the import process. When the import process completes,the Import dialog automatically closes.8. Expand the Car Rental System package node. A new model calledJoeCarRental was created. You may need to contract and re-expand the CarRental System package node to refresh the Project Tree.9. Expand the JoeCarRental model to see the default data types used in theAdvantage Joe model and the package Car Rental Analysis Model.10. Expand the Car Rental Analysis Model. All of the model elements insidewere originally created with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>, exported toAdvantage Joe, and then imported back to <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>.You will also see the objects you added in earlier sections in this exercise,such as the ITemp interface and Location<strong>Component</strong> class specification.For more detailed in<strong>for</strong>mation about the Import Package function of <strong>AllFusion</strong><strong>Component</strong> <strong>Modeler</strong>, please see the <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> on-line help.SummaryIn this chapter, you:• Exported the component model to an <strong>XMI</strong> file using the Advantage Joe <strong>XMI</strong>Export Wizard• Imported the component model’s <strong>XMI</strong> file into <strong>AllFusion</strong> <strong>Component</strong><strong>Modeler</strong> using the <strong>XMI</strong> Import option7–2 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export


Tutorial SummaryTutorial SummaryCongratulations! You have completed the import of a component specificationfrom <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong>, and exported the componentimplementation to an <strong>XMI</strong> file.Exporting to <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> 7–3


Tutorial Summary7–4 Advantage Joe Integrating with <strong>AllFusion</strong> <strong>Component</strong> <strong>Modeler</strong> – <strong>XMI</strong> Import/Export

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!