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.query;
017    
018    import org.opengion.hayabusa.common.HybsSystem;
019    import org.opengion.hayabusa.db.DBConstValue;
020    
021    /**
022     * ãƒ??タベã?ス登録時ã«ã€å›ºå®šå?カラãƒ??è¨­å®šã‚’è¡Œã†æƒ??を管ç?™ã‚‹ã‚¯ãƒ©ã‚¹ã§ã™ã?
023     * ã“ã?クラスã¯ã€GrowingMIS用ã®ç®¡ç?‚¯ãƒ©ã‚¹ã§ã™ã?
024     * 具体的ã«ã¯ã€?
025     *     更新フラグ  FGJ
026     *     作æ?æ—¥æ™?   DYSET
027     *     作æ?社員    USRSET
028     *     更新日�   DYUPD
029     *     更新社員    DYUPD
030     *     æ›´æ–°?°?§    PGUPD
031     * ãªã©ã®æƒ??ã‚’ã?INSERTã€UPDATE ã®çжæ³ã«å¿œã˜ã¦æä¾›ã—ã¾ã™ã?
032     * INSERT ã«ã¯ã€ã™ã¹ã¦ã®æƒ??(XXUPD)ã«ã‚‚å?ã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?
033     * ã“れã¯ã€UPDATE ã•ã‚ŒãŸæ—¥ä»˜ã‚„時刻ã§ã€ä¸?¦§æ¤œç´¢ã§ãるよã†ã«ã™ã‚‹ç‚ºã§ã€?
034     * null ã«ã—ã¦ãŠãã¨ã€IS NULL ã§å•ã„åˆã‚ã›ã‚‹å¿?¦ãŒã‚りã¾ã™ã?
035     * INSERT ãƒ??ã‚¿ã?‘å–å?ã™å?åˆã?ã€WHERE DYSET = DYUPD ã¨ã—ã¾ã™ã?
036     *
037     * コンストラクターã§ã¯ã€ãƒ†ãƒ¼ãƒ–ルåã?ユーザーID,ç”»é¢ID ã‚’å—ã‘å–りã¾ã™ã?
038     * 登録時刻ã¯ã€ã“ã®ã‚ªãƒ–ジェクトãŒç”Ÿæ?ã•ã‚ŒãŸæ™‚間を通常ã¯ä½¿ç”¨ã—ã¾ã™ã?
039     * ãƒ??ブルåを渡ã™ã?ã¯ã€ãƒ¯ãƒ¼ã‚¯ãªã©ã€ãƒ†ãƒ¼ãƒ–ルå˜ä½ã«å‡¦ç?™ã‚‹ã‚«ãƒ©ãƒ?Œ
040     * ç•°ãªã‚‹ã?ã§ã€ãれã¸ã®å¯¾å¿œã§ã™ã?
041     * 処ç?Œç°¡ç´?Œ–ã§ãるよã†ã«ã€ãƒ«ãƒ¼ãƒ«ã‚’è¦å®šã™ã¹ãã§ã™ã?
042     *
043     * @og.rev 4.1.2.0 (2008/03/12) æ–°è¦è¿½åŠ?
044     * @og.group �?タ登録
045     *
046     * @version  4.0
047     * @author   Kazuhiko Hasegawa
048     * @since    JDK5.0,
049     */
050    public class DBConstValue_GE implements DBConstValue {
051            //* ã“ã?プログラãƒ??VERSIONæ–?­—å?を設定ã—ã¾ã™ã?       {@value} */
052            private static final String VERSION = "4.3.7.0 (2009/06/01)" ;
053    
054            private static final String[] MSTR_INSKEYS =
055                    new String[] { "FGJ","DYSET","DYUPD","USRSET","USRUPD","PGUPD" };
056    
057            private static final String[] MSTR_UPDKEYS =
058                    new String[] { "FGJ","DYUPD","USRUPD","PGUPD" };
059    
060            private static final String[] MSTR_LOGDELKEYS = // 4.3.7.0 (2009/06/01)
061                    new String[] { "FGJ","DYUPD","USRUPD","PGUPD" };
062    
063            private static final String[] ZERO = new String[0] ;
064    
065            private String[] insKeys = ZERO;
066            private String[] insVals = ZERO;
067    
068            private String[] updKeys = ZERO;
069            private String[] updVals = ZERO;
070    
071            private String[] logDelKeys = ZERO; // 4.3.7.0 (2009/06/01)
072            private String[] logDelVals = ZERO; // 4.3.7.0 (2009/06/01)
073    
074            /**
075             * åˆæœŸåŒ–情報を設定ã—ã¾ã™ã?
076             *
077             * @param       table   ãƒ??ブルå?
078             * @param       user    ユーザーID
079             * @param       gamen   ç”»é¢ID
080             */
081            public void init( final String table, final String user, final String gamen ) {
082                    if( isUseClm( table ) ) {
083                            String userID  = "'" + user + "'";
084                            String gamenID = "'" + gamen + "'";
085                            String timestamp = "'" + HybsSystem.getDate( "yyyyMMddHHmmss" ) + "'" ;
086    
087                            insKeys = MSTR_INSKEYS;
088                            insVals = new String[] {
089                                                             "'1'"                  // FGJ
090                                                            ,timestamp              // DYSET
091                                                            ,timestamp              // DYUPD
092                                                            ,userID                 // USRSET
093                                                            ,userID                 // USRUPD
094                                                            ,gamenID                // PGUPD
095                            };
096    
097                            updKeys = MSTR_UPDKEYS;
098                            updVals = new String[] {
099                                                             "'1'"                  // FGJ
100                                                            ,timestamp              // DYUPD
101                                                            ,userID                 // USRUPD
102                                                            ,gamenID                // PGUPD
103                            };
104    
105                            // 4.3.7.0 (2009/06/01)
106                            logDelKeys = MSTR_LOGDELKEYS;
107                            logDelVals = new String[] {
108                                                             "'9'"                  // FGJ
109                                                            ,timestamp              // DYUPD
110                                                            ,userID                 // USRUPD
111                                                            ,gamenID                // PGUPD
112                            };
113                    }
114            }
115    
116            /**
117             * インサートã™ã‚‹å?åˆã?キーé…å?ã‚’è¿”ã—ã¾ã™ã?
118             *
119             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
120             *
121             * @og.rev 4.3.1.1 (2008/08/23) 変更å¯èƒ½ãªã‚ªãƒ–ジェクトã?å‚ç?を直接返ã•ãªã?‚ˆã?«ã—ã¾ã™ã?
122             *
123             * @return      インサートã™ã‚‹å?åˆã?キーé…å?(éžnull)
124             */
125            public String[] getInsertKeys() {
126    //              return insKeys ;
127                    return insKeys.clone();
128            }
129    
130            /**
131             * インサートã™ã‚‹å?åˆã?値é…å?ã‚’è¿”ã—ã¾ã™ã?
132             *
133             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
134             *
135             * @og.rev 4.3.1.1 (2008/08/23) 変更å¯èƒ½ãªã‚ªãƒ–ジェクトã?å‚ç?を直接返ã•ãªã?‚ˆã?«ã—ã¾ã™ã?
136             *
137             * @return      インサートã™ã‚‹å?åˆã?キーé…å?(éžnull)
138             */
139            public String[] getInsertVals() {
140    //              return insVals ;
141                    return insVals.clone();
142            }
143    
144            /**
145             * ã‚¢ãƒ??ãƒ??トã™ã‚‹å?åˆã?キーé…å?ã‚’è¿”ã—ã¾ã™ã?
146             *
147             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
148             *
149             * @og.rev 4.3.1.1 (2008/08/23) 変更å¯èƒ½ãªã‚ªãƒ–ジェクトã?å‚ç?を直接返ã•ãªã?‚ˆã?«ã—ã¾ã™ã?
150             *
151             * @return      ã‚¢ãƒ??ãƒ??トã™ã‚‹å?åˆã?キーé…å?(éžnull)
152             */
153            public String[] getUpdateKeys() {
154    //              return updKeys ;
155                    return updKeys.clone();
156            }
157    
158            /**
159             * ã‚¢ãƒ??ãƒ??トã™ã‚‹å?åˆã?値é…å?ã‚’è¿”ã—ã¾ã™ã?
160             *
161             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
162             *
163             * @og.rev 4.3.1.1 (2008/08/23) 変更å¯èƒ½ãªã‚ªãƒ–ジェクトã?å‚ç?を直接返ã•ãªã?‚ˆã?«ã—ã¾ã™ã?
164             *
165             * @return      ã‚¢ãƒ??ãƒ??トã™ã‚‹å?åˆã?キーé…å?(éžnull)
166             */
167            public String[] getUpdateVals() {
168    //              return updVals ;
169                    return updVals.clone();
170            }
171    
172            /**
173             * ãƒ?ƒªãƒ¼ãƒ?è«–ç†å‰Šé™¤) ã™ã‚‹å ´åˆã?キーé…å?ã‚’è¿”ã—ã¾ã™ã?
174             *
175             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
176             *
177             * @og.rev 4.3.7.0 (2009/06/01) æ–°è¦ä½œæ?
178             *
179             * @return      ãƒ?ƒªãƒ¼ãƒˆã™ã‚‹å?åˆã?キーé…å?(éžnull)
180             */
181            public String[] getLogicalDeleteKeys() {
182                    return logDelKeys.clone();
183            }
184    
185            /**
186             * ãƒ?ƒªãƒ¼ãƒ?è«–ç†å‰Šé™¤) ã™ã‚‹å ´åˆã?値é…å?ã‚’è¿”ã—ã¾ã™ã?
187             *
188             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
189             *
190             * @og.rev 4.3.7.0 (2009/06/01) æ–°è¦ä½œæ?
191             *
192             * @return      ãƒ?ƒªãƒ¼ãƒˆã™ã‚‹å?åˆã?キーé…å?(éžnull)
193             */
194            public String[] getLogicalDeleteVals() {
195    //              return updVals ;
196                    return logDelVals.clone();
197            }
198    
199            /**
200             * カラãƒ?‚’è¿”ã™ã‹ã©ã?‹ã‚’決ã‚るロジãƒ?‚¯
201             *
202             * ãƒ??ブルåよりã?ロジãƒ?‚¯çš?«å°Žã出ã—ã¾ã™ã?
203             *
204             * @param       table   ãƒ??ブルå?
205             *
206             * @return      カラãƒ?‚’è¿”ã™ã‹ã©ã?‹(true:カラãƒ?‚’生æ?/false:カラãƒ??生æ?ã—ãªã?
207             */
208            private boolean isUseClm( final String table ) {
209                    boolean flag = ( table != null &&
210                                                     table.startsWith( "GE" ) ) ;
211    
212                    return flag ;
213            }
214    }