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.develop;
017
018 import java.util.List;
019 import java.util.ArrayList;
020 import java.util.Map;
021
022 import org.opengion.hayabusa.develop.AbstractJspCreate;
023 import org.opengion.hayabusa.develop.JspConvertEntity;
024 import org.opengion.fukurou.xml.OGElement;
025 import org.opengion.fukurou.xml.OGAttributes;
026
027 /**
028 * entry.jspの<og:tableUpdateParam>タグを作æ?しますã?
029 * tableUpdateParam は、tableUpdate タグのBODY部に記述されますã?
030 * tableUpdateParam で書き換えが発生するã?は、対象ãƒ??ブルと、omitNames属æ?ですã?
031 * where条件の書き換えã?行いませんã€?雛形読み込み時ã?まま使用しますã?)
032 * ãƒ??ブルの書き間違いで、異なるUNIQ番号の更新を避ける意味合いでã€?
033 * UNIQ=[UNIQ]以外ã?キーを条件に入れておくと、より安å?ですã?
034 *
035 * ●使用ä¾?
036 * <og:tableUpdate command="{@command}" queryType="JDBCTableUpdate" debug="false">
037 * <og:tableUpdateParam
038 * sqlType = "{@sqlType}"
039 * table = "GF02"
040 * where = "UNIQ=[UNIQ] and DYSET=[DYSET]"
041 * omitNames = "SYSTEM_ID,TBLSYU,TABLESPACE_NAME"
042 * />
043 * </og:tableUpdate>
044 *
045 * @og.rev 5.6.1.2 (2013/02/22) æ–?—å?連結からã?XML処ç�?�™るよã�?�«変更しますã?
046 * @author Takeshi.Takada
047 *
048 */
049 public class JspCreate_TABLE_UPDATE extends AbstractJspCreate {
050 //* こã?プログラãƒ??VERSIONæ–?—å?を設定しますã? {@value} */
051 private static final String VERSION = "5.6.1.2 (2013/02/22)" ;
052
053 private List<JspConvertEntity> RESULT_ROWS ;
054 private boolean IS_NULL ;
055
056 /**
057 * 初期化メソãƒ?ƒ‰
058 *
059 * å†?ƒ¨で使用する JspConvertEntityのリストã?マップを受け取り、å?期化を行いますã?
060 *
061 * @og.rev 5.2.1.0 (2010/10/01) 名前空間を、og 決め打ちから、名前空間指定無しに変更しますã?
062 * @og.rev 5.6.1.2 (2013/02/22) 対象ファイルをã?result ã�?�‘から、update も含めるように変更ã€?
063 *
064 * @param master JspConvertEntityのリストã?マッãƒ?
065 */
066 @Override
067 protected void init( final Map<String,List<JspConvertEntity>> master ) {
068 RESULT_ROWS = master.get( "RESULT" );
069 IS_NULL = !isNotEmpty( RESULT_ROWS );
070 KEY = ":tableUpdateParam";
071 NAME = "entry";
072 }
073
074 /**
075 * JSPに出力するタグのå†?®¹を作æ?しますã?
076 * 引数より作æ?前ã?タグの属æ?å†?®¹を確認するする事が出来ますã?
077 *
078 * @og.rev 5.2.1.0 (2010/10/01) メソãƒ?ƒ‰の引数をã?OGAttributes から OGElement に変更しますã?
079 * @og.rev 5.2.1.0 (2010/10/01) 名前空間を、og 決め打ちから、引数を使用するように変更しますã?
080 *
081 * @param ele OGElementエレメントオブジェクãƒ?
082 * @param nameSpace こã?ドキュメントã?nameSpace( og とã�?mis とã�?)
083 *
084 * @return 変換された文字å?
085 * @throws Throwable 変換時ã?エラー
086 */
087 @Override
088 protected String execute( final OGElement ele , final String nameSpace ) throws Throwable {
089 if( IS_NULL ) { return ""; }
090
091 String table = null;
092 List<String> omitNames = new ArrayList<String>();
093 for(JspConvertEntity column : RESULT_ROWS){
094 // 非表示は、GF92の属æ?(Remarks)に、何もセãƒ?ƒˆされてã�?�ªã�?‚«ラãƒ??äº?
095 String remks = column.getRemarks();
096 String astbl = column.getAsTableName();
097
098 // DISP で、別名がA1以外ã?場合ã?ãƒ??タ登録しなã�??で、omit カラãƒ?�«なるã?
099 if ( "DISP".equalsIgnoreCase( remks ) && !"A1".equalsIgnoreCase( astbl ) ) {
100 omitNames.add( column.getColumnName() );
101 }
102
103 // æœ??の?‘回ã�?�‘取り込ã‚?
104 if( table == null && "A1".equalsIgnoreCase( astbl ) ) {
105 table = column.getTableName();
106 }
107 }
108
109 OGAttributes attri = ele.getOGAttributes(); // OGElementのå†?ƒ¨オブジェクトなので、副作用あり
110 attri.setUseCR( true );
111 attri.setVal( "table" , table );
112
113 if ( ! omitNames.isEmpty() ) {
114 attri.setVal( "omitNames" , chainChar( omitNames ,",") ); // あれば更新、なければ追åŠ?
115 }
116
117 return ele.getText( 1 );
118 }
119 }