現在、3270 または 5250 のコンソールを使用してアクセスするメインフレーム・アプリケーションには、大量の企業情報が存在しています。このメインフレーム・データが、他のデータと容易に結合できる形式で企業内またはインターネット上で利用できれば、ビジネス・ユーザーはこのデータを活用し、豊富な機能をもった最新のブラウザー・インターフェースを用いて、ビジネス問題の解決に役立てることができるでしょう。この記事では、貴重な財務情報が 3270 データ・アプリケーションに「ロックされている」状態で、ローン担当者がそのデータを抽出し、Web ベースの新しいマッシュアップ・アプリケーションを作成するユース・ケースについて説明します。マッシュアップは、複数の既存のソースからデータまたは機能を結合することによって作成され、新しい機能と視点を提供する軽量 Web アプリケーションです。グリーン・スクリーン (3270) アプリケーションの有益な部分を分離してラップし、マッシュアップ・フレームワーク内で使用することにより、ビジネス・ユーザーに新しい視点を提供できます。
まず、メインフレームのコンテンツをマッシュアップ・フレームワーク内で消費する前に、データ・フィードとしてフォーマットする必要があります。この記事は、Rational® Host Access Transformation Services (HATS) を使用して、メインフレーム・コンテンツの Atom フィードを生成する方法をステップバイステップで説明するガイドです。Ramakrishnan Kannan、Prasad Nagaraj、および Saikrishna Vaidyanathan によって書かれた developerWorks® の記事「Use HATS to generate Atom feeds for mainframe applications」では、3270 データから Atom フィードを作成する方法が示されています。この記事では、IBM Mashup Center を使用して状況依存型 Web アプリケーションを作成する別の例を紹介することで、上記の記事の概念を拡張します。
銀行の金融サービスのローン担当者は、現在の預金口座契約者が新規の自動車ローンに適格であるかどうかを判断するために、いくつかのデータにアクセスする必要があります。まず、グリーン・スクリーンの 3270 メインフレーム・アプリケーションで、ローン担当者は口座契約者の現在の当座預金残高を審査することができます。次に、Web アプリケーションを使用して、口座契約者のクレジット信用度を入手しなければなりません。また、別のアプリケーションを使用して、ローン申請者の居住エリアでの自動車盗難報告件数を把握します。現状では、口座契約者が新規の自動車ローンに対して適格であるかどうかを判断するために、ローン分析担当者は 3 種類のコンピューター・アプリケーションを切り替えながら必要な情報にアクセスしなければなりません。この記事では、主に 3270 アプリケーションからのデータ抽出に焦点を当てます。クレジット信用度および居住エリアでの自動車盗難報告は、IBM Mashup Center のフィード・ジェネレーターによってすでにデータ・フィードに変換されているか、Web ブラウザーを使用してすでにアクセスできるものとします。
現在、口座残高情報には、3270 アプリケーションを通じてアクセスします(図 1 参照)。
図 1. 3270 アプリケーション・データ
IBM Rational Host Access Transformation Services (HATS) を使用すると、Atom データ・フィードを作成できます。このデータ・フィードを他のデータと結合し、ローン担当者用の複合ダッシュボード・アプリケーションを作成できます(図 2 参照)。
図 2. 複合ダッシュボード・アプリケーション
ここでは、3270 アプリケーション・データの抽出、およびマッシュアップ・アプリケーションへのデータの配置に使用できるステップバイステップのガイドを示し、コード・テンプレートの例を紹介します。
デフォルト設定を使用して、Rational Host Access Transformation Services (HATS) の新規プロジェクトを作成します。次の手順に従います。
- 「接続設定」ウィンドウでホスト名を入力します。それ以外のフィールドには、すべてデフォルトで値が入ります。必要に応じて変更してください。「完了」をクリックします。接続設定の例を図 3 に示します。ご使用になる状況に応じて設定が変わることがあります。
図 3. HATS の「接続の作成」ウィンドウ
次の手順で、情報を照会するマクロを記録します。
- メイン接続を右クリックし、「HATS ホスト端末のオープン」、「メイン」の順にクリックします。
図 4 のように、3270 の画面が表示されます。
図 4. 3270 HATS ホスト端末環境でのログオン画面
- 画面一番上の「記録」ボタンをクリックし、マクロ名を入力します。
- 使用したいプロセスを一通り実行し、「抽出アクションを追加」ボタンをクリックして各ページで抽出したい行を選択します。図 5 を参照してください。
図 5. 3270 データを抽出する選択領域
- 後でリスト内の各行が別々のエントリーになるように、各抽出アクションで「抽出形式」オプションの「この領域をストリングのリストとして抽出」を選択します。他の値はすべてデフォルトで設定されます。「完了」をクリックします。
図 6. 「抽出を編集」ウィンドウ
Create an Integration Object from the macro by following these steps:
- マクロを右クリックし、「統合オブジェクトの作成」オプションを選択します。
- 「統合オブジェクト」で新規 Java™ ソースを開きます。これは、マクロと同じ名前になっています(この記事の付録にあるリスト A-1 のサンプル・コードを参照してください)。
- 最上部付近にある定義済みの HAOVariables に注意してください。それぞれのインスタンス生成で、最後の引数を「HAO_VARIABLE_SIMPLE」から「HAO_VARIABLE_ARRAY」に変更します。この変更により、行を結合した 1 つのストリングの代わりに、抽出された行の配列を得られます。次のように引数を変更します。
- 変更前
HAOVariable inquiry1 =
new HAOVariable("","inquiry1","inquiry1",false,"",0,0,63,7,HAO_VARIABLE_SIMPLE); - 変更後
HAOVariable inquiry1 =
new HAOVariable("","inquiry1","inquiry1",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
- 変更前
- ここで、your_inquiry.oMultiValues を返す各照会に vector 型の Getter を追加します。例として、リスト 1 のコードを参照してください。
リスト 1. 照会結果の配列用の Getter の例
public Vector getInquiry1AsVector()
{
hPubErrorOccurred = 0;
if (HPubTracingOn) { Ras.trace( className, "getInquiry1 array: ",
inquiry1.stringValue); }
return (inquiry1.oMultiValues);
}
|
次に、統合オブジェクトを右クリックし、「モデル 1 Web ページの作成」オプションを選択することにより、統合オブジェクトからモデル 1 Web ページを作成します。図 7 を参照してください。
図 7. 「モデル 1 Web ページの作成」ウィンドウ
指定されたデフォルト設定を使用し、「完了」をクリックして「モデル 1 ページ」の下に JSP ページを作成します。
次に、Atom フィードを出力するために JSP ページを変更します。次の手順に従います。
- 「Web コンテンツ」 → 「モデル 1 ページ」の下に JSP ページが作成されているので、これをダブルクリックしてソースに移動します。
- 提供されている JSP ファイル InquiryMacroOutput.jsp (この記事の付録にあるリスト A-2 を参照) をガイドとして使用し、Atom フィードを出力する独自のコードで JSP コードを置き換えます。JSP はパラメーター化を処理しないため、配列リストでのパラメーター化に関する警告は無視します。
TJSP ページのエンドポイントまで移動し、Atom フィードを確認することで JSP ページをテストします。
Microsoft® Internet Explorer ブラウザーを使用している場合、ページは 図 8 に示すテキストのようになります。
図 8. JSP ページからの結果の Atom フィード
IBM InfoSphere™ MashupHub に新規 Atom フィードを追加するには、次の手順に従います。
- InfoSphere MashupHub を開き、MashupHub ホーム・ページの「作成」セクションにある「新規フィード」をクリックします。
- 表示されるリストで、「部門」の下にある「既存の RSS または Atom または RSS フィード(登録) (登録)」を選択します (図 9 参照)。「次へ」をクリックします。
図 9. IBM Mashup Center の新規フィードの作成パネル
- 作成した JSP ページの URL を入力し、「次へ」をクリックします。図 10 を参照してください。
図 10. MashupHub フィード作成ウィンドウでの Atom フィード URL の指定
- 新規フィードのタイトルと説明を入力します。また、このフィードに関連付けたい任意のタグを指定し、「完了」をクリックします。
- これで、フィードが InfoSphere MashupHub カタログに保存されました。「マッシュアップ・ビルダー に追加」オプションを選択して、このフィードを マッシュアップ・ビルダー に追加します。
- マッシュアップ・ビルダー サーバーの場所を入力し、「次へ」をクリックします。
- 必要であれば、「タイトル」、「説明」、「カテゴリー」、「フィード・ビューアー」の各オプションを変更し、「完了」をクリックします。
フィードを使用した マッシュアップ・ビルダー でのマッシュアップの構築
次の手順に従い、フィードを使用して マッシュアップ・ビルダー でマッシュアップを構築します。
- マッシュアップ・ビルダー を開き、必要であればマッシュアップ用の新規ページを開きます。
- 「編集へジャンプ」ボタンをクリックして、マッシュアップの構築を開始します。
- ツールバーからフィードを選択します。デフォルトでは、図 11 に示すように、ツールバーの「コラボレーション」オプションに表示されています。フィードをページ上にドラッグします。必要に応じてサイズを変更します。
図 11. Mashup Center で 3270 データの Atom フィードを表示する「データ・ビューアー」ウィジェット
- ツールバーで「お気に入り」オプションをクリックし、OpenStreetMap ウィジェットおよびマッシュアップ・アプリケーションで使用したい任意のウィジェットを追加します。この例では、クレジット・レポート履歴および指定された地域での自動車盗難報告を提供するフィードがあります。OpenStreetMap ウィジェットと Website Displayer ウィジェットが使用されます。3270 データ表からの要素をこれらの新規ウィジェットに接続することにより、ビジネス・ニーズを解決するカスタマイズされたアプリケーションを作成します。
- フィード内でアイテムをクリックすると、対応する自動車盗難情報がマップ上に表示され、クレジット・レポート情報が「Web サイト表示機能」ウィジェットに表示されます(図 12 参照)。
図 12. 完成した、ローン担当者用のダッシュボード・マッシュアップ・アプリケーション
IBM Mashup Center と Rational Host Access Transformation Services を使用すると、現在 3270 または 5250 アプリケーションにロックされているデータを取り出し、他の Web ベース・アプリケーションに活用することができます。この記事は、3270 データを抽出し、状況依存型の新しいマッシュアップ・アプリケーションを作成するためのステップバイステップのガイドとして書かれています。さまざまな 3270 アプリケーションからデータを抽出するために調整できるコード・テンプレートも用意されています。
Listing A-1. Code for the integration object (InquiryMacro.java)
import java.util.Vector;
import com.ibm.HostPublisher.IntegrationObject.*;
import com.ibm.HostPublisher.Server.Ras;
public class InquiryMacro extends HPubHODCommon
{
public static float getIOTemplateVersion()
{ return 7.0F; } // Template version - HATS 7.0
public static String getIOTemplateType()
{ return "-DEFAULT"; } // Template type - Host Default
public static String getIOVersionInfo()
{ return "(IBM)"; } // Version info - IBM supplied
public static String getIOTemplateRevision()
{ return ":1.1"; } // Template revision per version - internal value
public String hPubIOVersion= getIOBaseVersion()+";"+getHPubBeanType()+
getIOTemplateType()+getIOTemplateVersion()+
getIOTemplateRevision()+getIOVersionInfo();
public String getIOVersion() { return hPubIOVersion; }
// Generated Objects altered to export their data as
//HAO_VARIABLE_ARRAY instead of HAO_VARIABLE_SIMPLE
HAOVariable inquiry1 =
new HAOVariable("","inquiry1","inquiry1",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
HAOVariable inquiry2 =
new HAOVariable("","inquiry2","inquiry2",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
HAOVariable inquiry3 =
new HAOVariable("","inquiry3","inquiry3",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
HAOVariable inquiry4 =
new HAOVariable("","inquiry4","inquiry4",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
HAOVariable inquiry5 =
new HAOVariable("","inquiry5","inquiry5",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
****************************************************
******** Automatically Generated Code Not Shown ********
****************************************************
/* Added Getters to return the inquiries as a Vector */
public Vector getInquiry1AsVector()
{
return (inquiry1.oMultiValues);
}
public Vector getInquiry2AsVector()
{
return (inquiry2.oMultiValues);
}
public Vector getInquiry3AsVector()
{
return (inquiry3.oMultiValues);
}
public Vector getInquiry4AsVector()
{
return (inquiry4.oMultiValues);
}
public Vector getInquiry5AsVector()
{
return (inquiry5.oMultiValues);
}
|
Listing A-2. Code for JSP that creates the Atom feed (InquiryMacroOutput.jsp)
<%@ page contentType="text/html;charset=UTF-8"errorPage="../BasicIOErrorPage.jsp"%>
<%@ page import="com.ibm.hats.runtime.*,
javax.xml.parsers.DocumentBuilder,
javax.xml.parsers.DocumentBuilderFactory,
javax.xml.transform.OutputKeys,
javax.xml.transform.Transformer,
javax.xml.transform.TransformerFactory,
javax.xml.transform.dom.DOMSource,
javax.xml.transform.stream.StreamResult,
org.w3c.dom.Document,org.w3c.dom.Element,
org.w3c.dom.Text,
java.io.StringWriter,
java.util.ArrayList,
java.util.Vector,
java.util.Date"%>
<%@ taglib uri="hats.tld" prefix="HATS"%>
<% IOGV.process(request); %>
<jsp:useBean id="InquiryMacro" type="IntegrationObject.InquiryMacro"
class="IntegrationObject.InquiryMacro" scope="request">
<jsp:setProperty name="InquiryMacro" property="*" />
</jsp:useBean>
<%
//Use the Integration Object that is instantiated above
//to get data from the 3270 machine.
InquiryMacro.doHPTransaction(request, response);
try {
// Build the feed to return from the page here.
// A well-formed Atom Feed should contain the
// following: A root "feed" element with "title",
// "updated", "author" (containing "name" and "email"), and "id"
// Create new feed factory
DocumentBuilderFactory feedFactory = DocumentBuilderFactory.newInstance();
// Create a new feed builder from the feedFactory
DocumentBuilder feedBuilder = feedFactory.newDocumentBuilder();
// Create a new document from the feed builder
Document doc = feedBuilder.newDocument();
// Create the root "feed" Element for the Atom Feed
Element root = doc.createElementNS(
"http://www.w3.org/2005/Atom", "feed");
doc.appendChild(root);
// Create the "title" element for the Atom Feed
Element title = doc.createElement("title");
// Append the title to the root element
root.appendChild(title);
// Create a text node for the title element
Text titleText = doc.createTextNode("Sample Feed from HATS");
// Append the text to the title node
title.appendChild(titleText);
// Create the "updated" element for the root of the Atom Feed
Element updated = doc.createElement("updated");
root.appendChild(updated);
Text updateText = doc.createTextNode(new Date().toString());
updated.appendChild(updateText);
// Create the "author" element for the root of the Atom Feed
Element author = doc.createElement("author");
// Created the "name" element for under the author element
Element name = doc.createElement("name");
// Create the "email" element for under the author element
Element email = doc.createElement("email");
name.setTextContent("IBM Hats");
email.setTextContent("ibm@us.ibm.com");
// Append the name and email to the author
author.appendChild(name);
author.appendChild(email);
// Append the author element to the root
root.appendChild(author);
// Create the "id" element for the root of the Atom Feed
Element id = doc.createElement("id");
id.setTextContent("http://www.ibm.com/root");
root.appendChild(id);
// Add all of the inquiries to an array to loop through
// and construct the body of the Atom Feed
ArrayList inqueries = new ArrayList();
inqueries.add(InquiryMacro.getInquiry1AsVector());
inqueries.add(InquiryMacro.getInquiry2AsVector());
inqueries.add(InquiryMacro.getInquiry3AsVector());
inqueries.add(InquiryMacro.getInquiry4AsVector());
inqueries.add(InquiryMacro.getInquiry5AsVector());
// Create multiple "entry" elements from the inquiries
// and add them to the root "feed"
// A well-formed entry element should contain title,
// link, id, updated, and content
for (int i = 0; i < 5; i++) {
// Get the vector of strings from the array JSP can't
// have parameterized types so it must be generic
Vector inquiry = (Vector) inqueries.get(i);
// Create the top element for the new Entry
Element entry = doc.createElement("entry");
// Append the entry to the root "feed" element
root.appendChild(entry);
//Create and append the title element to the Entry
Element titleEntry = doc.createElement("title");
titleEntry.setTextContent("Entry #" + i);
entry.appendChild(titleEntry);
//Create and append the link element to the Entry
Element link = doc.createElement("link");
link.setAttribute("href", "http://www.ibm.com");
entry.appendChild(link);
//Create and append the id element to the Entry
id = doc.createElement("id");
id.setTextContent("http://www.ibm.com/id" + i);
entry.appendChild(id);
//Create and append the updated element to the Entry
Element updatedEntry = doc.createElement("updated");
entry.appendChild(updatedEntry);
Text updateEntryText = doc.createTextNode(new Date()
.toString());
updatedEntry.appendChild(updateEntryText);
Element summaryEntry = doc.createElement("content");
//******* If you plan on having html content here, you should set
//******* the type attribute to html so it will display correctly
//******* by uncommenting the following lines
//summaryEntry.setAttribute("type", "html");
//summaryEntry.setAttribute("mode", "escaped");
// Create and append any data nodes from your inquiry to
// the content node of the entry
Element record = doc.createElement("Number");
record.setTextContent(inquiry.get(0).toString().trim());
summaryEntry.appendChild(record);
Element uname = doc.createElement("Name");
uname.setTextContent(inquiry.get(1).toString().trim());
summaryEntry.appendChild(uname);
Element address = doc.createElement("Address");
address.setTextContent(inquiry.get(2).toString().trim());
summaryEntry.appendChild(address);
Element phone = doc.createElement("Phone");
phone.setTextContent(inquiry.get(3).toString().trim());
summaryEntry.appendChild(phone);
Element date = doc.createElement("Date");
date.setTextContent(inquiry.get(4).toString().trim());
summaryEntry.appendChild(date);
Element amount = doc.createElement("Amount");
amount.setTextContent(inquiry.get(5).toString().trim());
summaryEntry.appendChild(amount);
Element comment = doc.createElement("Comment");
comment.setTextContent(inquiry.get(6).toString().trim());
summaryEntry.appendChild(comment);
// Append the content element to the entry element
entry.appendChild(summaryEntry);
}
// The following block transforms the Feed into a consumable
// string for the out.print
TransformerFactory feedTransformerFactory =
TransformerFactory.newInstance();
Transformer feedTransformer = feedTransformerFactory.newTransformer();
feedTransformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
feedTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(doc);
feedTransformer.transform(source, result);
//Print out the constructed feed xml as the content of the page
out.print(sw.toString());
} catch (Exception e) {
System.out.println(e);
}
%>
|
学ぶために
-
Read the developerWorks article, “Use HATS to generate Atom feeds for mainframe applications,” written by Ramakrishnan Kannan, Prasad Nagaraj, and Saikrishna Vaidyanathan. This article presents a good foundation on how to create Atom feeds from 3270 data.
-
Learn more about Rational Host Access Transformation Services (HATS). With HATS, you can extend your 3270 and 5250 host applications to the Web, to a portlet, to a rich client, or to browsers on mobile devices quickly, easily, and with low risk. There is a trial version that you can download.
-
Take the tutorial, Creating a Web Service using HATS. This lab teaches you how to use HATS to create a Web service that exposes logic contained in a System i 5250 green screen application. This lab shows new features in V7.1, including the new Visual Macro Editor tooling.
-
Refer to the HATS Help Documentation. Read a complete overview of HATS.
-
Learn more about IBM Mashup Center. Find an easy to use business mashup solution, supporting line of business assembly of dynamic situational applications — with the management, security, and governance capabilities IT requires. A free trial download is available for developers.
-
Read the Mashup Center wiki, which contains articles on installing, administering, deploying, and using IBM Mashup Center, including tutorials for new users.
-
Watch the video that complements this article.
製品や技術を入手するために
-
Download a trial version of IBM Mashup Center by using the online trial version located at the IBM Lotus Greenhouse Web site.
議論するために
-
Connect with the HATS HotSpot Community. Connect with the HATS community to learn what’s new, share hints and tips, reach out when you’re stuck, and engage in dialogue with the HATS team on what you like, don’t like, and what you need.
John Feller is the manager of the IBM Emerging Technologies Toolkit Development team. He manages a creative and energetic team of developers that architect, design, and develop innovative solutions that are then made available on alphaWorks. He is currently investigating best practices to build online communities using Web 2.0 technologies like wikis, blogs, tagging, and Ajax user interfaces. He earned a bachelor's degree in computer science at the University of Dayton and a master's degree in computer and information science at Ohio State University. He received an MBA from the University of North Carolina, Chapel Hill, and is certified as a Project Manager Professional with the Project Management Institute.