29.04.2015 Views

Reference Manual - UML2PHP

Reference Manual - UML2PHP

Reference Manual - UML2PHP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

S M A R T S O L U T I O<br />

N S<br />

<strong>UML2PHP</strong><br />

<strong>Reference</strong> <strong>Manual</strong><br />

Version of 2008-02-18<br />

BITPlan GmbH Pater-Delp-Str. D-47877 Willich<br />

Tel. 02154 / 811-480 Fax 02154 / 811-481 Web: www.bitplan.de E-Mail: info@bitplan.de


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Content<br />

© Copyright 2004-2008 BITPlan GmbH. All rights reserved.<br />

Y:\Source\Java\com\bitplan\uml2php\doc\<strong>UML2PHP</strong>-<strong>Reference</strong><strong>Manual</strong>.doc<br />

Trademarks<br />

MySQL and the MySQL Logo a registered trademark of MySQL AB in the United States, the European<br />

Union and other countries<br />

Poseidon is a registered trademark of Gentleware AG in Germany, USA and other countries<br />

Rational Rose® is a registered trademark of IBM Rational<br />

CORBA UML and MDA are trademarks of Object Management Group, Inc. in the U.S. and other<br />

countries<br />

Windows may or may not be a trademark of Microsoft Corporation in some or another country<br />

All other company, brand, and product names may be trademarks of their respective holders.<br />

Page 2 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Content<br />

Content<br />

Content ................................................................................................................................3<br />

1 Introduction ....................................................................................................................5<br />

1.1 What is <strong>UML2PHP</strong>?.................................................................................................5<br />

1.2 What do I need to use <strong>UML2PHP</strong>?..........................................................................5<br />

1.3 Where can I get <strong>UML2PHP</strong>?....................................................................................5<br />

1.4 Who created <strong>UML2PHP</strong>?.........................................................................................5<br />

1.5 How is <strong>UML2PHP</strong> implemented?.............................................................................6<br />

1.6 Organization of the <strong>UML2PHP</strong> documentation ........................................................6<br />

1.7 Further documentation.............................................................................................6<br />

1.8 Notation rules...........................................................................................................7<br />

2 <strong>UML2PHP</strong> base concepts..............................................................................................8<br />

2.1 Summary .................................................................................................................8<br />

2.2 Object Oriented Modelling and UML........................................................................8<br />

2.3 Who’s Who of <strong>UML2PHP</strong>.........................................................................................9<br />

3 <strong>UML2PHP</strong> Features.....................................................................................................12<br />

3.1 Summary ...............................................................................................................12<br />

3.2 PHP5 Code generation by mapping <strong>UML2PHP</strong>.....................................................12<br />

3.3 System Configuration.............................................................................................22<br />

3.4 User, Login and Session Support ..........................................................................24<br />

3.5 Menu and Functioncall Definition and handling .....................................................24<br />

3.6 Business object Catalogs and Business object Forms...........................................25<br />

3.7 Catalogs.................................................................................................................25<br />

3.8 Forms.....................................................................................................................26<br />

3.9 Selection Catalogs .................................................................................................27<br />

3.10 Dynamic Form handling ......................................................................................28<br />

3.11 SQL Database Support (Object-Relational mapping) .........................................28<br />

3.12 Test Support / Design for Testability...................................................................30<br />

3.13 Autoloading of PHP classes................................................................................31<br />

3.14 W3C conforming HTML code support and pretty printing ...................................31<br />

3.15 Cascading Style Sheet (CSS) support................................................................32<br />

3.16 N:M relation support............................................................................................32<br />

3.17 Platform independent code generation ...............................................................33<br />

4 Inheritance support ......................................................................................................34<br />

4.1 What is inheritance? ..............................................................................................34<br />

4.2 Examples ...............................................................................................................34<br />

5 <strong>UML2PHP</strong> architectural Support for inheritance ..........................................................38<br />

5.1 Overview................................................................................................................38<br />

5.2 UML to PHP language mapping for inheritance.....................................................38<br />

5.3 UML to generic architecture mapping ....................................................................38<br />

5.4 Object relational mapping / mapping UML inheritance to the database structure..39<br />

5.5 Mapping the UML inheritance to the GUI representation / Forms..........................44<br />

Page 3 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Content<br />

6 Generator.....................................................................................................................45<br />

6.1 Application Wizard .................................................................................................45<br />

6.2 Commandline Version of Generators.....................................................................45<br />

6.3 Generator Transaction Dialog................................................................................48<br />

6.4 Error Handling........................................................................................................49<br />

7 Appendix......................................................................................................................52<br />

7.1 Abbreviations .........................................................................................................52<br />

7.2 Bibliography ...........................................................................................................52<br />

7.3 Web-Links..............................................................................................................53<br />

8 Index............................................................................................................................54<br />

Page 4 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Introduction<br />

1 Introduction<br />

1.1 What is <strong>UML2PHP</strong>?<br />

<strong>UML2PHP</strong> is a tool for creating PHP5 code for web applications by the push of a button.<br />

From a single model source it will create<br />

PHP5 object oriented code<br />

A database structure that can be used for SQL and XML database storage<br />

Form and field definitions to edit records derived from UML classes<br />

Catalog definitions to search and browse multiple records for a UML class<br />

<strong>UML2PHP</strong> uses the smartGENERATOR technology to do all this. This technology is a<br />

100% pure Java based system that allows to specify how the resulting code should look<br />

like using templates. While using the community or professional editions of <strong>UML2PHP</strong><br />

you’ll only see the results of this technology. The enterprise edition of <strong>UML2PHP</strong> allows to<br />

modify the basic templates and the way the code is generated.<br />

The <strong>UML2PHP</strong> base framework is an OpenSource project hosted on SourceForge.net.<br />

You’ll find the project by searching for “uml2php” in SourceForge. The base framework is<br />

licensed under the BSD license – so it may be used for commercial purposes as long as<br />

you supply the copyright notice of BITPlan.<br />

1.2 What do I need to use <strong>UML2PHP</strong>?<br />

You’ll need<br />

Windows or Linux as an operating system<br />

Apache as a Webserver<br />

A MySQL database server as a Database 1 with SQL View support – mySQL5.0 is<br />

fine for this. mySQL 4.0 is still supported in Version 1.3c but the support is<br />

deprecated and limits the possibility to have inheritance support.<br />

PHP5<br />

A Java runtime environment to run the code generator<br />

A UML tool like Poseidon<br />

1.3 Where can I get <strong>UML2PHP</strong>?<br />

At http://www.uml2php.com you’ll find all the resources needed to download, try, buy<br />

and get support for <strong>UML2PHP</strong>.<br />

1.4 Who created <strong>UML2PHP</strong>?<br />

<strong>UML2PHP</strong> was created by BITPlan GmbH, Germany http://www.bitplan.com<br />

1 We support other databases using PEAR:DB<br />

Page 5 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Introduction<br />

1.5 How is <strong>UML2PHP</strong> implemented?<br />

<strong>UML2PHP</strong> is implemented using the Y-Principle MDA approach<br />

1.6 Organization of the <strong>UML2PHP</strong> documentation<br />

The <strong>UML2PHP</strong> documentation consists of the following documents:<br />

Readme<br />

this HTML 2 document contains a brief description and points to all relevant<br />

resources necessary to obtain information around <strong>UML2PHP</strong> – you’ll find contact<br />

information for BITPlan and other <strong>UML2PHP</strong> links there.<br />

User <strong>Manual</strong><br />

description of installation and general use of <strong>UML2PHP</strong> – you might want to read<br />

this document before you start using <strong>UML2PHP</strong>.<br />

Tutorial<br />

a step by step introduction to use <strong>UML2PHP</strong> along a list of simple examples that<br />

get more sophisticated with every step.<br />

<strong>Reference</strong> <strong>Manual</strong><br />

the reference <strong>Manual</strong> describes all the features and the technical background for<br />

<strong>UML2PHP</strong> – it’s intend for developers would like to use all the bells and whistles of<br />

<strong>UML2PHP</strong>. There is also a list of abbreviations used, recommended literature and<br />

the biggest index of all documents<br />

Release Notes<br />

this HTML document list all the information about changes between different<br />

versions of <strong>UML2PHP</strong>. You can find out which features are supported by your<br />

version and which bugs have been fixed.<br />

1.7 Further documentation<br />

1.7.1 PHPDoc<br />

You’ll find the PHP Doc HTML based documentation for <strong>UML2PHP</strong> in the htdoc<br />

subdirectory or the <strong>UML2PHP</strong> installation directory. On Windows Systems there is also a<br />

start-menu entry “phpdoc Documentation” available.<br />

1.7.2 Background information<br />

The following documents are available in the doc subdirectory of the <strong>UML2PHP</strong> installation<br />

directory:<br />

Requirements.pdf – the orignal requirements document for <strong>UML2PHP</strong> – it contains<br />

all requirements and acceptance test descriptions from the smartRQM 3<br />

requirements-database. This document was generated from this database.<br />

2 HTML Hypertext Markup Language<br />

3 a requirements tracing tool by BITPlan<br />

Page 6 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Introduction<br />

<br />

phpbobase.pdf – the original UML model printout – this document was generated<br />

from the UML architecture model that is the basis of <strong>UML2PHP</strong><br />

1.8 Notation rules<br />

!!! stands for things that are deprecated or need change. We use this symbol to quickly<br />

find these spots in this documentation.<br />

Page 7 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> base concepts<br />

2 <strong>UML2PHP</strong> base concepts<br />

2.1 Summary<br />

<strong>UML2PHP</strong> is based on the following concepts:<br />

Object oriented modelling using UML – the unified modelling language<br />

The idea of Business objects<br />

The platform independent data type definitions of the CORBA IDL – the common<br />

object request broker interface definition language 4<br />

Design Patterns<br />

The y-Principle as a software engineering approach that is user requirements and<br />

model driven and yields high quality and efficiency<br />

2.2 Object Oriented Modelling and UML<br />

As a reference <strong>Manual</strong> for UML we’ll not dive into the details of object-orientation and<br />

UML too much. If you’d like to use <strong>UML2PHP</strong> you should get yourself familiar with the<br />

base concepts of object orientation:<br />

Integration of data and its manipulation at a single point of maintenance<br />

Information hiding using Encapsulation<br />

Abstraction<br />

Inheritance and Polymorphism<br />

4 But <strong>UML2PHP</strong> does not support any ORB functionality other than the FunctionCall<br />

Page 8 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> base concepts<br />

2.3 Who’s Who of <strong>UML2PHP</strong><br />

The following graphic illustrates the Who’s who of <strong>UML2PHP</strong>:<br />

GUI<br />

UML<br />

User<br />

DB<br />

There are four main players:<br />

The User – he’s the boss and needs to have a nice application that fit’s his needs<br />

The Form – it displays what the user want’s to see in the GUI / Graphical User<br />

Interface<br />

The Table – it stores data from the form as it’s stored in the DB / Database<br />

The BO/Business Object it allows to manipulate the data involved by the PHP<br />

Page 9 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> base concepts<br />

2.3.1 How Data is moved around in <strong>UML2PHP</strong><br />

The following illustration shows how data is moved around from the Database to the<br />

Businessobject and the Browser and vice versa:<br />

asSQLValue<br />

BO<br />

asDisplayValue<br />

fromRow<br />

fromPOST<br />

Browser<br />

DB<br />

The conversion between the different Formats is done in Field.asSQLValue and<br />

Field.asDisplayValue. So the Business Object (BO) holds the true value of an attribute e.g.<br />

but it might be stored and shown differently. This is necessary to be able to show and save<br />

special data like passwords, strings with escape characters, database null values and so<br />

on. For the way back into the Businessobject BO.fromRow and BO.fromPOST are used.<br />

These methods undo the conversions that might have happened during the transfer from<br />

the Business Object to the Browser’s GUI (Graphical User Interface) or the Database. See<br />

below an excerpt from <strong>UML2PHP</strong>’s architecture UML model for more details.<br />

Page 10 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> base concepts<br />

phpbobase-Architecture model<br />

WF 2004-04-10<br />

BO, GUI and database overview<br />

BO<br />

fromPOST()<br />

fromRow()<br />

fromSESSION()<br />

Field<br />

data_type : string<br />

asDisplayValue()<br />

asSQLValue()<br />

getPHPDataType()<br />

isInStorage()<br />

isNull()<br />

phpAttributeName()<br />

sqlColumnName()<br />

2.3.2 Null Value handling<br />

Null values are allowed in databases – but what about PHP and the GUI? In PHP a null<br />

value is possible in principle you just use “null”. But what data type does null than have?<br />

The information about the datatype of a field is held in classField. So the nullValue check<br />

can be done in the field class with the isNull() method. This is necessary since a user<br />

needs some way to get null values displayed. Currently the null value display is “-“ as<br />

single dash. When you want an entry to be null in the database you might want to enter a<br />

“-“ in the field and when storing the record it will automatically be converted to a null.<br />

The definition for NULL_VALUE_DISPLAY is in classBO.php:<br />

/**<br />

* how to display NULL VALUES ...<br />

*/<br />

const NULL_VALUE_DISPLAY = "-";<br />

Page 11 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

3 <strong>UML2PHP</strong> Features<br />

3.1 Summary<br />

<strong>UML2PHP</strong> has the following main feature groups:<br />

PHP5 Code generation by mapping <strong>UML2PHP</strong><br />

System Configuration<br />

User, Login and Session Support<br />

Menu and Functioncall Definition and handling<br />

Business object Catalogs and Business object Forms<br />

Selection Catalogs<br />

Dynamic Form handling<br />

SQL Database Support (Object-Relational mapping)<br />

Test Support / Design for Testability<br />

Autoloading of PHP classes<br />

W3C conforming HTML code support and pretty printing<br />

Cascading Style Sheet (CSS) support<br />

N:M relation support<br />

Inheritance support (started in Version 1.3 with generating Views!!! 5 )<br />

Platform independent code generation<br />

3.2 PHP5 Code generation by mapping <strong>UML2PHP</strong><br />

3.2.1 Summary<br />

The code generation for <strong>UML2PHP</strong> supports the following UML Concepts:<br />

Packages<br />

o Namespace<br />

o Documentation<br />

o Tagged Values<br />

Classes<br />

o Abstraction<br />

o Inheritance<br />

o Documentation<br />

o Tagged Values<br />

DataTypes<br />

o Documentation<br />

Operations<br />

o Parameters<br />

•In-Parameter<br />

5 The inheritance support is not functional yet – you can only use abstract base tables at<br />

this time and redundant columns will be generated. !!! It’s intended to implement the<br />

support as outlined in the inheritance paragraph of this document.<br />

Page 12 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

<br />

•Out-Parameter<br />

•Return-Value<br />

o Visibility<br />

o Documentation<br />

o Tagged Values<br />

Attributes<br />

o Types<br />

o Visibility<br />

o Tagged Values<br />

Relations (1:1, 1:n, n:m) 6<br />

o Multiplicity<br />

o Roles<br />

o Navigation<br />

o Tagged Values<br />

The code generation for <strong>UML2PHP</strong> is controlled by a two sets of Tagged Values:<br />

<br />

<br />

BITPlan smartGENERATOR Tagged Value set<br />

PHP Tagged Value set<br />

3.2.2 UML package<br />

A UML package is mapped to a namespace. Since the PHP language as of version 5 does<br />

not support namespaces directly a namespace prefix for a class is generated to simulate<br />

namespaces.<br />

UML concept Code Comment<br />

… P1_ …<br />

e.g.<br />

aPackage<br />

class P1_aClass<br />

taggedValue<br />

packageName=P1<br />

Please note that the packageName is taken from the surrounding package. E.g. in a<br />

package hierarchy: com/bitplan/testpackage only the “packagename” taggedValue of the<br />

Package “testpackage” will be considered to create the namespaceprefix. The “_” is<br />

automatically inserted between the prefix and the classname.<br />

If the taggedValue “hasBOManager” of a package is set to true, all classes in the package<br />

will have “hasBOManager” set to true by default (see list of tagged values for details).<br />

The documentation of the package is not used for generating anything !!!.<br />

6 For creating n:m – relations please see Chapter “Modeling conventions”<br />

Page 13 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

3.2.3 UML class<br />

A UML class is mapped to one or more PHP 5 classes. For each PHP5 class a separate<br />

file is generated.<br />

UML concept Code Comment<br />

aClass<br />

taggedValue<br />

hasBOManager=false<br />

aClass<br />

hasBOManager=true<br />

class aClass {<br />

} // aClass<br />

class aClass extends<br />

phpbobase_BO {<br />

} // aClass<br />

class aClassManager<br />

extends<br />

phpbobase_BOManager<br />

{<br />

} // aClassManager<br />

PHP Doc header code for the class and it’s<br />

documentation is also generated<br />

aClass is considered to be a business<br />

object. The instance attributes and<br />

operations of aClass are generated into the<br />

class itself. The static/class attributes and<br />

operations are generated into the manager<br />

class. There is an implicit relation between<br />

the business object and it’s manager class<br />

3.2.4 UML datatypes<br />

PHP support for datatypes is poor, in UML it is a key concept. A datatype is either a<br />

standard datatype like string, integer, double or a user defined datatype. <strong>UML2PHP</strong> uses<br />

platform independent type declarations according to the CORBA standard as a basis. So<br />

you might want to make sure to load the UML CORBA Profile into your UML tool.<br />

3.2.5 UML operation<br />

An UML operation is mapped to a PHP function.<br />

If the class has a BOManager static operations are mapped as non-static! functions of the<br />

PHP BOManager class and instance operations are mapped as functions of the PHP BO<br />

class.<br />

If the class has no BOManager static operations are mapped as static functions of the<br />

PHP class and instance operations are mapped as non-static functions of the PHP class.<br />

UML concept Code Comment<br />

/**<br />

PHP Doc header code<br />

* Operations for Customer<br />

for the function, it’s<br />

*/<br />

/**<br />

documentation and<br />

parameters are also<br />

* make a new Order for this customer generated<br />

* @return the new order<br />

*/<br />

public function makeOrder() {<br />

} // makeOrder<br />

Page 14 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

3.2.6 UML attributes<br />

A UML attributes is mapped to a set of PHP getter and setter functions.<br />

UML concept Code Comment<br />

/**<br />

PHP Doc header code<br />

* Attributes for Customer<br />

for the attribute getter<br />

*/<br />

and setter and it’s is<br />

also generated<br />

/**<br />

* @param firstContact the date of the first<br />

contact;<br />

*/<br />

protected $firstContact;<br />

public function getfirstContact() {<br />

}<br />

return $this->firstContact;<br />

public function setfirstContact($value) {<br />

}<br />

$this->firstContact = $value;<br />

3.2.7 BITPlan smartGENERATOR stereotype handling<br />

UML stereotype Description<br />

Modelelement<br />

Package do not generate ignore the complete package when generating<br />

Class Class is the default – will be generated<br />

Class DataType denotes that the class is a DataType will be ignored when<br />

generating classes but may be used as a parameter or<br />

attribute type<br />

Class Interface not supported yet<br />

3.2.8 BITPlan smartGENERATOR Tagged Value set<br />

The BITPlan smartGENERATOR Tagged Value set was originally defined in Rational<br />

Rose PTY file bitplan.pty. If you use Rational Rose you’ll find bitplan.pty in the<br />

smartGENERATOR distribution’s 3 rd Party tool directory for Rational Rose.<br />

UML<br />

Modelelement<br />

Tag name Description Value<br />

range/<br />

type<br />

Model Export-Directory Directory where xmi/csv<br />

export script should put<br />

result<br />

ToolName Name of the tagged value<br />

set<br />

Path<br />

BITPlan,<br />

PHP,<br />

Delphi<br />

Default<br />

Same as model<br />

directory<br />

BITPlan<br />

Page 15 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

UML<br />

Modelelement<br />

Tag name Description Value Default<br />

range/<br />

type<br />

autogenerate True if the export script boolean false<br />

should not show a user<br />

dialog<br />

XMIId<br />

Internal tool independend string -<br />

xmi modelelement id<br />

XMIBaseId Base id to generate the tool string S100<br />

independend xmi<br />

modellement id from<br />

Package Template Default smartGENERATOR<br />

generator template class<br />

name to use for generating<br />

classes in this package<br />

TemplateOptions Options for the generator<br />

template class<br />

XMIId<br />

Internal tool independend<br />

xmi modelelement id<br />

Class final if true the generated class<br />

should be final (in Java ..)<br />

Template Default smartGENERATOR<br />

generator template class<br />

name to use for generating<br />

classes in this package<br />

TemplateOptions Options for the generator<br />

template class<br />

IsGUI<br />

if true the class data and<br />

functionality is part of the<br />

Graphical User Interface<br />

that should be generated<br />

(usually a form and catalog<br />

is generated)<br />

toolTipText show this text as a tooltip<br />

for the generated gui<br />

element of this class (e.g.<br />

form)<br />

SQLView use this SQL view to<br />

display records of that<br />

belong to this class after<br />

having generated an SQL<br />

table for this class<br />

string -<br />

string -<br />

string<br />

boolean<br />

string -<br />

string -<br />

boolean<br />

string -<br />

string -<br />

false<br />

true<br />

Page 16 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

UML<br />

Modelelement<br />

Tag name Description Value Default<br />

range/<br />

type<br />

XMLderived 7 consider this class as boolean false<br />

derived when mapping to a<br />

storage system (e.g. XML)<br />

persistent consider this class as boolean true<br />

persistent when mapping to<br />

a storage system (e.g.<br />

XML) When set to false all<br />

attributes will be considered<br />

as non transient<br />

isSaveable ? boolean false<br />

Attribute Final if true the generated boolean false<br />

attribute should be final (in<br />

Java ..)<br />

isGUI<br />

if true the attribute has a boolean false<br />

mapped counterpart in the<br />

Graphical User Interface<br />

e.g. a label/field<br />

combination<br />

isKey<br />

if true the attribute is a boolean false<br />

primary key for the class<br />

autoKey 8 if true make sure the boolean false<br />

storage system generates<br />

automatic new id's for this<br />

field<br />

sortPos<br />

when displaying a catalog integer 0<br />

of records for this class this<br />

attribute will be a) used for<br />

sorting at the given position<br />

b) used for displaying short<br />

catalogs (e.g. when<br />

navigating thru a relation)<br />

A sortpos must be unique<br />

within a class<br />

catalog The name of the selection string -<br />

7 The name of this tagged value is !!! deprecated !!! it will be changed soon since the prefix<br />

"XML" is misleading - it is only one of multiple storage concepts that can be used. The<br />

future name will be storagederived or the behaviour will happen when the standard UML<br />

"derived" setting is used .<br />

8 !!! not implemented yet<br />

Page 17 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

UML<br />

Modelelement<br />

Tag name Description Value Default<br />

range/<br />

type<br />

catalog to use - when this is<br />

set usually a combobox is<br />

generated that displays<br />

choice values from the<br />

given selection catalog<br />

catalogtype The type of the catalog: string static 9<br />

static and dynamic are<br />

available<br />

label<br />

the label to display for this string -<br />

attributes GUI element. E.g.<br />

in a label field combination<br />

the label will show this<br />

string<br />

unit<br />

if set a unit will be displayed string -<br />

behind the label/field<br />

combination that is<br />

generated for this attribute<br />

isHidden if true the field generated boolean false<br />

for this attribute will be<br />

hidden<br />

isReadonly if true the field generated boolean false<br />

for this attribute will be<br />

readonly<br />

isMandatory if true a value for the field<br />

generated for this attribute<br />

must be entered before a<br />

record can be saved for the<br />

form of this attribute's class'<br />

form<br />

boolean false<br />

isDefaultSearchFi<br />

eld<br />

derivedfrom 10<br />

if true this field will be used<br />

as the default search field<br />

for the search function of<br />

the catalog that is<br />

generated<br />

the value that this attribute<br />

is derived from<br />

boolean<br />

string -<br />

false<br />

showInGrid when showing the catalog / boolean true<br />

9 !!! Will be changed to "-" in a future Version<br />

10 There is no functionality for this tagged Value yet!!!<br />

Page 18 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

UML<br />

Modelelement<br />

Operation final<br />

Tag name Description Value Default<br />

range/<br />

type<br />

database grid for the class<br />

this attribute should be<br />

displayed as a column<br />

charWidth when set use this width for integer 80<br />

the field instead of the<br />

default field width<br />

RegExp<br />

Regular Expression to use string -<br />

to verify the field content<br />

against<br />

toolTipText show this text as a tooltip string -<br />

for the generated gui<br />

element of this attribute<br />

(e.g. field)<br />

XMIId<br />

Internal tool independent string<br />

model element identifier for<br />

XMI<br />

XMLasNode If true use a DOM node as boolean false<br />

the XML representation for<br />

the attribute. The default is<br />

to use an XML attribute<br />

XMLderived 11 consider this attribute as boolean false<br />

derived when mapping to a<br />

storage system (e.g. XML)<br />

persistent consider this attribute as boolean true<br />

persistent when mapping to<br />

a storage system (e.g.<br />

XML)<br />

selectAction 12 Selection Dialog to use string -<br />

selectDesc Description to show for the<br />

selection Dialog<br />

string -<br />

if true the generated boolean false<br />

operation should be final (in<br />

Java ..)<br />

XMIId Internal tool independent string<br />

11 The name of this tagged value is !!! deprecated !!! it will be changed soon since the<br />

prefix "XML" is misleading - it is only one of multiple storage concepts that can be used.<br />

The future name will be storagederived or the behaviour will happen when the standard<br />

UML "derived" setting is used .<br />

12 Only implemented for the Java GUI generator at this time!!!<br />

Page 19 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

UML<br />

Modelelement<br />

Relation<br />

Role<br />

Tag name Description Value Default<br />

range/<br />

type<br />

model element identifier for<br />

XMI<br />

isGUI<br />

if true the operation has a boolean false<br />

mapped counterpart in the<br />

Graphical User Interface<br />

e.g. a button<br />

confirm<br />

if true the operation must boolean false<br />

be confirmed by the user<br />

with a dialog before it is<br />

invoked from the GUI<br />

toolTipText show this text as a ToolTip string -<br />

for the generated graphical<br />

user interface element of<br />

this operation (e.g. button)<br />

icon<br />

The icon to use for the<br />

generated gui element for<br />

this operation (e.g. button)<br />

string -<br />

XMIId<br />

isGUI<br />

toolTipText<br />

Internal tool independent<br />

model element identifier for<br />

XMI<br />

if true the relation has a<br />

mapped counterpart in the<br />

Graphical User Interface<br />

e.g. for each role a tab in a<br />

tabbed folder or a sub-tree<br />

show this text as a tool tip<br />

for the generated graphical<br />

user interface element of<br />

this relation<br />

string<br />

boolean<br />

string -<br />

true<br />

XMIId<br />

Internal tool independent string<br />

model element identifier for<br />

XMI<br />

isGUI<br />

if true the role has a boolean True<br />

mapped counterpart in the<br />

graphical user interface e.g.<br />

a tab in a tabbed folder or a<br />

sub-tree<br />

isHidden if true the field generated boolean false<br />

Page 20 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

UML<br />

Modelelement<br />

Generaliz<br />

ation<br />

Tag name Description Value Default<br />

range/<br />

type<br />

for this Role will be hidden<br />

isReadonly if true the field generated boolean false<br />

for this Role will be<br />

readonly<br />

showInGrid when showing the catalog / boolean True<br />

database grid for the class<br />

this Role should be<br />

displayed as a column<br />

transient boolean false<br />

toolTipText show this text as a tool tip string -<br />

for the generated graphical<br />

user interface element of<br />

this role<br />

icon<br />

The icon to use for the string -<br />

generated gui element for<br />

this role<br />

persistent consider this role as<br />

persistent when mapping to<br />

a storage sysem (e.g. XML)<br />

boolean false 13<br />

XMIId<br />

Internal tool independent<br />

model element identifier for<br />

XMI<br />

string<br />

3.2.9 PHP Tagged Value set<br />

The BITPlan smartGENERATOR Tagged Value set was originally defined in Rational<br />

Rose PTY file php.pty. If you use Rational Rose you’ll find BITPlan.pty in the<br />

smartGENERATOR distribution’s 3 rd Party tool directory for Rational Rose.<br />

UML<br />

Modelelement<br />

Package<br />

Tag name Description Value<br />

range/<br />

type<br />

hasBOManager generate a Business Object boolean<br />

Manager for all classes in<br />

the package. A BOManager<br />

is needed if records for the<br />

class shall be stored<br />

Default<br />

false<br />

13 The default is set to false to avoid persistence cycles<br />

Page 21 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

UML<br />

Modelelement<br />

Class<br />

Tag name Description Value Default<br />

range/<br />

type<br />

packageName generate a namespace<br />

prefix for all classes in this<br />

package a "_" will be added<br />

between the packageName<br />

and the className<br />

string -<br />

hasBOManager generate a Business Object true true<br />

Manager for this class. A<br />

BOManager is needed if<br />

records for the class shall<br />

be stored<br />

nextForm if set present a button that string<br />

allows to submit to the form<br />

and directly jump to form<br />

named in this taggedvalue<br />

Operation by<strong>Reference</strong> Generate a by reference &<br />

function - that is the return<br />

parameter for this function<br />

will be returned by<br />

reference<br />

Parameter by<strong>Reference</strong> Generate a by reference &<br />

parameter - that is this<br />

parameter will be passed<br />

by reference<br />

default 14 generate a default value for<br />

this parameter so that the<br />

parameter is optional. If one<br />

parameter is optional all<br />

following must be optional<br />

too!<br />

3.3 System Configuration<br />

boolean<br />

boolean<br />

string -<br />

false<br />

false<br />

The System Configuration holds values that decide how the application should behave<br />

regarding a list of global aspects. For each <strong>UML2PHP</strong> application the values of the<br />

SystemConfiguration are taken from an include file usually named “config.inc” 15 in the local<br />

cgi-bin directory.<br />

14 This feature is not implemented for Poseidon yet!!!<br />

15 For testcases the filename „test.inc“ is mostly used<br />

Page 22 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

The configuration sets directly the attributes of the phpbobase class SystemConfiguration<br />

with some lines of php code:<br />

SystemConfiguration<br />

dbmachine : string<br />

dbsqltype : string<br />

dbname : string<br />

dbuser : string<br />

dbpassword : string<br />

timeoutSecs : long<br />

debug : boolean<br />

checkBoxDisplayLimit : long<br />

downloadDirectory : string<br />

certificateFunction : string<br />

useSSL : boolean<br />

init(configfilename : string)<br />

Here is an extract of an example Systemconfiguration include file:<br />

$this->dbmachine = 'localhost';<br />

$this->dbuser<br />

= 'test';<br />

$this->dbpassword = 'testsecret';<br />

$this->dbname<br />

= 'testdb';<br />

$this->downloadDirectory = 'com/bitplan/phpbobase/test/genepi/download';<br />

<br />

<br />

<br />

<br />

<br />

<br />

$this->timeoutSecs = 600;<br />

$this->debug<br />

= true;<br />

$this->checkBoxDisplayLimit = 5;<br />

dbmachine, dbsqltype, dbname, dbuser and dbpassword<br />

describe the database connection that shall be used by your application.<br />

timeoutSecs<br />

determines how many seconds a session will be valid before it times out and the<br />

user will be logged out automatically<br />

debug<br />

if debug is set to true it can be used by the programmer to decide whether to<br />

display debug messages or log debug messages<br />

checkBoxDisplayLimit<br />

the number “checkBoxDisplayLimit” will decide when the forms display switches<br />

from radio buttons in checkBox form to lists for displaying a list. If the number of list<br />

items is greater than the checkboxDisplayLimit a listbox will show other wise a set<br />

of radiobuttons<br />

downloadDirectory<br />

if set will denote a sessin-specific directory where downloads that should only<br />

available for the current user can be placed. The contents of this directory are<br />

automatically removed at the end of the session<br />

certificateFunction<br />

if set the user administration will allow to create (SSL)-certificates. When the<br />

“createCertificate” button is pressed the function for certificate creation specified in<br />

the Systemconfiguration will be called<br />

Page 23 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

<br />

useSSL<br />

if set using SSL (Secure Socket Layer) will be mandatory for this application<br />

3.4 User, Login and Session Support<br />

3.4.1 The boot process / running in bootmode<br />

As long as the necessary data is not available in the database, User, Organization and<br />

UserRole data is taken from three XML files in the subdirectory storage: User.xml,<br />

Organization.xml and UserRole.xml. These three business objects form a boot group. On<br />

startup the application checks whether User, Organization and UserRole data is available<br />

in tables of the SQL database. All three tables must exist and have one entry before the<br />

bootgroup will be considered active and the application will take User, Organization and<br />

UserRole information from the database. If the bootgroup is not active, that is one of the<br />

three tables is missing or has no entries yet, than the XML bootmode is used and the<br />

information is read in from the three XML files. You’ll see a message saying<br />

“bootmode - only users from XML file are valid ...” before the login happens:<br />

If you klick on the link “XML file User.xml”, the XML file is opened and you can see which<br />

users are valid, for example id="admin" password="secret".<br />

3.4.2 Forcing a new Session<br />

If you’d like to make sure that a new session is started when you access your <strong>UML2PHP</strong><br />

application using an URL than you might want to add the URL parameter<br />

“newsession=true”. This parameter is often used in test-situations. It will force a new<br />

session to be created. Example:<br />

http://localhost/com/bitplan/testcase/RQ1030/index.php?newsession=true<br />

3.5 Menu and Functioncall Definition and handling<br />

3.5.1 Overview<br />

After logging into the system the user is known and assigned a default role. This role is<br />

used to find out what menu should be displayed to the user. The menu is a hierarchy of<br />

menus with submenus. The atoms of this hierarchy are menuitems. Each menuitem is<br />

linked to a functioncall. A list of roles can be assigned to a menuitem to decide for which<br />

roles accessing this menuitem and calling the functioncall should be allowed.<br />

Page 24 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

3.5.2 The boot process / running in bootmode<br />

As long as the necessary data is not available in the database, Menu information is taken<br />

from an XML file in the subdirectory “menu” with the name “rootMenu.xml”. A default<br />

menu is automatically generated by the Application Wizard.<br />

3.5.3 Menus& Menuitems<br />

A Menu can consist of several submenus. Each submenu may contain several Menuitems.<br />

For each Menuitem a Functioncall definintion and multiple allowed User – Roles can be<br />

assigned.<br />

3.6 Business object Catalogs and Business object Forms<br />

3.6.1 Summary<br />

<strong>UML2PHP</strong> uses the following concepts to define forms:<br />

FormSet - a set of Forms that belong together (e.g. for an application)<br />

Form - a single Form that may consist of multiple pages<br />

Page - a page of a form<br />

Field - a field of a form which might be part of a page or belong to the form directly<br />

The forms and fields are used two display your business objects in two ways:<br />

as a single form<br />

as a catalog<br />

3.7 Catalogs<br />

The Catalog ist used to display all available business objects of a certain kind. It allows for<br />

searching business objects, editing and deleting existing business objects and creating<br />

new business objects.<br />

3.7.1 Selection of attributes to show<br />

In a catalog only those attributes from an UML class are show where the taggedValue<br />

showInGrid is true.<br />

3.7.2 Sorting<br />

The default sorting of a business object catalog can be influenced by setting the sortPos<br />

taggedValues for the UML-attributes. If the sortPos is non-zero it will be used to determine<br />

a sorting sequence. E.g. if you have the attributes: address,counter,firstname, name and<br />

set the sortpos values as: address(0), counter(-3),firstname(2), name(1) the sorting<br />

sequence will be name ascending, firstname ascending, count descending. The sorting<br />

sequence may not be broken or you’ll get a runtime error. The sequence<br />

address(2),counter(-2), firstname(1) would be false, because the sorting order is unclear in<br />

this case – should counter or address be the second field to sort by?<br />

Page 25 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

3.8 Forms<br />

A form allows for editing the contents of a business object and for calling operations on it.<br />

Also you can navigate to neighbours of a business object from the form.<br />

3.8.1 FormSets<br />

A Formsets helps managing forms and the tables attached to these forms.<br />

phpbobase-Architecture model<br />

WF 2004-02-29<br />

FormSet details<br />

FormSet<br />

id : string<br />

name : string<br />

issue date : date<br />

short description : string<br />

description : memo<br />

$show()<br />

$showform()<br />

dropAllTables()<br />

createAllTables()<br />

$addFormSetName()<br />

$getFormSetNames()<br />

+myFormSet<br />

+myForms<br />

0..1<br />

0..n<br />

Form<br />

id : string<br />

name : string<br />

description : memo<br />

detailType : string<br />

$lastform : string<br />

currenttabid : string<br />

submit()<br />

getKeyField()<br />

cancel()<br />

undo()<br />

$showForm()<br />

$addToXmlSearchPath()<br />

saveForm()<br />

allStorageFields()<br />

all<strong>Reference</strong>1Fields()<br />

myTabs()<br />

showFormPage()<br />

showFieldList()<br />

genScript()<br />

show()<br />

getFieldByName()<br />

allSortFields()<br />

execrequest()<br />

dosubmit()<br />

3.8.2 Fields<br />

Fields are generated from attributes - for each UML attribute of a class a corresponding<br />

input field is generated. According to the datatype of the attribute the field type is<br />

determined:<br />

datatype<br />

fieldtype<br />

boolean<br />

checkbox<br />

enum/list/dynamic list several checkboxes or one list depending on the number<br />

of entries and the setting of checkboxdisplaylimit<br />

memo<br />

textarea<br />

password<br />

password<br />

Page 26 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

html<br />

editize applet<br />

string and other<br />

input field<br />

Fields may have the attribute "mandatory". This field attribute is initially derived from the<br />

tagged value "mandatory" of the UML attribute. In may be modified at run-time.<br />

If a field's attribute mandatory is set to true the field's background will be displayed in the<br />

way defined by your Stylesheet file.<br />

3.9 Selection Catalogs<br />

See Requirement #004<br />

phpbobase Architecture model<br />

WF 2004-02-13<br />

Selection Catalog<br />

Selection_catalog<br />

name : string<br />

language : string<br />

description : memo<br />

catalogtype : enum{isEnumeration,isList,isDynamicList}<br />

+myCatalog<br />

1<br />

+myEntries<br />

0..n<br />

CatalogEntry<br />

dbkey : string<br />

identifier : string<br />

entry : string<br />

description : memo<br />

code : long<br />

usagecount : long<br />

There a three ways to define a list of possible values that may be entered for a field:<br />

Enumerations (isEnumeration)<br />

Lists (isList)<br />

Dynamic Lists (isDynamicList)<br />

Enumerations are fixed sets of values that are mainly defined in the UML model using the<br />

CORBA enum datatype concept.<br />

Lists are sets of values that may be modified by an administrator<br />

Dynamic Lists are sets of values that may be modified by an end-user<br />

If you are using Lists or Dynamic Lists please set the tagged values “catalog” and<br />

“catalogtype” of the corresponding attribute (see 3.2.2).<br />

Page 27 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

3.10 Dynamic Form handling<br />

3.10.1 Generated Forms<br />

The Form and field definitions are generated from the UML model. The formset that these<br />

forms belong to is specified by setting the formsetid when starting the generator. In the<br />

application wizard you’ll find the formsetid field in the “details” page. The default is set to<br />

the packagename of the main package of your uml file.<br />

3.10.2 Dynamic User defined Forms (no UML)<br />

You may add your own user defined formsets, forms and fields.<br />

3.11 SQL Database Support (Object-Relational mapping)<br />

3.11.1 Summary<br />

<strong>UML2PHP</strong> transforms your UML models to database structures automatically. For each<br />

business object a database table is created and for each attribute of a business object a<br />

database column is created. The transformation decision is based on the “persistent”<br />

tagged value of the corresponding UML element. If persistent is set to “true” the<br />

transformation takes place.<br />

3.11.2 Database<br />

Database<br />

(from phpbobase)<br />

name : string<br />

$me : Database<br />

lastmessage : string<br />

isopen : boolean<br />

opendb()<br />

check()<br />

sql()<br />

backup()<br />

restore()<br />

init()<br />

mysqlCommand()<br />

Page 28 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

3.11.3 DBTable<br />

DBTable<br />

(from phpbobase)<br />

name : string<br />

createCommand()<br />

createOnDB()<br />

checkTable()<br />

drop()<br />

init()<br />

insertValues()<br />

updateValues()<br />

deleteRecord()<br />

createViewCommand()<br />

getByKey()<br />

exists()<br />

getCount()<br />

backup()<br />

restore()<br />

3.11.4 Persistence Cycle detection<br />

When modelling classes and their relations be careful to avoid “persistence cycles “. A<br />

persistence cycle is created if an instance of a class will attempt to store it’s neighbours<br />

which will in turn store their neighbours – if the chain of these attempts leads to trying to<br />

store the initial instance again a persistence cycle happens. This is currently not detected<br />

at run time but at generation time / design time. Here are two examples for persistence<br />

cycles:<br />

A<br />

(from p)<br />

+myA<br />

+myB<br />

B<br />

(from p)<br />

+myA<br />

+myC<br />

+myB<br />

+myC<br />

C<br />

(from p)<br />

1:1 persistence cycle example<br />

Page 29 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

If the navigable roles myB from A to B, myC from B to C and myA from C to A are all<br />

marked persistent than a persistence cycle is created.<br />

Menu<br />

(from phpbobase)<br />

0..n<br />

+mySubMenus<br />

1<br />

+myParentMenu<br />

1:N to self persistence cycle example<br />

If myParentMenu is marked as persistent the Menu will attempt to store itself as a<br />

neighbour . To avoid this persistence cycle set the “persistent” tag of the myParentMenu<br />

role to false<br />

The generator can warn you when a persistence cycle happens:<br />

You should then cancel the transaction and solve the problem by setting the persistent<br />

tags in a way that the persistence cycle is broken.<br />

To switch on the persistence cycle check you might want to check the check box<br />

of your Application Wizard settings or when using the command<br />

line set the command line option –checkpersistencecycle=true<br />

3.12 Test Support / Design for Testability<br />

3.12.1 Summary<br />

Certain features in <strong>UML2PHP</strong> have been created for the purpose of being able to test the<br />

application better. Depending on the test environment you use you might find some of<br />

these features useful. These are:<br />

Javascript Menu disabling<br />

Debug and log<br />

3.12.2 Javascript Menu disabling<br />

The URL Parameter nojavascriptmenu will be set to the value of the attribute<br />

useJavaScriptMenu of the class WebFrame.<br />

Page 30 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

If it is set to false, the menu will be displayed using simple HTML links instead of<br />

JavaScript (if set to true).<br />

3.12.3 Debug and log<br />

The bpcommon_Debug is used for Debug support. To init logging initialize it with<br />

bpcommon_Debug::init(true);<br />

This mode is automatically entered if a user logs in that has a role with the name<br />

"Developer" assigned to it. When Debug-loggin is switched on you'll find a debug log<br />

named "phperrorlog.txt" in your operating systems default temporary directory. The logging<br />

commands for getter and setter are pre-generated but commented out. If you'd like to see<br />

the result just uncomment the code. E.g.:<br />

bpcommon_Debug::log("Getting WebFrame [".$nm."]");<br />

3.13 Autoloading of PHP classes<br />

<strong>UML2PHP</strong> supports autoloading of your classes. To do so it will create a helper class with<br />

an index of all the generated PHP classes. The index will allow to look up the PHP name<br />

for a CORBA IDL name and then the path to the generated PHP class for the PHP name.<br />

The arrays $_php2path and $_idl2path are internally used by the helper class for this<br />

purpose.<br />

Example helper Class “Jokedatabase_ClassList”:<br />

class Jokedatabase_ClassList {<br />

static function getClassPathList() {<br />

// help autoload ... require_once ...<br />

// all classes used<br />

$_php2path=array();<br />

$_idl2php =array();<br />

$_php2path["JD01_Author"]="uml2phpexamples/Jokedatabase/classAuthor.php";<br />

$_idl2php ["::uml2phpexamples::Jokedatabase::Author"]="JD01_Author";<br />

$_php2path["JD01_AuthorManager"]="uml2phpexamples/Jokedatabase/classAuthorManager.php";<br />

$_idl2php ["::uml2phpexamples::Jokedatabase::AuthorManager"]="JD01_AuthorManager";<br />

$_php2path["JD01_AuthorForm"]="uml2phpexamples/Jokedatabase/classAuthorForm.php";<br />

$_idl2php ["::uml2phpexamples::Jokedatabase::AuthorForm"]="JD01_AuthorForm";<br />

$_php2path["JD01_AuthorCatalog"]="uml2phpexamples/Jokedatabase/classAuthorCatalog.php";<br />

$_idl2php ["::uml2phpexamples::Jokedatabase::AuthorCatalog"]="JD01_AuthorCatalog";<br />

$_php2path["JD01_Joke"]="uml2phpexamples/Jokedatabase/classJoke.php";<br />

$_idl2php ["::uml2phpexamples::Jokedatabase::Joke"]="JD01_Joke";<br />

$_php2path["JD01_JokeManager"]="uml2phpexamples/Jokedatabase/classJokeManager.php";<br />

$_idl2php ["::uml2phpexamples::Jokedatabase::JokeManager"]="JD01_JokeManager";<br />

$_php2path["JD01_JokeForm"]="uml2phpexamples/Jokedatabase/classJokeForm.php";<br />

$_idl2php ["::uml2phpexamples::Jokedatabase::JokeForm"]="JD01_JokeForm";<br />

$_php2path["JD01_JokeCatalog"]="uml2phpexamples/Jokedatabase/classJokeCatalog.php";<br />

3.14 W3C conforming HTML code support and pretty printing<br />

Internally <strong>UML2PHP</strong> tries to be as W3C conforming as possible. The functions<br />

prepare() and emit() are used for pretty printing the HTML code that is created by<br />

<strong>UML2PHP</strong>.<br />

Page 31 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

3.15 Cascading Style Sheet (CSS) support<br />

There is a cascading style sheet “formstyle.css” which allows you to set the appearance<br />

of your application. You may set up your own stylesheet to always use. Just copy the<br />

content of the BITPlan/<strong>UML2PHP</strong>/templates directory to a directory of your choice. If you<br />

know set the template path in the application wizard to this newly created directory with<br />

your own content the generator will take the formstyle.css file from there.<br />

3.16 N:M relation support<br />

An n:m-relation (e.g. between several UserRoles and several MenuItems) should look like<br />

this to be generated by <strong>UML2PHP</strong>, the association name “TestMenuAccess” must either<br />

be the same as the name of the AssociationClass or be empty:<br />

<strong>UML2PHP</strong> automatically interprets such a model as if it where modelled like this:<br />

Page 32 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> Features<br />

In fact the N:M association is split into two 1:N relations to be handled by the database and<br />

GUI concepts properly. The Jokedatabase example in the tutorial has an N:M relation<br />

between “Joke” and “Category” as an example for this concept.<br />

3.17 Platform independent code generation<br />

To make the UML model platform independent and allow the possibility of generating for<br />

other target platforms the data types in your model have to be independent of your target<br />

language PHP. <strong>UML2PHP</strong> therefore expects CORBA-Types. The basic CORBA-types are<br />

short, long, long long, unsigned short, unsigned long, unsigned long long, float, double,<br />

char, wchar, boolean, string and fixed.<br />

For further information please see the CORBA standard at http://www.omg.org.<br />

Additionally the following “standard” types are supported:<br />

date is used for calendar dates. It’s representation in memory and for the database<br />

is in ISO format yyyy-mm-dd<br />

memo can be used for long text fields. It represents a string of unlimited length and<br />

the corresponding database and gui representations are used<br />

html can be used for text fields in html format. This way you can actually keep<br />

HTML code in your database. The representation in the gui is done with an<br />

editize 16 applet.<br />

<br />

password can be used for text fields that should be hidden while you enter them. It<br />

represents a string and the gui representation is as a password field.<br />

In Gentleware’s Poseidon Professional edition, it is possible to activate the CORBA data<br />

types by activating the CorbaProfile in the settings dialog.<br />

In the community edition, it is necessary to create the CORBA DataTypes yourself with<br />

“New datatype”. Please be sure not to use the java-types like “String”.<br />

16 the editize applet is delivered with <strong>UML2PHP</strong> – the license is limited to your local host. If<br />

you’d like to use the HTML feature you might want to buy an editize license.<br />

Page 33 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Inheritance support<br />

4 Inheritance support<br />

4.1 What is inheritance?<br />

Inheritance is a fundamental object oriented concept. When analyzing the desired<br />

behaviour of a software system, the objects that the system is supposed to handle and<br />

support are classified. Objects with similar attributes, behaviour and relations lead to<br />

classes. If objects share common attributes. behaviour and relations but have further<br />

different attributes, behaviour and relations this will lead to a hierarchy of classes that have<br />

a generalization/specialization relation to each other – this relation is called inheritance.<br />

The more general class is called superclass and the specialized class is called subclass.<br />

The objects of the subclass inherit attributes (features) and operations (behaviour) from<br />

the superclass. One superclass can always have multiple subclasses. A situation where a<br />

subclass can have multiple superclasses is called multiple inheritance. Multiple inheritance<br />

is often avoided and not supported directly in most implementation environments<br />

(programming languages, database mappings). The feature of the objects that decides to<br />

which class an object belongs given different possible subclasses the object could belong<br />

to is called a discriminator.<br />

4.1.1 Polymorphism<br />

Polymorphism is complicated word with greek roots – it means something like “many<br />

varying looks”. In object orientation it is allowed that the attributes, behaviour (and we<br />

wished easily also relations) with the same name can have different<br />

realizations/implementations depending on where an object is located in the class<br />

hierarchy. In the banking example below you’ll see that the getAreaCode() function of a<br />

foreign customer works differently than that of a domestic customer.<br />

4.2 Examples<br />

4.2.1 Banking inheritance example<br />

The following example is a banking scenario which illustrates the inheritance concept. The<br />

root subclass of the inheritance hierarchy (also called inheritance tree) in this example is<br />

Partner. All business contacts that a bank has are considered to be partners. A common<br />

attribute all these partner objects share is “phone”. The discriminator for the subclasses<br />

Supplier and Customer is the role / business relation the partner has to the bank. A third<br />

possible subclass could be “employee”.<br />

A customer in the desired software system shall have a different behaviour than a supplier.<br />

A customer shall have one or more bank accounts assigned to him and the usual banking<br />

services like risk and overdraw limit calculation shall be available.<br />

The functions getAreaCode() and handle() are polymorph. To calculate the area code for a<br />

foreign customer (represented by an object that belongs to the class ForeignCustomer) the<br />

extra attribute Country Code is necessary. E.g. for a german customer the full are code<br />

might consist of the country code “+49” and the local are code “211” giving “+49 211” as<br />

Page 34 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Inheritance support<br />

the result. For a domestic customer that would be represented by an object that belongs to<br />

the class Customer, the area code might be e.g. “719” and so “719” would be returned as<br />

the result by getAreaCode().<br />

handle() is just a helper function that allows to do some task on all partners of the bank.<br />

The handling will be different for all the objects in the subclasses of the inheritance<br />

hierarchy.<br />

The keywords “abstract”, “virtual” and “override” are used as stereotypes for polymorph<br />

functions in this UML model. This is a work-around for the missing native support of UML<br />

for these concept, that are known e.g. in the C++ and/or Delphi programming language.<br />

Using these keywords allows a language specific generator to react accordingly. In<br />

<strong>UML2PHP</strong> these keywords are currently ignored.<br />

Testmodel for inheritance<br />

08.10.1999 10:40 AV<br />

2004-06-12 WF english version<br />

Partner<br />

phone : string<br />

getAreaCode()<br />

handle()<br />

+myPartners<br />

0..n<br />

+myBank<br />

1..1<br />

Bank<br />

maxAccountNumber : long<br />

$isCustomer(in pPartner : Partner) : boolean<br />

toCustomer(in pPartner : Customer)<br />

1..1<br />

+myBank<br />

Supplier<br />

Customer<br />

calculateOverdrawLimit()<br />

calculateRisk()<br />

$calculateTransactionVolumeOfAllCustomers()<br />

handle()<br />

handle()<br />

+myOwner<br />

0..n<br />

Bankrelation<br />

0..n<br />

+myAccounts<br />

Bankrelation<br />

+myAccounts<br />

0..n<br />

Account<br />

overdrawLimit : Amount<br />

frozen : boolean<br />

accountNumber : AccountNoType<br />

interestRate : InterestRate<br />

calculateNumberOfTransactions()<br />

getNumberOfTransactions()<br />

createTransaction()<br />

calcMax()<br />

ForeignCustomer<br />

CountryCode : string<br />

getAreaCode() : string<br />

BusinessCustomer<br />

handle()<br />

Page 35 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Inheritance support<br />

4.2.2 Inheritance tree – data attributes<br />

The following class diagram is a view that shows the relevant data attributes for the object<br />

relational mapping of the banking example. Please note that the types used for the<br />

attributes are CORBA types plus a special type “Date” that will be directly mapped to the<br />

“date” type supplied by most relational databases.<br />

Testmodel for inheritance<br />

08.10.1999 10:40 AV<br />

2004-06-12 WF english version<br />

2005-07-26 WF ORM version<br />

Partner<br />

phone : string<br />

Customer<br />

birthdate : Date<br />

customername : string<br />

Supplier<br />

since : Date<br />

ForeignCustomer<br />

CountryCode : string<br />

4.2.3 <strong>UML2PHP</strong> architecture example (Center)<br />

The following example shows how a domain specific class (in this example Center) is<br />

based on an architectural inheritance hierarchy. The root subclass of the hierarchy is BO<br />

(short for Business Object). The BO base class is used for tracing administrative<br />

information on business objects, like when and by whom they were created, what the<br />

name of the key attribute of the business object is, in which table it is stored, whether the<br />

business object is locked and the like.<br />

One of the <strong>UML2PHP</strong> framework classes is Organization, like most <strong>UML2PHP</strong> framework<br />

classes it is a subclass of BO. One can also say that Organization is derived from BO. The<br />

Organization information is used for grouping users, being able to address and label them<br />

correctly and assign SSL certificate information to them.<br />

One of the reference projects of <strong>UML2PHP</strong> is used in a clinical environment. The clinics<br />

are called Center in the application. For that software system the analysis lead to creating<br />

the class Center as a subclass of Organization. The only difference between the generic<br />

Page 36 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Inheritance support<br />

Organization and the specific Center is that the Centers have a collection of patients<br />

assigned to them. Therefore there is a relation between Center and Patient (which is not<br />

shown in the class diagram below).<br />

WF 2004-05-27<br />

Center<br />

Center<br />

Organization<br />

(from phpbobase)<br />

id : string<br />

name : string<br />

unit : string<br />

address : memo<br />

countrycode : string<br />

state : string<br />

city : string<br />

web : string<br />

status : string<br />

BO<br />

(from phpbobase)<br />

oid : string<br />

created_at : date<br />

created_by : string<br />

last_modified_at : date<br />

last_modified_by : string<br />

boclass : string<br />

boshortname : string<br />

bokey : string<br />

bodbtable : string<br />

isNew : boolean<br />

fullyActivated : boolean<br />

useoidforSession : boolean<br />

boIsEditing : boolean<br />

locked_by : string<br />

Page 37 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> architectural Support for inheritance<br />

5 <strong>UML2PHP</strong> architectural Support for inheritance<br />

5.1 Overview<br />

There are four areas in which inheritance needs to be supported by <strong>UML2PHP</strong>:<br />

UML to PHP/PHP5 language mapping for inheritance<br />

UML to generic architecture mapping (differenciation between class/static and<br />

instance specific UML attributes and operations)<br />

Object relational mapping / mapping UML inheritance to the database structure<br />

Mapping the UML inheritance to the GUI representation / Forms<br />

5.2 UML to PHP language mapping for inheritance<br />

Single inheritance is directly supported by PHP5. Currently <strong>UML2PHP</strong> supports<br />

inheritance between classes (implements relations to interfaces are not supported yet).<br />

The “extends” keyword of PHP is used to denote the inheritance relation between two<br />

classes. Multiple inheritance is not supported at this time.<br />

For the above Center class (from the package genepi) the following declaration is<br />

generated:<br />

class genepi_Center extends phpbobase_Organization<br />

{<br />

…<br />

} // genepi_Center<br />

The superclass Organization from the package phpbobase has the following declaration:<br />

class phpbobase_Organization extends phpbobase_BO<br />

{<br />

…<br />

} // phpbobase_Organization<br />

The root base class BO from the package phpbobase has the following declaration:<br />

class phpbobase_BO<br />

{<br />

…<br />

} // phpbobase_BO<br />

5.3 UML to generic architecture mapping<br />

<strong>UML2PHP</strong> always separates class and instance attributes and operations. Each UML<br />

class that has the tagged Value “hasBOManager” set to “true” will be mapped to two PHP<br />

classes, one for the instance part which has the prefix “class” and no suffix and one for the<br />

class/static part with the prefix “class” and the suffix “Manager”. For the Center example<br />

the PHP files classCenter.php and classCenterManager.php are therefore generated. The<br />

root base class of the Manager class hierarchy is the <strong>UML2PHP</strong> framework class<br />

BOManager. The BOManager is in charge of managing all instances of a class. Creating,<br />

and deleting (factory), looking up and searching (query) as well as navigating all the<br />

instances/objects of a class (collection) are the main tasks of a BOManager.<br />

For the above Center class (from the package genepi) the following declaration is<br />

generated for the CenterManager:<br />

Page 38 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> architectural Support for inheritance<br />

class genepi_CenterManager extends phpbobase_OrganizationManager<br />

{<br />

…<br />

} // genepi_CenterManager<br />

The superclass OrganizationManager from the package phpbobase has the following<br />

declaration:<br />

class phpbobase_OrganizationManager extends phpbobase_BOManager<br />

{<br />

…<br />

} // phpbobase_OrganizationManager<br />

The super class BOManager from the package phpbobase has the following declaration:<br />

abstract class phpbobase_BOManager extends phpbobase_BOCollection<br />

{<br />

…<br />

} // phpbobase_BOManager<br />

As you can see on the architectural side the hierarchy does not end with BOManager – it<br />

is itself derived from BOCollection. Also it’s an abstract class. There can be no concrete<br />

BOManager for abstract BO objects. Both the concrete Manager e.g. FooManager<br />

as the concrete e.g. Foo must be derived.<br />

5.4 Object relational mapping / mapping UML inheritance to the<br />

database structure<br />

5.4.1 Why Object Relational Mapping?<br />

Writing a PHP application that stores data in a Relational Database Management System<br />

can be as simple as accessing a few mySql tables and columns directly using the built-in<br />

API functions of PHP. This simple approach has the disadvantage of taking much effort to<br />

maintain – any change in the structure of your data must be manually adapted to by<br />

changing your database access code. The benefit of an object relational mapping lies in<br />

the encapsulation and the link to the UML model. To gain these benefits a proper objectrelational<br />

mapping is needed with a strategy for mapping the UML object model to the<br />

relational table model in order for PHP objects to become stored to the RDBMS/SQL<br />

database. An object that automatically stores and retrieves itself from storage in this way<br />

is called “persistent”.<br />

Objects can not be directly stored and retrieved in a relational database. Object do not<br />

only consist of data(attributes) but also have an identity a state and behaviour(functions).<br />

The database will only be able to save the attributes and with some extra measures<br />

identity and state of the object. There are few problems to solve for this: the data types<br />

used must be mapped (this is why <strong>UML2PHP</strong> relies on CORBA data types in the UML<br />

Model). Also the references from one object to another must be cared for. During PHP<br />

runtime the object references are direct references between objects in memory. Tables in<br />

relational databases are linked to each other using foreign and primary keys. There is no<br />

direct support for inheritance in relational database systems. The design goals for object<br />

oriented software systems and relational database management systems differ: the object<br />

oriented approach to software development tries to closely model the business objects and<br />

business processes the software is to support – relational modeling is much more<br />

Page 39 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> architectural Support for inheritance<br />

concerned with normalizing data (avoiding redundant data). The differences between<br />

these two approaches must be overcome.<br />

5.4.2 Mapping an inheritance tree<br />

There are three commonly used approaches for mapping a class inheritance tree to<br />

relational database tables 17 :<br />

vertical<br />

horizontal<br />

filtered<br />

The three approaches will be explained now using the Center/Organization/BO inheritance<br />

tree already used as an example above.<br />

Vertical Mapping. In vertical mapping, each class in the tree, whether abstract or<br />

concrete, is mapped to a different table. All branch and leaf tables in the tree must be<br />

linked to their parent tables. This can be accomplished by means of a foreign key column<br />

that references the object id (as a key/primary key) of the parent table. In order to<br />

instantiate a concrete class using this method, a join query of the concrete class table and<br />

all its abstract parent class tables must be performed. The tables below show how our two<br />

sample models are mapped to a relational database (in this case mySQL) using vertical<br />

mapping:<br />

GC1_Center<br />

colname coltype collen colflags comment<br />

oid string 32 not_null<br />

GV1_Organization<br />

colname coltype collen colflags comment<br />

oid string 32 not_null<br />

id string 255 not_null primary_key<br />

name string 255<br />

unit string 255<br />

address blob 65535 blob<br />

countrycode string 32<br />

state string 255<br />

city string 255<br />

web string 255<br />

status string 255<br />

mainContact_id string 255<br />

17 The mapping definitions are from<br />

http://www.objectmatter.com/vbsf/docs/maptool/ormapping.html.<br />

Page 40 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> architectural Support for inheritance<br />

GV1_BO<br />

colname coltype collen colflags comment<br />

oid string 32 not_null primary_key<br />

created_at date 10<br />

created_by string 255<br />

last_modified_at date 10<br />

last_modified_by string 255<br />

boclass string 255<br />

boshortname string 255<br />

bokey string 255<br />

bodbtable string 255<br />

locked_by string 255<br />

The CENTER, ORGANIZATION and BO tables are related to each other via the OID column. In<br />

this way, restoring a CENTER object with OID=100 requires a join of the tables CENTER,<br />

ORGANIZATION and BO:<br />

SELECT CENTER.*, ORGANIZATION.*, BO.*<br />

FROM CENTER c, ORGANIZATION o, BO b<br />

WHERE c.oid=oid AND o.oid=bo.oid AND oid=100;<br />

This approach closely resembles the class inheritance tree in the database, but might<br />

result in complex and time consuming queries on moderately deep inheritance hierarchies.<br />

Nevertheless this is the standard mapping approach that <strong>UML2PHP</strong> uses.<br />

Horizontal Mapping. Under horizontal mapping, each concrete class in the tree is<br />

mapped to a different table. Each of these mapped tables contains columns for all<br />

attributes in its concrete class, plus all attributes inherited from all its abstract parent<br />

classes. In other words, abstract classes are not mapped to their own table. This approach<br />

provides very fast performance, and is simple to design. However, if an attribute of an<br />

abstract parent class is changed, then potentially many tables must be modified.<br />

Consequently, this method is most useful if the inheritance tree is more method driven<br />

than attribute driven. To be more specific, if a substantial number of classes inherit a large<br />

number of attributes from an abstract parent class, then the vertical or filtered methods<br />

might be better choices.<br />

As shown in the table below, the number of tables necessary to map our sample model to<br />

a mySQL database using horizontal mapping is reduced to two. Retrieving a center or<br />

organization in this case involves querying only its corresponding table.<br />

GC1_Center<br />

colname coltype collen colflags comment<br />

oid string 32 not_null<br />

id string 255 not_null primary_key<br />

name string 255<br />

unit string 255<br />

Page 41 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> architectural Support for inheritance<br />

GC1_Center<br />

address blob 65535 blob<br />

countrycode string 32<br />

state string 255<br />

city string 255<br />

web string 255<br />

status string 255<br />

mainContact_id string 255<br />

created_at date 10<br />

created_by string 255<br />

last_modified_at date 10<br />

last_modified_by string 255<br />

boclass string 255<br />

boshortname string 255<br />

bokey string 255<br />

bodbtable string 255<br />

locked_by string 255<br />

GV1_Organization<br />

colname coltype collen colflags comment<br />

oid string 32 not_null<br />

id string 255 not_null primary_key<br />

name string 255<br />

unit string 255<br />

address blob 65535 blob<br />

countrycode string 32<br />

state string 255<br />

city string 255<br />

web string 255<br />

status string 255<br />

mainContact_id string 255<br />

created_at date 10<br />

created_by string 255<br />

last_modified_at date 10<br />

last_modified_by string 255<br />

boclass string 255<br />

boshortname string 255<br />

bokey string 255<br />

bodbtable string 255<br />

Page 42 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> architectural Support for inheritance<br />

GV1_Organization<br />

locked_by string 255<br />

With horizontal mapping it gets harder to navigate all the objects of the root and<br />

superclasses of the inheritance tree. This is one of the reasons, why this mapping<br />

approach is not yet supported by <strong>UML2PHP</strong>.<br />

Filtered Mapping. In filtered mapping all concrete classes in the tree are mapped to the<br />

same table. The table must contain columns for all attributes of all the abstract and<br />

concrete classes in the inheritance tree (or the part of the tree using this mapping). In<br />

addition, a filter column is created in the table. The value of the filter column is used to<br />

distinguish between subclasses. Abstract classes are not mapped to this table. This<br />

approach provides adequate performance, but violates table-normalization rules. More<br />

specifically, it could lead to a substantial number of NULL columns in the table, wasting<br />

space. Consequently, this method is most useful if most of the attributes are inherited from<br />

the abstract parent classes. As shown in the table below, only one table is necessary to<br />

map our sample model to a mySQL database using filtered mapping.<br />

GV1_BO<br />

colname coltype collen colflags comment<br />

oid string 32 not_null<br />

id string 255 not_null primary_key<br />

name string 255<br />

unit string 255<br />

address blob 65535 blob<br />

countrycode string 32<br />

state string 255<br />

city string 255<br />

web string 255<br />

status string 255<br />

mainContact_id string 255<br />

created_at date 10<br />

created_by string 255<br />

last_modified_at date 10<br />

last_modified_by string 255<br />

boclass string 255<br />

boshortname string 255<br />

bokey string 255<br />

bodbtable string 255<br />

locked_by string 255<br />

The boclass column is used as a filter used to distinguish the type of object being stored.<br />

For example, assuming that a boclass=”GV1_Organization” is used for organizations, then<br />

to retrieve all organizations from the GV1_BO table we can issue the following query:<br />

Page 43 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

<strong>UML2PHP</strong> architectural Support for inheritance<br />

SELECT o.oid, o.id,o.name, o.unit, o.address, o.countrycode, o.state, o.city, o.web, o.status<br />

FROM GV1_BO o WHERE boclass=’GV1_Organization’;<br />

The problem is that all column names that are derived from the organization attribute<br />

names need to be known to create this query. <strong>UML2PHP</strong> does not support filtered<br />

mapping.<br />

5.5 Mapping the UML inheritance to the GUI representation / Forms<br />

!!! Currently no special mapping is done. It’s intended to have the subclasses information<br />

on separate pages. You are invited to put feature requests on SourceForge for this<br />

feature.<br />

Page 44 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Generator<br />

6 Generator<br />

The Generator of <strong>UML2PHP</strong> is based on the smartGENERATOR technology by BITPlan.<br />

Fully detailled manuals and API information on smartGENERATOR is available with the<br />

Enterprise Version of <strong>UML2PHP</strong>. This reference manual is focussed on the visible parts of<br />

smartGENERATOR that you might need to interact with while using <strong>UML2PHP</strong>:<br />

Application Wizard<br />

Commandline Version of Generators<br />

Generator Transaction Dialog<br />

Error Handling and Exception Stack<br />

6.1 Application Wizard<br />

The application wizard is described in the tutorial for <strong>UML2PHP</strong><br />

6.2 Commandline Version of Generators<br />

The Generators for <strong>UML2PHP</strong> are delivered as jar files. You’ll find the four jar files:<br />

phpbobase.jar<br />

The full fledged business object generator that generators your PHP code for<br />

supporting business object based application<br />

Page 45 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Generator<br />

phpgen (now also in phpbobase.jar)<br />

The PHP5 language generator – this generator is for creating PHP5 code from UML<br />

models (without special handling for business objects)<br />

uml2php.jar<br />

This is the jar file that contains the application wizar<br />

smartGenerator.jar<br />

This is where the underlying smartGENERATOR technology is packaged into<br />

in the bin directory of your installation.<br />

6.2.1 General usage on the commandline<br />

Calling one of the generators from the commandline is done by one of the commands<br />

java -cp phpbobase.jar com.bitplan.phpgen.gen.phpgen<br />

or<br />

java –jar phpbobase.jar<br />

or<br />

java –jar uml2php.jar<br />

The first two calls will respond with a usage display. The third call will start the Application<br />

Wizard which was describe above.<br />

Here is an example for a usage display:<br />

BITPlan smartGENERATOR Version 4.0<br />

missing argument modelFilename<br />

usage: java com.bitplan.phpbobase.gen.phpbobase<br />

{the path of the model file}<br />

[] {the root directory for all output}<br />

-indexdir= {the output directory for generated index<br />

files}<br />

[-phpver=(5)] {the php version (3, 4 or 5)}<br />

[-checkpersistencecycle] {check persistence cycle}<br />

[-temproot=] {path to temporary directory for generation}<br />

[-removetemp] {set if temporary results shall be removed<br />

automatically}<br />

[-showtransaction] {set if a gui for the transaction shall be shown}<br />

[-automodify] {true if modifications shall be done without asking}<br />

[-allowPurposeRename] {true if usercode purpose is renameable}<br />

[-debug=(core)] {the debug mode once/core/all/off}<br />

[-log=] {the path of the logfile}<br />

[-edit] {set to invoke interactive editing of arguments}<br />

[-console] {if set a console window is opened}<br />

[-wait]<br />

{set if to wait for Console to be closed by user - needs -console<br />

to work}<br />

[-maxerrlevel=(0)] {maximum errorlevel to be<br />

tolerated}<br />

[-maxerrcount=(0)] {how many errors shall be<br />

tolerated}<br />

[-minMbyte=(0)] {how much discspace mandatory to<br />

continue}<br />

[-outputChangeListener=<br />

<br />

(com.bitplan.gen.output.impl.OutputChangeHandlerImpl)]<br />

{class to invoke on outputchanges}<br />

[-beforeModification=(cvs edit)]<br />

{command before Modification}<br />

Page 46 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Generator<br />

[-afterModification=] {command after<br />

Modification}<br />

[-modlistpath=]<br />

{set this path to create a list of all modified files}<br />

[-gencls=] {list of classes to generate}<br />

[-backupdir=] {the directory to use for continue with<br />

backup}<br />

[-cmdln] {operation in command line only modus}<br />

[-javadoc] {set if package javadoc shall be created}<br />

[-exceptionpackage=] {default exception package}<br />

[-baseexception=] {standard exception for operations}<br />

[-gencls=] {Classlist to generate}<br />

[-ini=] {the path of the property file}<br />

The details of most options are described in the manual of the Enterprise Version of<br />

<strong>UML2PHP</strong>. For basic usage in the community and professional edition the following<br />

options are relevant:<br />

{the path of the model file}<br />

The model file may be of any type that is supported by the smartGENERATOR<br />

technology: e.g. XMI export files from various tools, or Poseidon zuml files.<br />

] {the root directory for all output}<br />

<br />

The path to the root of the source tree to be generated<br />

-indexdir= {the output directory for generated index files}<br />

This is the relative path of the directory where the index file for class-autoloading<br />

support is generated to.<br />

[-phpver=(5)] {the php version (4 or 5)}<br />

There is only limited PHP4 code capability available and this is an unsupported<br />

feature, therefore the default is: 5<br />

<br />

[-checkpersistencecycle] {check persistence cycle}<br />

if true a persistence cycle check on the model will be performed and an exception is<br />

thrown if a cycle is detected (only for phpbobase.jar)<br />

6.2.2 Language only generator<br />

This generator basically only needs the model and the outputdirectory as input. It will<br />

generate PHP5 code for you.<br />

Here is an example of a valid call:<br />

java –cp bin\phpbobase.jar com.bitplan.phpgen.gen.phpgen<br />

php\uml2phpexamples\recipeCollection\model\recipecollection.zuml c:\temp\test\ -indexdir=.<br />

In principle it’s possible to call the phpbobase.jar Generator in the same way. But you then<br />

might want to also call the xml – Generator for the forms. An example Batch file would be:<br />

REM fill in or change as needed<br />

SET BPPATH=C:\PROGRA~1\BITPlan\<strong>UML2PHP</strong><br />

set UMLDir=<br />

set UMLNAME=<br />

set UMLEXT=zuml<br />

set OutDir=<br />

set IndexDir=<br />

set FormDir=<br />

set ReportDir=.\<br />

set FormSetName=<br />

set FormSetId=<br />

REM keep this as is<br />

SET BPCLASSPATH=%BPPATH%\bin\uml2php.jar;%BPPATH%\bin\phpbobase.jar;%BPPATH%\bin<br />

\phpgen.jar;%BPPATH%\bin\testutil.jar;%BPPATH%\bin\smartGenerator.jar;%CLASSPATH<br />

%<br />

Page 47 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Generator<br />

set UMLFile=%UMLDir%%UMLNAME%.%UMLEXT%<br />

REM gen content<br />

java com.bitplan.phpbobase.gen.phpbobase %UMLFile% %OutDir% -indexdir=%IndexDir% %1 %2 %3 %4<br />

java com.bitplan.phpbobase.gen.xml %UMLFile% %FormDir% -protocolid=%FormSetId% -<br />

protocolname=%FormSetName%<br />

6.3 Generator Transaction Dialog<br />

The generator transaction dialog appears if the principle of the generator “generate<br />

everything or nothing” fails. To follow this principle all generator results are first stored in a<br />

subdirectory “gen” of the temporary directory of your operating system. If the generator<br />

fails, due to an error in the input model, the generator itself, a full disk or any other<br />

circumstance that can be caught by the generator a generator transaction dialog will<br />

appear. This will also happen if everything is fine, but the files in the temporary directory<br />

will probably not be successfully copied to their finally destination since the destination<br />

files are readonly.<br />

The generator transaction dialog has 9 buttons:<br />

continue with backup - even if an error occurred – ignore it and do not even create<br />

a backup of the files involved<br />

continue with backup - even if an error occurred – ignore it but create a backup zip<br />

file of all the files involved before overwriting these files<br />

cancelTransaction – stop the transaction – do not overwrite any of the files that<br />

where to be generated<br />

showProblemsOnly – show a list of those files that caused problems<br />

Page 48 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Generator<br />

<br />

<br />

<br />

<br />

<br />

leftOverUserCode – if applicable shows a list of files that have a “left over user<br />

code” problem<br />

modifiedOutputsList - show a list of all files that would be modified when continuing<br />

the transaction<br />

myConsole – if applicable shows the console (that is the graphical output for stderr<br />

and stdout if it has been redirected)<br />

mySettingManager – show the settings for this generator<br />

myTargetDirectoriesList – show a list of all directories that are target directories for<br />

this generator run/transaction<br />

6.4 Error Handling<br />

In case an error should occur during the generation process the error might be handled in<br />

two ways:<br />

if a general error occurs and ExceptionStack is immediately displayed<br />

if the error occurs in the context of one of the files generated, but all other files<br />

could be generated successfully the exception is caught and you can navigate to<br />

the corresponding ExceptionStack thru the “showProblemsOnly” button of the<br />

generator transaction dialog<br />

6.4.1 ExceptionStack<br />

The field “Message” shows the original error message. The field “hint” might contain<br />

(sometimes a collection of) helpful information on what to do to solve the problem.<br />

Page 49 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Generator<br />

The ExceptionStack shows six different options:<br />

Ok – just continue with no action<br />

Cancel – stop the operation (if enabled – might even lead to a system exit – be<br />

careful to use this button)<br />

Report_EMail – report this problem to the vendor of the software (BITPlan)<br />

ShowDetail (show the details of this problem – a full history is displayed)<br />

StackTrace – show the Java stack trace to check the cause of the problem<br />

myContext – show the object which was the context for the problem (either using<br />

it’s own gui or by showing it’s properties depending on the type of object)<br />

6.4.2 Batch mode<br />

There is a command line parameter “-batch” now for the application wizard. If you this the<br />

Generators will automatically be started – but be cautious – no questions will be asked<br />

when overriding e.g. left over user code – it’s like clicking “continue withoutbackup” all the<br />

time.<br />

6.4.3 System.property expansion<br />

You can use a notation like ${uml2php_home} in you application Wizard configuration files<br />

to specify the outputdirectory, the model path or the template directory. You might want to<br />

Page 50 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Generator<br />

make sure that a valid Java system property is used or supplied by changing the java call<br />

of the generator with a –D option.<br />

Page 51 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Appendix<br />

7 Appendix<br />

7.1 Abbreviations<br />

Abbreviation Explanation Comment/URL/<strong>Reference</strong><br />

BO<br />

Business Object<br />

CORBA<br />

Common Object Request http://www.omg.org<br />

Broker Architecture<br />

CSS Cascading Style Sheet http://www.w3.org/Style/CSS/<br />

DB<br />

Database<br />

GUI<br />

Graphical User Interface<br />

IDL Interface Definition Language See CORBA Standard Chapter<br />

2.4<br />

LAMP<br />

Linux/Apache/MySQL/PHP<br />

MDA Model Driven Architecture http://www.omg.org/mda/<br />

PHP … Hypertext Preprocessor http://www.php.net<br />

PHP5 Version 5 of PHP http://www.php.net<br />

SSL Secure Socket Layer http://wp.netscape.com/eng/ssl3/<br />

SQL Structured Query Language International Organization for<br />

Standardization, Information<br />

Technology — Database<br />

Languages — SQL, ISO/IEC<br />

9075, 1992.<br />

UML Unified Modelling Language http://www.uml.org<br />

URL Uniform Resource Locator ftp://ftp.rfc-editor.org/innotes/rfc1738.txt<br />

WAMP<br />

Windows/Apache/MySQL/PHP<br />

W3C World Wide Web Consortium www.w3c.org<br />

7.2 Bibliography<br />

7.2.1 Recommended Literature<br />

<br />

Build your own database driven website using PHP&MySQL, Sitepoint Pty Ltd,<br />

Australia, ISBN 0-9579218-0-2<br />

German translation: Kevin Yank, PHP und MySQL Schritt für Schritt zur<br />

datenbankgestützten Website, 2003 dpunkt.verlag, ISBN 3-89864-198-8<br />

<br />

Harry Fuecks „The PHP Anthology“ ISBN-0-9579218-5-3, 2004 Sitepoint Pty Ltd,<br />

Australia<br />

German translation: “PHP5 für Fortgeschrittene”, 2005 dpunkt.verlag, ISBN 3-<br />

89864-300-X<br />

Page 52 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Appendix<br />

Sebastian Bergmann: "Professionelle Softwareentwicklung mit PHP 5"<br />

Objektorientierung. Entwurfsmuster. Modellierung. Fortgeschrittene<br />

Datenbankprogrammierung.<br />

dpunkt.verlag 2005. ISBN 3-89864-229-1.<br />

http://www.professionelle-softwareentwicklung-mit-php5.de/<br />

http://www.amazon.de/exec/obidos/ASIN/3898642291/sbergmann<br />

7.3 Web-Links<br />

7.3.1 Product-Manufacturers<br />

Category Product name Manufacturer URL<br />

PHP Development Zend Studio Zend http://www.zend.com<br />

Environment<br />

UML Tool Poseidon Gentleware http://www.uml.org<br />

7.3.2 Standards<br />

Standard Publisher URL<br />

CORBA OMG http://www.omg.org<br />

UML OMG http://www.uml.org<br />

Page 53 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Index<br />

8 Index<br />

A<br />

Abstraction 12<br />

Apache 5<br />

Attribute 13, 17<br />

autogenerate 16<br />

autoKey 17<br />

B<br />

BO 9, 52<br />

bootmode 24, 25<br />

bpcommon_Debug 31<br />

by<strong>Reference</strong> 22<br />

C<br />

catalog 17<br />

catalogtype 18<br />

certificateFunction 23<br />

cgi-bin 22<br />

charWidth 19<br />

checkBoxDisplayLimit 23<br />

Class 12, 15, 16<br />

config.inc 22<br />

confirm 20<br />

CORBA 8, 14, 33, 52<br />

CSS 12, 32<br />

D<br />

Database 28<br />

database connection 23<br />

datatype 8, 26<br />

DataType 12, 15<br />

DB 9, 52<br />

dbmachine 23<br />

dbname 23<br />

dbpassword 23<br />

dbsqltype 23<br />

DBTable 29<br />

dbuser 23<br />

debug 23<br />

Debug 31<br />

default 22<br />

derivedfrom 18<br />

do not generate 15<br />

Documentation 12, 13<br />

downloadDirectory 23<br />

Dynamic List 27<br />

E<br />

Enumeration 27<br />

ExceptionStack 49<br />

Export-Directory 15<br />

F<br />

final 16, 17, 19<br />

Form 9<br />

FunctionCall 8<br />

G<br />

GUI 9, 10, 52<br />

H<br />

hasBOManager 21, 22<br />

I<br />

icon 20, 21<br />

IDL 8, 52<br />

Inheritance 12<br />

In-Parameter 12<br />

Interface 15<br />

isDefaultSearchField 18<br />

isGUI 16, 20, 21<br />

isKey 17<br />

isMandatory 18<br />

isSaveable 17<br />

L<br />

label 18<br />

LAMP 52<br />

List 27<br />

M<br />

MDA 6, 52<br />

Model 15<br />

Multiplicity 13<br />

MySQL 5<br />

N<br />

N:M 12<br />

Namespace 12<br />

Navigation 13<br />

nojavascriptmenu 30<br />

Null Value 11<br />

NULL_VALUE_DISPLAY<br />

11<br />

O<br />

Operation 12<br />

ORB 8<br />

Organization 24<br />

Out-Parameter 13<br />

P<br />

Package 12, 16<br />

packageName 22<br />

Parameter 12<br />

PEAR 5<br />

persistent 30<br />

PHP 9, 52<br />

PHP5 5 see PHP<br />

phpbobase 23<br />

Poseidon 5<br />

R<br />

RegExp 19<br />

Relation 13<br />

Return-Value 13<br />

Role 13<br />

Page 54 / 55<br />

© 2004-2008 BITPlan GmbH


<strong>UML2PHP</strong> <strong>Reference</strong> <strong>Manual</strong><br />

S M A R T S O<br />

L U T I<br />

O<br />

N S<br />

Index<br />

S<br />

Secure Socket Layer See<br />

SSL<br />

selectAction 19<br />

selectDesc 19<br />

showInGrid 18, 25<br />

smartGENERATOR 5, 45<br />

sortPos 17, 25<br />

SQL 52<br />

SQLView 16<br />

SSL 24, 52<br />

stereotype 15<br />

SystemConfiguration: 23<br />

T<br />

Table 9<br />

Tagged Value 12<br />

Template 16<br />

TemplateOptions 16<br />

timeoutSecs 23<br />

ToolName 15<br />

toolTipText 16, 19, 20, 21<br />

transient 21<br />

U<br />

UML 5, 14, 52<br />

<strong>UML2PHP</strong> 5<br />

Unified Modelling<br />

Language See UML<br />

unit 18<br />

URL Parameter 30<br />

User 9, 24<br />

UserRole 24<br />

V<br />

Visibility 13<br />

W<br />

W3C 12, 31<br />

WAMP 52<br />

X<br />

XMIBaseId 16<br />

XMIId 16, 19, 20, 21<br />

XMLasNode 19<br />

XMLderived 17, 19<br />

XMLtransient 17, 19<br />

Y<br />

Y-Principle 6<br />

Page 55 / 55<br />

© 2004-2008 BITPlan GmbH

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

Saved successfully!

Ooh no, something went wrong!