System Design Tools

28
System Design Tools Albert Guo [email protected] 1 2009年1月4日星期日

Transcript of System Design Tools

Page 1: System Design Tools

System Design ToolsAlbert Guo

[email protected]

12009年1月4日星期日

Page 2: System Design Tools

Agenda

Scenario

System Design Process

Design ER Diagram by JDeveloper

Generate DB schema diagram via SchemaSpy

Generate artifacts by MyEclipse

Refactor artifacts automatically via ant

Q&A

22009年1月4日星期日

Page 3: System Design Tools

Scenario

32009年1月4日星期日

Page 4: System Design Tools

System Design Process

42009年1月4日星期日

Page 5: System Design Tools

Design ER Diagram by JDeveloper

52009年1月4日星期日

Page 6: System Design Tools

JDeveloper Studio

JDeveloper StudioIt contains all the features of the product - including ADF, SOA, J2EE, UML, Database, Java, and XML. This download includes JDK 5.0.5 and is supported on Windows XP, 2003 and 2000.

I used this tool to do schema design and draw ER diagram. It will create / update / delete tables, columns and constraints synchrnously as I edit ER diagram.

62009年1月4日星期日

Page 8: System Design Tools

82009年1月4日星期日

Page 9: System Design Tools

Generate DB schema diagram via SchemaSpy

92009年1月4日星期日

Page 10: System Design Tools

SchemaSpy

SchemaSpySchemaSpy is a Java-based tool that analyzes the metadata of a schema in a database and generates a visual representation of it in a browser-displayable format.

Download: http://schemaspy.sourceforge.net/

SchemaSpy requires:1. Java 1.4 or higher

2. Graphviz: http://www.graphviz.org/

I use ant to execute command to generate schema document.

102009年1月4日星期日

Page 11: System Design Tools

SchemaSpy

Regarding its commands, please go to here to check: http://schemaspy.sourceforge.net/I had integrated its commands into ant script, so I can reuse it easily.

112009年1月4日星期日

Page 12: System Design Tools

Ant build script

<?xml version="1.0" encoding="UTF-8"?><project name="schemaspy" default=" schemaspy "> <property name="reports.dir" value="C:\rs-schema"/> <tstamp> <format property="CURRENT_DATETIME" pattern="yyyy/MM/dd HH:mm" /> </tstamp> <target name="schemaspy"> <java jar="D:/jar/schemaSpy_4.1.1.jar" output="${reports.dir}/output.log" error="${reports.dir}/error.log" fork="true"> <arg line="-cp d:/jar/ojdbc14.jar;C:/Program Files/Graphviz 2.21/bin"/> <arg line="-t orathin"/> <arg line="-host 10.9.164.101"/> <arg line="-port 1521"/> <arg line="-db RSDB"/> <arg line="-u username"/> <arg line="-p password"/> <arg line="-s RSDB"/> <arg line="-o ${reports.dir}"/> <arg line="-ahic"/> </java> <tstamp> <format property="CURRENT_DATETIME" pattern="yyyy/MM/dd HH:mm" /> </tstamp> <echo>Schema Report had been generated to ${reports.dir} at ${CURRENT_DATETIME}</echo> </target>

122009年1月4日星期日

Page 13: System Design Tools

SchemaSpy Analysis Report

list all tables in this list

132009年1月4日星期日

Page 14: System Design Tools

SchemaSpy Analysis Report

show the table relationships

142009年1月4日星期日

Page 15: System Design Tools

Generate artifacts by MyEclipse

152009年1月4日星期日

Page 16: System Design Tools

Generate artifacts by MyEclipse

Artifacts includeEntities

DAOs

persistence.xml

162009年1月4日星期日

Page 17: System Design Tools

select tables which you want to do DTO generation in database explore view

172009年1月4日星期日

Page 18: System Design Tools

decide these artifacts will be generated into which project and in which package

check this checkbox to tell MyEclipse to geneate DTOs, and also update these DTOs to persistence.xml

click Finish button to get DTOs generation process done.

182009年1月4日星期日

Page 19: System Design Tools

MyEclipse had generated DTOs and also updated its persistence.xml

192009年1月4日星期日

Page 20: System Design Tools

DTOs which generated by MyEclipse. It just full of getter and setter method.

202009年1月4日星期日

Page 21: System Design Tools

Then we go to Database Explorer view to generate DAOs

212009年1月4日星期日

Page 22: System Design Tools

decide these artifacts should be generated to which project and which package.

check this checkbox to tell MyEclipse to generate DAOs

Click on the Finish button to get the DAOs generation process done.

222009年1月4日星期日

Page 23: System Design Tools

The artifacts which had been generated by MyEclipse

232009年1月4日星期日

Page 24: System Design Tools

These methods which had been generated, you may can customize it to fulfill your requirements.

242009年1月4日星期日

Page 25: System Design Tools

Refactor artifacts automatically via ant

252009年1月4日星期日

Page 26: System Design Tools

Refactor artifacts automatically via ant

Refactor rules for entities1. implement one more interface: Persistable

2. import one more class: import ht.fc.entity.essential.Persistable;

3. modify object ID generation rules: @Id@TableGenerator(name = "IDGEN", table = "htsequence", pkColumnName = "sequence", allocationSize=1)

4. eliminate @Basic(optional = false), and its import class

262009年1月4日星期日

Page 27: System Design Tools

Refactor artifacts automatically via ant

<property name="entity.dir" value="D:\work\test\src\java\com\htc\hr\entity"/> <target name="refactorEntity"> <echo>refactor entities...</echo> <replace dir="${entity.dir}" value='@Id@TableGenerator(name = "IDGEN", table = "htsequence", pkColumnName = "sequence", allocationSize=1)'> <include name="**/*.java" /> <replacetoken>@Id</replacetoken> </replace>

<replace dir="${entity.dir}" value=""> <include name="**/*.java" /> <replacetoken>@Basic(optional = false)</replacetoken> </replace>

<replace dir="${entity.dir}" value=""> <include name="**/*.java" /> <replacetoken>import javax.persistence.Basic;</replacetoken> </replace>

<replace dir="${entity.dir}" value='import ht.fc.entity.essential.Persistable;import java.io.Serializable;import javax.persistence.TableGenerator;'> <include name="**/*.java" /> <replacetoken>import java.io.Serializable;</replacetoken> </replace>

<replace dir="${entity.dir}" value="implements Serializable, Persistable"> <include name="**/*.java" /> <replacetoken>implements Serializable</replacetoken> </replace>

<tstamp> <format property="CURRENT_DATETIME" pattern="yyyy/MM/dd HH:mm" /> </tstamp> <echo>refactor entities had finished at ${CURRENT_DATETIME}</echo> </target>

272009年1月4日星期日

Page 28: System Design Tools

Q&A

282009年1月4日星期日