package jp.co.hitachi.soft.ucnp.plugin.sample.ioaction.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpSession;
import jp.co.hitachi.soft.ucnp.plugin.inputoutput.controller.IIoPluginController;
import jp.co.hitachi.soft.ucnp.plugin.inputoutput.common.UCNPPluginException;
import jp.co.hitachi.soft.ucnp.plugin.inputoutput.util.ParamConvertUtil;
public class IoPluginController implements IIoPluginController {
/* クライアントから受信した入力パラメタの値を保持するメンバ変数です。 */
private String param1 = null;
private String param2 = null;
private String param3 = null;
public Map<String, Object> inputFromNode(HttpSession session,
Map<String, Object> param) {
/* クライアントに処理結果を送るためのMapを生成します。 */
Map<String, Object> map = new HashMap<String, Object>();
/* ボタンの種別で処理を分けます。*/
String buttonType = (String) param.get("ucnp.button.type");
if ("show_next_page".equals(buttonType)) {
/* [次へ]ボタンの場合は,入力の値を取得してメンバ変数で保持します。 */
/* クライアントから受信したデータをMapに展開します。 */
Map<?, ?> inParamMap = (Map<?, ?>) param.get("ucnp.current.params.map");
/* 変換する値をMapより取り出します。 */
String inParam1 = (String) inParamMap.get("inputItemName1");
Map<String, String> decodedMap = null;
/* APIを利用するため,try-catchで囲みます。*/
try {
decodedMap = ParamConvertUtil.decodeHtmlPartParam(inParam1);
} catch (UCNPPluginException e) {
/* 例外処理を行います。 */
String errMsg = e.getMessage();
/* プラグインのログ出力などの処理をします。 */
/* エラーメッセージをマップに追加して返します。*/
map.put("ucnp.error.message", errMsg);
return map;
}
/* name属性が「order」のvalue属性の値を取得します。*/
String value = decodedMap.get("order");
/* メンバ変数に入力パラメタの値を設定します。 */
param1 = value;
param2 = (String) inParamMap.get("inputItemName2");
param3 = (String) inParamMap.get("inputItemName3");
} else if ("show_previous_page".equals(buttonType)) {
/* 戻るボタンの場合は,何もしません。 */
}
return map;
}
public Map<String, Object> outputToNode(HttpSession session,
Map<String, Object> param) {
/* クライアントへ送るMapを生成します。 */
Map<String, Object> map = new HashMap<String, Object>();
/* ボタンの種別で処理を分けます。*/
String buttonType = (String) param.get("ucnp.button.type");
if ("show_next_page".equals(buttonType)) {
/* 次へボタンの場合は,入力の値を出力項目へマッピングします。 */
Map<String, String> outParamMap = new HashMap<String, String>();
/* Mapに送信するデータを設定します。 */
/* outputItemName1に固定テキストパーツを設定しているので,
この固定テキストパーツの値としてHTMLパーツから取得した値を設定します。*/
outParamMap.put("outputItemName1", param1);
outParamMap.put("outputItemName2", param2);
outParamMap.put("outputItemName3", param3);
map.put("ucnp.next.params.map", outParamMap);
} else if ("show_previous_page".equals(buttonType)) {
/* 戻るボタンの場合は,何もしません。 */
}
return map;
}
} |