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