001 /*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016 package org.opengion.plugin.table;
017
018 /**
019 * TableFilter_TABLE_SQLSERVER は、TableUpda インターフェースを継承した、DBTableModel 処?の
020 * 実?ラスです?とくに、SQLServer用のDB定義スクリプトを作?します?
021 *
022 * ここでは、テーブル?の検索結果より、GF05 の??ブルカラ?義??ブルから
023 * ?な??を取得し、テーブル作?スクリプトを作?します?
024 * 出力ファイルは、テーブル名?S.sql" と?命名規則で作?します?
025 * 検索では?SYSTEM_ID,TBLSYU,TABLE_NAME,NAME_JA,TABLESPACE_NAME,INITIAL_EXTENT,NEXT_EXTENT,COMMENTS)
026 * の?を取得する?があります?
027 *
028 * @og.rev 4.0.0.0 (2005/08/31) 新規作?
029 *
030 * @version 0.9.0 2000/10/17
031 * @author Kazuhiko Hasegawa
032 * @since JDK1.1,
033 */
034 public class TableFilter_TABLE_SQLSERVER extends TableFilter_TABLE {
035 //* こ?プログラ??VERSION??を設定します? {@value} */
036 private static final String VERSION = "5.1.1.0 (2009/12/01)" ;
037
038 /**
039 * ?部?カラ?義)の処?実行します?
040 *
041 * @og.rev 5.1.1.0 (2009/12/01) ?ラ??説明を追?
042 *
043 * @param data ?行?の??タ配?
044 * @param first ??の行かど?[true:??/false:それ以降]
045 *
046 * @return ?部?カラ?義)配?
047 */
048 @Override
049 protected String[] makeLineList( final String[] data,final boolean first ) {
050
051 String clsName = data[GF05_CLS_NAME] ;
052
053 // 5.1.1.0 (2009/12/01) ?ラ??説明文?入れたくな??合?、null を設定する?
054 if( isXml ) { data[GF05_NAME_JA] = null; }
055
056 if( "UNIQ".equalsIgnoreCase( data[GF05_CLM] ) || "UNIQSEQ".equalsIgnoreCase( data[GF05_CLM] ) ) {
057 data[GF05_CLS_NAME] = "int IDENTITY(1,1)";
058 data[GF05_DATA_DEFAULT] = null;
059 data[GF05_NOT_NULL] = null;
060 data[GF05_USE_LENGTH] = null;
061 }
062 else if( clsName == null || clsName.length() == 0 || clsName.startsWith( "VARCHAR" ) ) {
063 data[GF05_CLS_NAME] = "varchar" ;
064 }
065 else if( clsName.startsWith( "CLOB" ) ) {
066 data[GF05_CLS_NAME] = "text";
067 data[GF05_DATA_DEFAULT] = null;
068 data[GF05_NOT_NULL] = null;
069 data[GF05_USE_LENGTH] = null;
070 }
071 else if( clsName.startsWith( "DATE" ) ) {
072 data[GF05_CLS_NAME] = "datetime";
073 data[GF05_DATA_DEFAULT] = null;
074 data[GF05_NOT_NULL] = null;
075 data[GF05_USE_LENGTH] = null;
076 }
077 else if( clsName.startsWith( "NUMBER" ) || clsName.startsWith( "LONG" ) ) {
078 String len = data[GF05_USE_LENGTH] ;
079 if( len.indexOf( ',' ) >= 0 ) { // カンマがある
080 data[GF05_CLS_NAME] = "decimal";
081 data[GF05_USE_LENGTH] = null;
082 }
083 else if( Integer.parseInt( len ) >= 10 ) { // ?0桁以?
084 data[GF05_CLS_NAME] = "float";
085 data[GF05_USE_LENGTH] = null;
086 }
087 else {
088 data[GF05_CLS_NAME] = "int";
089 data[GF05_USE_LENGTH] = null;
090 }
091 }
092
093 return super.makeLineList( data,first );
094 }
095
096 /**
097 * 定義の??部??処?実行します?
098 *
099 * @param clmNo カラ?号配?
100 * @param data ?行?の??タ配?
101 *
102 * @return 定義の??部?
103 */
104 @Override
105 protected String makeEndLine( final int[] clmNo,final String[] data ) {
106 return ( isXml ? ")" + EXEC_END_TAG : ");" );
107 }
108
109 /**
110 * ユニ?クシーケンスの作?処?実行します?
111 *
112 * @param clmNo カラ?号配?
113 * @param data ?行?の??タ配?
114 *
115 * @return ユニ?クシーケンス
116 */
117 @Override
118 protected String makeUniqSeq( final int[] clmNo,final String[] data ) {
119 return "";
120 }
121
122 /**
123 * ユニ?クシーケンスと関連付けるトリガの作?処?実行します?
124 *
125 * @param clmNo カラ?号配?
126 * @param data ?行?の??タ配?
127 * @param uniqName ユニ?クトリガ?
128 *
129 * @return ユニ?クシーケンスと関連付けるトリガ
130 */
131 @Override
132 protected String makeUniqTrig( final int[] clmNo,final String[] data, final String uniqName ) {
133 return "";
134 }
135 }