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