Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Feature to Output Description for MSSQL #15

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ Install the following eclipse plugins:

License
--------
[Eclipse Public License 1.0](http://opensource.org/licenses/eclipse-1.0.php)
[Eclipse Public License 2.0] (https://www.eclipse.org/legal/epl-2.0/)

History
--------
### 2020/11/11 - AmaterasModeler 2.0.5

- include table description into DDL when generating using MS SQL dialect

### 2020/11/10 - AmaterasModeler 2.0.4

- include column description into DDL when generating using MS SQL dialect

### 2020/10/18 - AmaterasModeler 2.0.0

- Java11 Support
Expand Down
4 changes: 2 additions & 2 deletions erd-tools/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

<mkdir dir="./tmp/classes" />
<unjar src="./tmp/commons-lang-2.0.jar" dest="./tmp/classes" />
<unjar src="./tmp/dom4j-1.3.jar" dest="./tmp/classes" />
<unjar src="./tmp/dom4j-1.6.1.jar" dest="./tmp/classes" />
<unjar src="./tmp/jdom-1.0.jar" dest="./tmp/classes" />
<unjar src="./tmp/jmock-2004-03-19.jar" dest="./tmp/classes" />
<unjar src="./tmp/joda-time-1.0.jar" dest="./tmp/classes" />
<unjar src="./tmp/joda-time-1.6.jar" dest="./tmp/classes" />
<unjar src="./tmp/stax-api-1.0.jar" dest="./tmp/classes" />
<unjar src="./tmp/xml-writer-0.2.jar" dest="./tmp/classes" />
<unjar src="./tmp/xom-1.0b3.jar" dest="./tmp/classes" />
Expand Down
Binary file modified erd-tools/lib/amateras-erd.jar
Binary file not shown.
36 changes: 18 additions & 18 deletions erd-tools/sample/sample.erd
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<children>
<net.java.amateras.db.visual.model.TableModel>
<tableName>USER_INFO</tableName>
<logicalName>ユーザ情報</logicalName>
<logicalName>ユーザ情報</logicalName>
<description></description>
<columns>
<net.java.amateras.db.visual.model.ColumnModel>
<columnName>USER_ID</columnName>
<logicalName>ユーザID</logicalName>
<logicalName>ユーザID</logicalName>
<columnType class="net.java.amateras.db.dialect.ColumnType">
<name>INTEGER</name>
<logicalName>整数</logicalName>
<logicalName>æ•´æ•°</logicalName>
<supportSize>false</supportSize>
<type>4</type>
</columnType>
Expand All @@ -23,10 +23,10 @@
<defaultValue></defaultValue>
<dommain>
<id>12101269426330</id>
<name>ユーザID</name>
<name>ユーザID</name>
<type class="net.java.amateras.db.dialect.ColumnType">
<name>VARCHAR</name>
<logicalName>文字列</logicalName>
<logicalName>文字列</logicalName>
<supportSize>true</supportSize>
<type>12</type>
</type>
Expand All @@ -35,10 +35,10 @@
</net.java.amateras.db.visual.model.ColumnModel>
<net.java.amateras.db.visual.model.ColumnModel>
<columnName>GROUP_ID</columnName>
<logicalName>グループID</logicalName>
<logicalName>グループID</logicalName>
<columnType class="net.java.amateras.db.dialect.ColumnType">
<name>INTEGER</name>
<logicalName>整数</logicalName>
<logicalName>æ•´æ•°</logicalName>
<supportSize>false</supportSize>
<type>4</type>
</columnType>
Expand All @@ -51,10 +51,10 @@
</net.java.amateras.db.visual.model.ColumnModel>
<net.java.amateras.db.visual.model.ColumnModel>
<columnName>MAIL</columnName>
<logicalName>メールアドレス</logicalName>
<logicalName>メールアドレス</logicalName>
<columnType class="net.java.amateras.db.dialect.ColumnType">
<name>INTEGER</name>
<logicalName>整数</logicalName>
<logicalName>æ•´æ•°</logicalName>
<supportSize>false</supportSize>
<type>4</type>
</columnType>
Expand All @@ -66,14 +66,14 @@
<defaultValue></defaultValue>
<dommain>
<id>12101269431961</id>
<name>メールアドレス</name>
<name>メールアドレス</name>
<type class="net.java.amateras.db.dialect.ColumnType" reference="../../../net.java.amateras.db.visual.model.ColumnModel/dommain/type"/>
<size>100</size>
</dommain>
</net.java.amateras.db.visual.model.ColumnModel>
<net.java.amateras.db.visual.model.ColumnModel>
<columnName>PASSWORD</columnName>
<logicalName>パスワード</logicalName>
<logicalName>パスワード</logicalName>
<columnType class="net.java.amateras.db.dialect.ColumnType" reference="../../net.java.amateras.db.visual.model.ColumnModel[3]/columnType"/>
<size>10</size>
<notNull>false</notNull>
Expand All @@ -84,7 +84,7 @@
</net.java.amateras.db.visual.model.ColumnModel>
<net.java.amateras.db.visual.model.ColumnModel>
<columnName>NAME</columnName>
<logicalName>氏名</logicalName>
<logicalName>��</logicalName>
<columnType class="net.java.amateras.db.dialect.ColumnType" reference="../../net.java.amateras.db.visual.model.ColumnModel[3]/columnType"/>
<size>10</size>
<notNull>false</notNull>
Expand Down Expand Up @@ -119,12 +119,12 @@
<entry>
<net.java.amateras.db.visual.model.ColumnModel>
<columnName>GROUP_ID</columnName>
<logicalName>グループID</logicalName>
<logicalName>グループID</logicalName>
<columnType class="net.java.amateras.db.dialect.ColumnType" reference="../../../../../../columns/net.java.amateras.db.visual.model.ColumnModel[2]/columnType"/>
<size>10</size>
<notNull>false</notNull>
<primaryKey>true</primaryKey>
<description></description>
<description>testing group id description</description>
<autoIncrement>false</autoIncrement>
<defaultValue></defaultValue>
</net.java.amateras.db.visual.model.ColumnModel>
Expand All @@ -134,16 +134,16 @@
<source class="net.java.amateras.db.visual.model.TableModel" reference="../../.."/>
<target class="net.java.amateras.db.visual.model.TableModel">
<tableName>GROUP</tableName>
<logicalName>グループ</logicalName>
<logicalName>グループ</logicalName>
<description></description>
<columns>
<net.java.amateras.db.visual.model.ColumnModel reference="../../../references/entry/net.java.amateras.db.visual.model.ColumnModel"/>
<net.java.amateras.db.visual.model.ColumnModel>
<columnName>GROUP_NAME</columnName>
<logicalName>グループ名</logicalName>
<logicalName>グループ�</logicalName>
<columnType class="net.java.amateras.db.dialect.ColumnType">
<name>VARCHAR</name>
<logicalName>文字列</logicalName>
<logicalName>文字列</logicalName>
<supportSize>true</supportSize>
<type>12</type>
</columnType>
Expand Down Expand Up @@ -204,7 +204,7 @@
<net.java.amateras.db.visual.model.DommainModel reference="../../children/net.java.amateras.db.visual.model.TableModel/columns/net.java.amateras.db.visual.model.ColumnModel/dommain"/>
<net.java.amateras.db.visual.model.DommainModel reference="../../children/net.java.amateras.db.visual.model.TableModel/columns/net.java.amateras.db.visual.model.ColumnModel[3]/dommain"/>
</dommains>
<dialectName>PostgreSQL</dialectName>
<dialectName>MSSQL</dialectName>
<logicalMode>false</logicalMode>
<jarFile></jarFile>
<jdbcDriver>sun.jdbc.odbc.JdbcOdbc</jdbcDriver>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.java.amateras.db.dialect;

import java.sql.Types;
import java.text.MessageFormat;

import net.java.amateras.db.Messages;
import net.java.amateras.db.visual.model.ColumnModel;
Expand All @@ -12,6 +13,9 @@
* @since 1.0.8
*/
public class MSSQLDialect extends AbstractDialect {

private static final String DESC_TPL = "EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'$desc' , @level0type=N'SCHEMA',@level0name=N'$schema', @level1type=N'TABLE',@level1name=N'$table', @level2type=N'COLUMN',@level2name=N'$column'";
private static final String DESC_TBL_TPL = "EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'$desc' , @level0type=N'SCHEMA',@level0name=N'$schema', @level1type=N'TABLE',@level1name=N'$table'";

private static final IColumnType[] COLUMN_TYPES = {
new ColumnType("BIT", Messages.getResourceString("type.bit"), false, Types.BIT),
Expand Down Expand Up @@ -54,6 +58,36 @@ protected String createColumnDDL(RootModel root, TableModel tableModel,
}
return ddl;
}

/**
* 20201109 JIM - override this to add column descriptions in MSSQL
*/
@Override
protected void setupTableOption(RootModel root, TableModel model,
boolean schema, boolean drop, boolean alterTable, boolean comment,
StringBuilder additions, StringBuffer sb) {
super.setupTableOption(root, model, schema, drop, alterTable, comment, additions, sb);
if(comment) {
additions.append(LS);
if(model.getDescription() != null && !model.getDescription().isEmpty()) {
String s = DESC_TBL_TPL.replace("$desc", model.getDescription());
s = s.replace("$schema", root.getJdbcSchema());
s = s.replace("$table", model.getTableName());
additions.append(s).append(separator).append(LS);
}
for(ColumnModel cm : model.getColumns()) {
if(cm.getDescription()==null || cm.getDescription().isEmpty()) {
continue;
}

String s = DESC_TPL.replace("$desc", cm.getDescription());
s = s.replace("$schema", root.getJdbcSchema());
s = s.replace("$table", model.getTableName());
s = s.replace("$column", cm.getColumnName());
additions.append(s).append(separator).append(LS);
}
}
}

@Override
public String getColumnMetadataSQL(String tableName) {
Expand Down
6 changes: 3 additions & 3 deletions net.java.amateras.modeler/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<feature
id="net.java.amateras.modeler"
label="Amateras Modeler"
version="2.0.0.qualifier"
version="2.0.5.qualifier"
provider-name="Project Amateras">

<description url="http://www.example.com/description">
[Enter Feature Description here.]
[modified from original Amasteras project]
</description>

<copyright url="http://www.example.com/copyright">
[Enter Copyright Description here.]
[all rights belongs to original Amasteras creator]
</copyright>

<license url="http://www.example.com/license">
Expand Down
Binary file not shown.