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.Map;
020 import java.util.Calendar;
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 import org.opengion.fukurou.util.HybsDateUtil;
027
028 /**
029 * query.jspの<og:comment>タグを作?します?
030 * comment タグは、既存?
031 *
032 * ●使用?
033 * <og:comment
034 * system = ENTITY.getNmSys()
035 * pgid = ENTITY.getPgid()
036 * title = ENTITY.getNmpg()
037 * date = HybsDateUtil.getDate( "yyyy/MM/dd" )
038 * author = "Auto Create"
039 * text = ""
040 * version = "001"
041 * />
042 *
043 * @og.rev 5.6.1.2 (2013/02/22) ??連結から?XML処?るよ?変更します?
044 *
045 * @author Administrator
046 *
047 */
048 public class JspCreate_COMMENT extends AbstractJspCreate {
049 //* こ?プログラ??VERSION??を設定します? {@value} */
050 private static final String VERSION = "5.6.1.2 (2013/02/22)" ;
051
052 private List<JspConvertEntity> COMMENT_ROWS ;
053 private boolean IS_NULL ;
054
055 /**
056 * 初期化メソ?
057 *
058 * ?で使用する JspConvertEntity の リス?のマップを受け取り、?期化を行います?
059 * @og.rev 5.2.1.0 (2010/10/01) 名前空間を、og 決め打ちから、名前空間指定無しに変更します?
060 * @og.rev 5.6.1.2 (2013/02/22) 処?象のファイル名を?するよ?変更します?
061 *
062 * @param master JspConvertEntityのリスト?マッ?
063 */
064 @Override
065 protected void init( final Map<String,List<JspConvertEntity>> master ) {
066 COMMENT_ROWS = master.get("COMMENT");
067 IS_NULL = !isNotEmpty( COMMENT_ROWS );
068 KEY = ":comment"; // 5.2.1.0 (2010/10/01) 名前空間指定無?
069 NAME = "query,result,update,entry";
070 }
071
072 /**
073 * ファイル名から?処?象かど?を判断します?
074 *
075 * @og.rev 5.6.1.2 (2013/02/22) 処?象のファイル名を?するため??します?
076 *
077 * @param name 処?象のファイル?
078 *
079 * @return 処?象な?true/ そうでなければ、false
080 */
081 // @Override
082 // protected boolean isExecute( final String name ) {
083 // return ( name != null && name.indexOf( "index" ) < 0 && name.indexOf( "forward" ) < 0 );
084 // }
085
086 /**
087 * JSPに出力するタグの?を作?します?
088 * 引数より作?前?タグの属??を確認するする事が出来ます?
089 *
090 * @og.rev 5.2.1.0 (2010/10/01) メソ?の引数を?OGAttributes から OGElement に変更します?
091 * @og.rev 5.2.1.0 (2010/10/01) 名前空間を、og 決め打ちから、引数を使用するように変更します?
092 * @og.rev 5.6.1.2 (2013/02/22) XML処?るよ?変更します?
093 *
094 * @param ele OGElementエレメントオブジェク?
095 * @param nameSpace こ?ドキュメント?nameSpace( og と?mis と?)
096 *
097 * @return 変換された文字?
098 * @throws Throwable 変換時?エラー
099 */
100 @Override
101 protected String execute( final OGElement ele , final String nameSpace ) throws Throwable {
102 if( IS_NULL ) { return ""; }
103
104 // こ? OGElement の階層の深さを探ります?
105 // ele.getText( para ) とすることでXML全体を階層表示できる?
106 // int para = ele.getParentCount();
107
108 JspConvertEntity ENTITY = COMMENT_ROWS.get(0);
109
110 OGAttributes attri = ele.getOGAttributes();
111 attri.setUseCR( true );
112 attri.setVal( "system" , ENTITY.getNmSys() );
113 attri.setVal( "pgid" , ENTITY.getPgid() );
114 attri.setVal( "title" , ENTITY.getNmpg() );
115 // attri.setVal( "date" , toDay() );
116 attri.setVal( "date" , HybsDateUtil.getDate( "yyyy/MM/dd" ) ); // 5.6.1.2 (2013/02/22)
117 attri.setVal( "author" , "Auto Create" );
118 attri.setVal( "text" , "" );
119 attri.setVal( "version" , "001" );
120
121 return ele.getText( 0 );
122 }
123
124 /**
125 * JSPに出力するタグの?を作?します?
126 * 引数より作?前?タグの属??を確認するする事が出来ます?
127 *
128 * @og.rev 5.2.1.0 (2010/10/01) メソ?の引数を?OGAttributes から OGElement に変更します?
129 * @og.rev 5.2.1.0 (2010/10/01) 名前空間を、og 決め打ちから、引数を使用するように変更します?
130 *
131 * @param ele OGElementエレメントオブジェク?
132 * @param nameSpace こ?ドキュメント?nameSpace( og と?mis と?)
133 *
134 * @return 変換された文字?
135 * @throws Throwable 変換時?エラー
136 */
137 // @Override
138 // protected String execute( final OGElement ele , final String nameSpace ) throws Throwable {
139 // if( IS_NULL ) { return ""; }
140 //
141 // String ns = (nameSpace.length() == 0) ? "" : nameSpace + ":" ; // 5.2.1.0 (2010/10/01) 名前空?
142 //
143 // JspConvertEntity ENTITY = COMMENT_ROWS.get(0);
144 //
145 // // TODO Auto-generated method stub
146 // //書き?す文字?を作?開始?
147 // StringBuilder sbTub = new StringBuilder();
148 // sbTub.append( "<" ).append( ns ).append( "comment").append( CR );
149 // sbTub.append( "\tsystem = \"" ).append( ENTITY.getNmSys() ).append( "\"" ).append( CR );
150 // sbTub.append( "\tpgid = \"" ).append( ENTITY.getPgid() ).append( "\"" ).append( CR );
151 // sbTub.append( "\ttitle = \"" ).append( ENTITY.getNmpg() ).append( "\"" ).append( CR );
152 // sbTub.append( "\tdate = \"" ).append( toDay() ).append( "\"" ).append( CR );
153 // sbTub.append( "\tauthor = \"" ).append( "Auto Create" ).append( "\"" ).append( CR );
154 // sbTub.append( "\ttext = \"" ).append( "" ).append( "\"" ).append( CR );
155 // sbTub.append( "\tversion = \"" ).append( "001" ).append( "\"" ).append( CR );
156 // sbTub.append( "/>" ).append( CR );
157 // return sbTub.toString();
158 // }
159
160 /**
161 * 現在の日?yyyy/MM/dd)を取得?
162 *
163 * @return 現在の日?
164 */
165 // private String toDay(){
166 // //インスタンス?
167 // Calendar now = Calendar.getInstance();
168 //
169 // int year = now.get(Calendar.YEAR);
170 // int mm = now.get(Calendar.MONTH) + 1;
171 // int dd = now.get(Calendar.DATE);
172 //
173 // String month = String.valueOf( mm );
174 // if (mm < 10){
175 // month = "0" + month ;
176 // }
177 // String day = String.valueOf( dd );
178 // if (dd < 10){
179 // day = "0" + day ;
180 // }
181 // return year + "/" + month + "/" + day;
182 // }
183 }