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     * ã“ã?クラスã¯ã€MICSç³»ã®ç®¡ç?‚¯ãƒ©ã‚¹ã§ã™ã?
024     * 具体的ã«ã¯ã€?
025     *     削除?Œï¾—ク??    DeleteFlg   0:通常 1:削除
026     *     登録日�    EntryDate
027     *     更新日�    RenewDate
028     * ãªã©ã®æƒ??ã‚’ã?INSERTã€UPDATE ã®çжæ³ã«å¿œã˜ã¦æä¾›ã—ã¾ã™ã?
029     * INSERT ã«ã¯ã€ç™»éŒ²æ—¥æ™‚ã?更新日時ã«ã‚‚å?ã‚’ã‚»ãƒ?ƒˆã—ã¾ã™ã?
030     * ã“れã¯ã€UPDATE ã•ã‚ŒãŸæ—¥ä»˜ã‚„時刻ã§ã€ä¸?¦§æ¤œç´¢ã§ãるよã†ã«ã™ã‚‹ç‚ºã§ã€?
031     * null ã«ã—ã¦ãŠãã¨ã€IS NULL ã§å•ã„åˆã‚ã›ã‚‹å¿?¦ãŒã‚りã¾ã™ã?
032     * INSERT ãƒ??ã‚¿ã?‘å–å?ã™å?åˆã?ã€WHERE EntryDate = RenewDate ã¨ã—ã¾ã™ã?
033     *
034     * コンストラクターã§ã¯ã€ãƒ†ãƒ¼ãƒ–ルåã?ユーザーID,ç”»é¢ID ã‚’å—ã‘å–りã¾ã™ã?
035     * 登録時刻ã¯ã€ã“ã®ã‚ªãƒ–ジェクトãŒç”Ÿæ?ã•ã‚ŒãŸæ™‚間を通常ã¯ä½¿ç”¨ã—ã¾ã™ã?
036     * ãƒ??ブルåを渡ã™ã?ã¯ã€ãƒ¯ãƒ¼ã‚¯ãªã©ã€ãƒ†ãƒ¼ãƒ–ルå˜ä½ã«å‡¦ç?™ã‚‹ã‚«ãƒ©ãƒ?Œ
037     * ç•°ãªã‚‹ã?ã§ã€ãれã¸ã®å¯¾å¿œã§ã™ã?
038     * 処ç?Œç°¡ç´?Œ–ã§ãるよã†ã«ã€ãƒ«ãƒ¼ãƒ«ã‚’è¦å®šã™ã¹ãã§ã™ã?
039     *
040     * @og.rev 5.6.2.1 (2013/03/08) æ–°è¦è¿½åŠ?
041     * @og.group �?タ登録
042     *
043     * @version  4.0
044     * @author   Kazuhiko Hasegawa
045     * @since    JDK5.0,
046     */
047    public class DBConstValue_MICS implements DBConstValue {
048            private static final String[] MSTR_INSKEYS =
049                    new String[] { "DELETEFLG","ENTRYDATE","RENEWDATE" };
050    
051            private static final String[] MSTR_UPDKEYS =
052                    new String[] { "RENEWDATE" };
053    
054            private static final String[] MSTR_LOGDELKEYS = // 4.3.7.0 (2009/06/01)
055                    new String[] { "DELETEFLG","RENEWDATE" };
056    
057            private static final String[] ZERO = new String[0] ;
058    
059            private String[] insKeys = ZERO;
060            private String[] insVals = ZERO;
061    
062            private String[] updKeys = ZERO;
063            private String[] updVals = ZERO;
064    
065            private String[] logDelKeys = ZERO; // 4.3.7.0 (2009/06/01)
066            private String[] logDelVals = ZERO; // 4.3.7.0 (2009/06/01)
067    
068            /**
069             * åˆæœŸåŒ–情報を設定ã—ã¾ã™ã?
070             *
071             * @param       table   ãƒ??ブルå?
072             * @param       user    ユーザーID
073             * @param       gamen   ç”»é¢ID
074             */
075            public void init( final String table, final String user, final String gamen ) {
076                    init( table, user, gamen, "" );
077            }
078    
079            /**
080             * åˆæœŸåŒ–情報を設定ã—ã¾ã™ã?
081             *
082             * @param       table   ãƒ??ブルå?
083             * @param       user    ユーザーID
084             * @param       gamen   ç”»é¢ID
085             * @param       pgamen  親画é¢ID
086             */
087            public void init( final String table, final String user, final String gamen, final String pgamen ) {
088                    if( isUseClm( table ) ) {
089                                                                            // TIMESTAMPåž‹ãªã®ã§ '2009-12-22 16:06:32' å½¢å¼ã«ã™ã‚‹ã€?
090                            String timestamp = "'" + HybsSystem.getDate( "yyyy-MM-dd HH:mm:ss" ) + "'" ;
091    
092                            insKeys = MSTR_INSKEYS;
093                            insVals = new String[] {
094                                                             "'0'"                  // DeleteFlg
095                                                            ,timestamp              // EntryDate
096                                                            ,timestamp              // RenewDate
097                            };
098    
099                            updKeys = MSTR_UPDKEYS;
100                            updVals = new String[] {
101                                                             timestamp              // RenewDate
102                            };
103    
104                            // 4.3.7.0 (2009/06/01)
105                            logDelKeys = MSTR_LOGDELKEYS;
106                            logDelVals = new String[] {
107                                                             "'1'"                  // DeleteFlg
108                                                            ,timestamp              // RenewDate
109                            };
110                    }
111            }
112    
113            /**
114             * インサートã™ã‚‹å?åˆã?キーé…å?ã‚’è¿”ã—ã¾ã™ã?
115             *
116             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
117             *
118             * @return      インサートã™ã‚‹å?åˆã?値é…å?(éžnull)
119             */
120            public String[] getInsertKeys() {
121                    return insKeys.clone();
122            }
123    
124            /**
125             * インサートã™ã‚‹å?åˆã?値é…å?ã‚’è¿”ã—ã¾ã™ã?
126             *
127             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
128             *
129             * @return      インサートã™ã‚‹å?åˆã?値é…å?(éžnull)
130             */
131            public String[] getInsertVals() {
132                    return insVals.clone();
133            }
134    
135            /**
136             *ã‚¢ãƒ??ãƒ??トã™ã‚‹å?åˆã?キーé…å?ã‚’è¿”ã—ã¾ã™ã?
137             *
138             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
139             *
140             * @return      ã‚¢ãƒ??ãƒ??トã™ã‚‹å?åˆã?キーé…å?(éžnull)
141             */
142            public String[] getUpdateKeys() {
143                    return updKeys.clone();
144            }
145    
146            /**
147             * ã‚¢ãƒ??ãƒ??トã™ã‚‹å?åˆã?値é…å?ã‚’è¿”ã—ã¾ã™ã?
148             *
149             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
150             *
151             * @return      ã‚¢ãƒ??ãƒ??トã™ã‚‹å?åˆã?キーé…å?(éžnull)
152             */
153            public String[] getUpdateVals() {
154                    return updVals.clone();
155            }
156    
157            /**
158             * ãƒ?ƒªãƒ¼ãƒ?è«–ç†å‰Šé™¤) ã™ã‚‹å ´åˆã?キーé…å?ã‚’è¿”ã—ã¾ã™ã?
159             *
160             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
161             *
162             * @return      ãƒ?ƒªãƒ¼ãƒˆã™ã‚‹å?åˆã?キーé…å?(éžnull)
163             */
164            public String[] getLogicalDeleteKeys() {
165                    return logDelKeys.clone();
166            }
167    
168            /**
169             * ãƒ?ƒªãƒ¼ãƒ?è«–ç†å‰Šé™¤) ã™ã‚‹å ´åˆã?値é…å?ã‚’è¿”ã—ã¾ã™ã?
170             *
171             * æŒ?®šã?値ãŒãªã‘れã°ã€?•·ã•ゼロé…å?ã‚’è¿”ã—ã¾ã™ã?
172             *
173             * @return      ãƒ?ƒªãƒ¼ãƒˆã™ã‚‹å?åˆã?キーé…å?(éžnull)
174             */
175            public String[] getLogicalDeleteVals() {
176                    return logDelVals.clone();
177            }
178    
179            /**
180             * カラãƒ?‚’è¿”ã™ã‹ã©ã?‹ã‚’決ã‚るロジãƒ?‚¯
181             *
182             * ãƒ??ブルåよりã?ロジãƒ?‚¯çš?«å°Žã出ã—ã¾ã™ã?
183             *
184             * @param       table   ãƒ??ブルå?
185             *
186             * @return      カラãƒ?‚’è¿”ã™ã‹ã©ã?‹(true:カラãƒ?‚’生æ?/false:カラãƒ??生æ?ã—ãªã?
187             */
188            private boolean isUseClm( final String table ) {
189                    boolean flag = ( table != null ) ;
190    
191                    return flag ;
192            }
193    }