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 */
016package org.opengion.plugin.calendar;
017
018import org.opengion.hayabusa.resource.CalendarQuery;
019import org.opengion.hayabusa.common.HybsSystemException;
020import org.opengion.fukurou.util.StringUtil;
021
022/**
023 * カレンダDB(TP652)の検索QUERYを定義したクラスです。
024 *
025 * QUERY は、このオブジェクトを、toString() して求めることとします。
026 * 本来は、これらのクラスの共通インターフェースを作成して、getQuery() などのメソッドを
027 * 介して取得すべきですが、Object の共通クラスを利用することとします。
028 *
029 * @og.rev 3.6.0.0 (2004/09/17) 新規作成
030 * @og.group リソース管理
031 *
032 * @version  4.0
033 * @author   Kazuhiko Hasegawa
034 * @since    JDK5.0,
035 */
036public final class CalendarQuery_TP652 implements CalendarQuery {
037        /** このプログラムのVERSION文字列を設定します。   {@value} */
038        private static final String VERSION = "6.4.2.0 (2016/01/29)" ;
039
040        /** カレンダDBの読み込みのクエリー(TP652)  */
041        public static final String QUERY =
042                                "select YM,DAY1,DAY2,DAY3,DAY4,DAY5,DAY6,DAY7,DAY8,DAY9,DAY10,"
043                                + "DAY11,DAY12,DAY13,DAY14,DAY15,DAY16,DAY17,DAY18,DAY19,DAY20,"
044                                + "DAY21,DAY22,DAY23,DAY24,DAY25,DAY26,DAY27,DAY28,DAY29,DAY30,DAY31"
045                                + " from TP652 where CDJGB=? and CDKTEI=? and KBCAL='0' and KBREC='1'"
046                                + " order by YM" ;
047
048        /** CDJGB:事業部コード の初期値:{@value} */
049        public static final String DEFAULT_CDKTEI = "STD";
050
051        /**
052         * デフォルトコンストラクター
053         *
054         * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor.
055         */
056        public CalendarQuery_TP652() { super(); }               // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。
057
058        /**
059         * 4つの引数を受け取り、整合性チェックを行います。
060         * 引数は、各クラスによって使用するカラム名(意味)が異なります。
061         * また、すべての引数をチェックするのではなく、クラス毎に、チェックする
062         * カラムの数は、異なります。
063         * 引数が正しくない場合は、HybsSystemException を発行します。
064         *
065         * @param       arg1    データベース検索時の第1引数(CDJGB:事業部コード)
066         * @param       arg2    データベース検索時の第2引数(CDKTEI:物件工程コード)
067         * @param       arg3    データベース検索時の第3引数(未使用)
068         * @param       arg4    データベース検索時の第4引数(未使用)
069         *
070         * @return      入力パラメータに応じた配列文字列(cdjgb,cdktei)
071         * @og.rtnNotNull
072         * @throws HybsSystemException CDJGB(事業部コード) が設定されていない場合。
073         */
074        public String[] checkArgment( final String arg1,final String arg2,final String arg3,final String arg4 ) {
075                final String cdjgb  = arg1;
076
077                if( cdjgb == null || cdjgb.isEmpty() ) {
078                        final String errMsg = "CalendarQuery_TP652 クラスの第一引数 "
079                                                + "CDJGB(事業部コード)を指定して、初期化下さい。" ;
080                        throw new HybsSystemException( errMsg );
081                }
082
083                return new String[] { cdjgb,StringUtil.nval( arg2,DEFAULT_CDKTEI ) } ;  // cdjgb,cdktei
084        }
085
086        /**
087         * データベース検索の為の Select 文を返します。
088         * 引数リストとともに、使用します。
089         *
090         * @return データベース検索の為の Select 文
091         * @og.rtnNotNull
092         */
093        public String getQuery() {
094                return QUERY;
095        }
096
097        /**
098         * データベースの持ち方を指定します。
099         * 持ち方がフラット(横持ち=1~31の日付をカラムで持つ)の場合、trueを返します。
100         * 縦持ち(日付単位で、行情報として持つ)場合は、false です。
101         *
102         * @return DBの持ち方がフラット(横持ち=1~31の日付をカラムで持つ)の場合、true
103         *
104         */
105        public boolean isFlatTable() {
106                return true;
107        }
108}