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.develop; 017 018import java.util.List; 019import java.util.ArrayList; 020import java.util.Map; 021 022import org.opengion.hayabusa.develop.AbstractJspCreate; 023import org.opengion.hayabusa.develop.JspConvertEntity; 024import org.opengion.fukurou.xml.OGElement; 025import org.opengion.fukurou.xml.OGAttributes; 026 027/** 028 * result.jspの<og:view>タグを作成します。 029 * 030 * ●使用例 031 * JspConvertEntity e = new JspConvertEntity(); 032 * e.setTableName("GF92"); 033 * e.setColumnName("CLM"); 034 * List< JspConvertEntity> a = new ArrayList< JspConvertEntity>(); 035 * a.add( e ); 036 * Map< String , List< JspConvertEntity> > m = new Map< String , List< JspConvertEntity > >(); 037 * m.put( "RESULT", a ); 038 * JspCreate j = JspCreateFactory.newInstance( "QUERY",m ); 039 * j.execute("<og:view />"); 040 * 041 * @og.rev 5.6.1.2 (2013/02/22) 文字列連結から、XML処理するように変更します。 042 * @author Takeshi.Takada 043 * 044 */ 045public class JspCreate_VIEW extends AbstractJspCreate { 046 /** このプログラムのVERSION文字列を設定します。 {@value} */ 047 private static final String VERSION = "6.3.9.1 (2015/11/27)" ; 048 049 // 6.3.9.1 (2015/11/27) Variables should start with a lowercase character(PMD) 050 private List<JspConvertEntity> resultRows ; 051 private boolean isNULL ; 052 053 /** 054 * コンストラクター 055 * 056 * インスタンス構築時に、タグ名(key)とファイル名(names)を指定します。 057 * 058 * @og.rev 6.3.9.1 (2015/11/27) コンストラクタを用意して、KEY,NAME をセットするように変更します。 059 */ 060 public JspCreate_VIEW() { 061 super( ":view" , "result,update" ); 062 } 063 064 /** 065 * 初期化メソッド 066 * 067 * 内部で使用する JspConvertEntityのリストのマップを受け取り、初期化を行います。 068 * 069 * @og.rev 5.2.1.0 (2010/10/01) 名前空間を、og 決め打ちから、名前空間指定無しに変更します。 070 * @og.rev 5.6.1.2 (2013/02/22) 対象ファイルを、result だけから、update も含めるように変更。 071 * 072 * @param master JspConvertEntityのリストのマップ 073 */ 074 @Override 075 protected void init( final Map<String,List<JspConvertEntity>> master ) { 076 resultRows = master.get( "RESULT" ); // 6.3.9.1 (2015/11/27) 077 isNULL = !isNotEmpty( resultRows ); // 6.3.9.1 (2015/11/27) 078 } 079 080 /** 081 * JSPに出力するタグの内容を作成します。 082 * 引数より作成前のタグの属性内容を確認するする事が出来ます。 083 * 084 * @og.rev 5.2.1.0 (2010/10/01) メソッドの引数を、OGAttributes から OGElement に変更します。 085 * @og.rev 5.2.1.0 (2010/10/01) 名前空間を、og 決め打ちから、引数を使用するように変更します。 086 * 087 * @param ele OGElementエレメントオブジェクト 088 * @param nameSpace このドキュメントのnameSpace( og とか mis とか ) 089 * 090 * @return 変換された文字列 091 * @og.rtnNotNull 092 * @throws Throwable 変換時のエラー 093 */ 094 @Override 095 protected String execute( final OGElement ele , final String nameSpace ) throws Throwable { 096 if( isNULL ) { return ""; } // 6.3.9.1 (2015/11/27) 097 098 final List<String> no_displays = new ArrayList<>(); 099 for( final JspConvertEntity display : resultRows ) { // 6.3.9.1 (2015/11/27) 100 // 非表示は、GF92の属性(Remarks)に、何もセットされていないカラムの事 101 final String remks = display.getRemarks(); 102 if( remks == null || remks.trim().isEmpty() ) { // 6.0.2.5 (2014/10/31) refactoring 103 no_displays.add( display.getColumnName() ); 104 } 105 } 106 107 final OGAttributes attri = ele.getOGAttributes(); // OGElementの内部オブジェクトなので、副作用あり 108 attri.setUseCR( true ); 109 if( ! no_displays.isEmpty() ) { 110 attri.setVal( "noDisplay" , chainChar( no_displays ,",") ); // あれば更新、なければ追加 111 } 112 return ele.getText( 0 ); 113 114 // sbTub.append( "<" ).append( ns ).append( "view" ).append( CR ); 115 // sbTub.append( "\tviewFormType = \"HTMLTable\"" ).append( CR ); 116 // sbTub.append( "\tcommand = \"{@command}\"" ).append( CR ); 117 // if( ! no_displays.isEmpty() ) { 118 // sbTub.append( "\tnoDisplay = \"").append(chainChar( no_displays ,",") ).append("\"" ).append( CR ); 119 // } 120 // sbTub.append( "/>" ).append( CR ); 121 122 // return sbTub.toString(); 123 } 124}