この章では、AWMPlugin、ViewerPluginおよびEditorPluginインタフェースを実装するJavaクラスの例を示します。また、プラグインを指定するXMLドキュメントの例も示します。
この章の内容は次のとおりです。
この章と第1章のJavaクラスおよびXMLドキュメントには、クラスまたはドキュメントの完全なコードが含まれています。完全なコードは、Oracle Technology Network (OTN)のWebサイトからダウンロードできる圧縮ファイルでも入手できます。ダウンロードには、プラグインのコンパイル済classファイルも含まれます。OTNのWebサイトは次の場所にあります。
http://www.oracle.com/technology/products/bi/olap/index.html
サンプルを取得するには、Webページの「Download」セクションで、「Sample Code and Schemas」を選択します。「Oracle OLAP Downloads」ページで、「Sample Schemas and Code」セクションのOracle OLAP 11gのAWM Java Plug-ins and XML Documents for 11.2.0.2の行で、「examples」をクリックします。
圧縮ファイルのcustomizingAWM_examples11202.zipには、次のファイルが含まれています。
| ファイル名 | 説明 |
|---|---|
readme.txt |
zipファイルの内容を簡単に説明しています。 |
awmcalcs.xml |
例1-9「AWMCalcsドキュメントの例」のXMLが含まれます。 |
awmtree.xml |
例1-3「SELECT文へのビューの名前の引渡し」のXMLが含まれます。 |
plugin11202.jar |
plugin11202という名前のディレクトリが含まれます。このディレクトリは、サンプルを含むパッケージです。ディレクトリには、第3章の例のxml、javaおよびclassファイルがあります。 |
awmcalcs.xmlファイルとawmtree.xmlファイルはAnalytic Workspace Managerの実行可能ファイルと同じディレクトリに配置します。plugin11202.jarファイルはプラグインに指定したディレクトリに配置します。「Analytic Workspace Managerプラグインの有効化」を参照してください。
AWMPluginの例は次のトピックで示しています。
例には、AWMPluginインタフェースのメソッドのドキュメント・コメントまたはこれらのメソッドの入力パラメータと戻り値は含まれていません。これらのメソッドとパラメータは、「AWMPluginインタフェースの説明」で説明されています。
ViewXMLPluginクラスでは、Analytic Workspace Managerのナビゲーション・ツリーの「キューブ」フォルダにあるキューブのメジャーまたはカスタム・メジャーのXML表現が表示されます。例3-1に、クラスのコードを示します。プラグインはoracle.olap.metadata.mdm.MdmBaseMeasureおよびoracle.olap.metadata.mdm.MdmDerivedMeasureオブジェクトに適用されます。これらのオブジェクトは、それぞれキューブのメジャーおよび計算済メジャー・オブジェクトに対応します。
プラグインはメジャーのXML表現を取得し、表示します。図2-3に、ユーザーがメジャーを右クリックしたときにAnalytic Manager WorkspaceによってViewXMLPluginに対して表示されるメニューを示します。ViewXMLPluginによって表示されるダイアログ・ボックスの例は、図3-1「ViewXMLPluginによって表示されるダイアログ・ボックス」を参照してください。
例3-1 ViewXMLPluginクラス
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import oracle.AWXML.AW;
import oracle.olap.awm.plugin.AWMPlugin;
import oracle.olapi.metadata.mdm.MdmBaseMeasure;
import oracle.olapi.metadata.mdm.MdmDerivedMeasure;
import oracle.olapi.metadata.mdm.MdmMetadataProvider;
import oracle.olapi.metadata.mdm.MdmObject;
/**
* An implementation of the AWMPlugin interface that displays the XML
* representation of an Oracle OLAP measure object.
*/
public class ViewXMLPlugin implements AWMPlugin
{
public boolean isSupported(Connection conn, String type, Object obj,
AW aw, Map params)
{
// Support MdmBaseMeasure and MdmDerivedMeasure objects.
if (obj instanceof MdmBaseMeasure || obj instanceof MdmDerivedMeasure)
{
return true;
}
return false;
}
public String getMenu(Connection conn, String type, Object obj, AW aw,
Map params)
{
// Text to display on the right-click menu.
String menu = "View XML Example Plug-in";
return menu;
}
public void handle(Frame parent, Connection conn, String type, Object obj,
AW aw, Map params)
{
if (obj instanceof MdmObject)
{
// Get the MdmMetadataProvider to use in exporting the XML.
Object objdp = params.get("DATAPROVIDER");
if (objdp != null)
{
MdmObject mobj = (MdmObject)obj;
MdmMetadataProvider mdp = (MdmMetadataProvider)objdp;
// Get the XML representation of the MdmObject.
List objects = new ArrayList();
objects.add(mobj);
Map renameMap = null;
boolean includeOwnerString = true;
String title = "XML for " + mobj.getName();
try
{
String xml =
mdp.exportFullXML(objects, renameMap, includeOwnerString);
// Create a dialog box and display the XML.
DisplayXMLDialog dxd = new DisplayXMLDialog(parent, title, true,
xml);
}
catch (IOException ie)
{
// Ignore error.
}
}
}
}
public boolean refreshTree(Connection conn, String type, Object obj, AW aw,
Map params)
{
// This example does not create new metadata objects, so return false.
return false;
}
/**
* An inner class that creates a dialog box that displays the XML.
*/
class DisplayXMLDialog extends JDialog implements ActionListener
{
/**
* Creates a DisplayXMLDialog for displaying the contents of the xml
* parameter.
*
* @param parent A Frame that is provided by Analytic Workspace Manager.
* @param title A String that contains text to use as the title for the
* dialog box.
* @param modal A boolean that specifies whether the dialog box is modal.
* @param xml A String that contains the XML to display.
*/
public DisplayXMLDialog(Frame parent, String title, boolean modal,
String xml)
{
super(parent);
setLocation(200, 200);
setTitle(title);
setModal(modal);
try
{
displayXML(xml);
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* Creates a dialog box and displays the contents of a String.
*
* @param xml A String that contains the XML to display.
*/
private void displayXML(String xml)
{
JTextArea ta = new JTextArea(xml);
ta.setEditable(false);
Font of = ta.getFont();
Font f = new Font("Courier New", of.getStyle(), of.getSize());
ta.setFont(f);
JScrollPane p = new JScrollPane();
p.getViewport().add(ta);
JPanel buttonPane = new JPanel();
JButton button = new JButton("Close");
buttonPane.add(button);
button.addActionListener(this);
getContentPane().add(buttonPane, BorderLayout.SOUTH);
getContentPane().add(p, BorderLayout.NORTH);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
pack();
setVisible(true);
}
/**
* Performs an action for the Close button.
*
* @param e An ActionEvent for the Close button.
*/
public void actionPerformed(ActionEvent e)
{
setVisible(false);
dispose();
}
}
}
図3-1に、ViewXMLPluginによってUNITS_CUBEフォルダのPROFIT計算済メジャーに対して表示されるダイアログ・ボックスを示します。
DeleteDimPluginクラスはユーザーがナビゲーション・ツリーで選択したディメンションを削除します。このプラグインが適用されるのは、カスタム・フォルダ内にあり、params MapのTYPEキーの値としてdimobjを持つディメンション・オブジェクトのみです。DeleteDimPluginプラグインは、例3-7のaw.xmlドキュメントによって指定されます。
例3-2に、DeleteDimPluginクラスのコードを示します。
例3-2 DeleteDimPluginクラス
package plugin11202;
import java.awt.Frame;
import java.sql.Connection;
import java.util.Map;
import javax.swing.JOptionPane;
import oracle.AWXML.AW;
import oracle.olap.awm.plugin.AWMPlugin;
import oracle.olapi.metadata.mdm.MdmMetadataProvider;
import oracle.olapi.metadata.mdm.MdmObject;
import oracle.olapi.metadata.mdm.MdmPrimaryDimension;
import oracle.olapi.metadata.mdm.MdmSchema;
/**
* An implementation of the AWMPlugin interface that can delete
* an Oracle OLAP dimension object in a custom folder.
*/
public class DeleteDimPlugin implements AWMPlugin
{
// This plug-in applies to dimension objects in a custom folder.
public boolean isSupported(Connection conn, String type, Object obj, AW aw,
Map params)
{
if (params != null)
{
// Get the value of the type attribute of the AWMNode that specifies this
// plug-in.
Object nodeType = params.get("TYPE");
if (nodeType != null && ((String)nodeType).equalsIgnoreCase("dimobj"))
return true;
}
return false;
}
public String getMenu(Connection conn, String type, Object obj, AW aw,
Map params)
{
Object dimName = null;
if (obj != null && obj instanceof String)
{
dimName = (String) obj;
}
// Text to display on the right-click menu.
return "Example Plug-in: Delete Dimension " + dimName;
}
public void handle(Frame parent, Connection conn, String type, Object obj,
AW aw, Map params)
{
String dimName = "";
// The obj parameter should be the name of the currently selected dimension.
if (obj != null && obj instanceof String)
{
dimName = (String) obj;
String title = "Delete Dimension";
if (JOptionPane.showConfirmDialog(parent, "Delete " + dimName + "?",
title, JOptionPane.YES_NO_OPTION) ==
JOptionPane.NO_OPTION)
return;
}
if (params != null)
{
Map bindMap = (Map)params.get("BIND_MAP");
if (bindMap != null)
{
// Get the name of the owner, which is also the name of the schema.
String owner = (String)bindMap.get("owner");
// Get the currently selected dimension.
MdmPrimaryDimension dim = getDimension(dimName, owner, params);
if (dim != null)
{
// Get the schema object that contains the dimension.
MdmSchema schema = dim.getOwner();
schema.removeDimension(dim);
MdmMetadataProvider mdp = getMetadataProvider(params);
// Get the TransactionProvider and commit the current Transaction.
try
{
mdp.getDataProvider()
.getTransactionProvider()
.commitCurrentTransaction();
JOptionPane.showMessageDialog(parent,
owner + "." + dimName +
" dimension has been deleted.");
}
catch (Exception e)
{
JOptionPane.showMessageDialog(parent, e.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
// Roll back the current Transaction.
try
{
mdp.getDataProvider()
.getTransactionProvider()
.rollbackCurrentTransaction();
}
catch (Exception e2)
{
// Ignore the exception.
}
}
}
}
else
{
return;
}
}
}
public boolean refreshTree(Connection conn, String type, Object obj, AW aw,
Map params)
{
return true;
}
// Get the MdmMetadataProvider.
private MdmMetadataProvider getMetadataProvider(Map params)
{
Object dp = params.get("DATAPROVIDER");
if (dp instanceof MdmMetadataProvider)
{
MdmMetadataProvider mdp = (MdmMetadataProvider)dp;
return mdp;
}
return null;
}
// Get the currently selected dimension.
private MdmPrimaryDimension getDimension(String dimName, String schema,
Map params)
{
if (params != null)
{
MdmMetadataProvider mdp = getMetadataProvider(params);
if (mdp != null)
{
// Get the dimension from the MdmMetadataProvider.
MdmObject mobj = mdp.getMetadataObject(schema + "." + dimName);
if (mobj != null && mobj instanceof MdmPrimaryDimension)
{
MdmPrimaryDimension dim = (MdmPrimaryDimension)mobj;
return dim;
}
}
}
return null;
}
}
図3-2に、Analytic Manager WorkspaceによってDeleteDimPluginに対して表示されるメニューを示します。この図は、ユーザーが「MyDims」フォルダのCUSTOMERディメンションを右クリックしたときに表示されるメニューを示します。「MyDims」フォルダは、例3-7のaw.xmlドキュメントによって作成されます。
ユーザーが「サンプル・プラグイン: ディメンションCUSTOMERを削除」をクリックすると、DeleteDimPluginによって図3-3に示すダイアログ・ボックスが表示されます。
ViewerPluginおよびEditorPluginの実装の例は、次のトピックにあります。
これらのトピックでは、プラグインを指定するXMLドキュメントも示されます。
ViewerPluginおよびEditorPluginインタフェースのメソッドは、「ViewerPluginおよびEditorPluginインタフェースの説明」で説明されています。
例3-3のdimension.xmlドキュメントには、MyLevelsという名前のフォルダを指定する<AWMNode>、および現在選択されているディメンションのレベルの名前をUSER_CUBE_DIM_LEVELS表から選択するSQL文があります。名前のない子の<AWMNode>はLevelViewerPluginを指定します。図3-4に、ナビゲーション・ツリーのフォルダおよびドキュメントのプロパティ・インスペクタの表示を示します。
例3-3 dimension.xmlドキュメントの作成
<?xml version="1.0" encoding="US-ASCII" ?> <AWMTree> <AWMNode name="MyLevels" type="levelobj" sql="select level_name from user_cube_dim_levels where dimension_name = {dimension_name} "> <AWMNode type="levelview" viewClass="plugin11202.LevelViewerPlugin"/> </AWMNode> </AWMTree>
例3-4に、LevelViewerPluginクラスを示します。図3-5に示すように、このクラスによって、現在選択されているレベルの名前が表示されます。
例3-4 LevelViewerPluginクラス
package plugin11202;
import java.awt.FlowLayout;
import java.sql.Connection;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JPanel;
import oracle.olap.awm.plugin.ViewerPlugin;
public class LevelViewerPlugin implements ViewerPlugin
{
public boolean isViewerForType(Connection conn, String name)
throws Exception
{
return true;
}
public JPanel getPanel(Connection conn, String name, Map params)
throws Exception
{
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
// Get the name of the current level.
Object obj = params.get("levelobj");
if (obj instanceof String)
{
String levelName = (String)obj;
panel.add(new JLabel(levelName));
}
return panel;
}
public void cleanup(String name)
{
}
}
図3-4に、dimension.xmlドキュメントのMyLevels <AWMNode>の結果を示します。MyLevelsは、アナリティック・ワークスペースの各ディメンション・フォルダに表示されます。ユーザーは「PRODUCT」フォルダの「MyLevels」フォルダを選択しました。<AWMNode>のSQL文の結果は「MyLevels」フォルダに表示されます。プロパティ・インスペクタには、同じSQL文とその結果が表示されます。結果は、ディメンションのレベルのリストです。
図3-5に、dimension.xmlドキュメントのMyLevels <AWMNode>内の名前のない子の<AWMNode>の結果を示します。ユーザーは「MyLevels」フォルダのFAMILYレベルを選択しました。プロパティ・インスペクタには、LevelViewerPluginによって指定されたユーザー・インタフェースが表示されます。プラグインによってレベルの名前が表示されます。
例3-5のcube.xmlドキュメントには、MyMeasuresという名前のフォルダを指定する<AWMNode>、および現在選択されているキューブのメジャーの名前をUSER_CUBE_MEASURES表から選択するSQL文があります。名前のない子の<AWMNode>はMeasureViewerPluginプラグインを指定します。図3-6に、ナビゲーション・ツリーのフォルダおよびドキュメントのプロパティ・インスペクタの表示を示します。
例3-5 cube.xmlドキュメントの作成
<?xml version="1.0" encoding="US-ASCII" ?> <AWMTree> <AWMNode name="MyMeasures" type="measureobj" sql="select measure_name from user_cube_measures where cube_name = {cube_name}"> <AWMNode type="measureview" viewClass="plugin11202.MeasureViewerPlugin"/> </AWMNode> </AWMTree>
例3-6に、MeasureViewerPluginクラスを示します。Figure 3-7に示すように、このクラスによって、現在選択されているメジャーの名前が表示されます。
例3-6 MeasureViewerPluginクラス
package plugin11202;
import java.awt.FlowLayout;
import java.sql.Connection;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JPanel;
import oracle.olap.awm.plugin.ViewerPlugin;
public class MeasureViewerPlugin implements ViewerPlugin
{
public boolean isViewerForType(Connection conn, String name)
throws Exception
{
return true;
}
public JPanel getPanel(Connection conn, String name, Map params)
throws Exception
{
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
// Get the name of the current measure.
Object measureobj = null;
if (params != null)
measureobj = params.get("measureobj");
if (measureobj instanceof String)
{
String measureName = (String)measureobj;
panel.add(new JLabel(measureName));
}
return panel;
}
public void cleanup(String name)
{
}
}
図3-6に、cube.xmlドキュメントのMyMeasures <AWMNode>の結果を示します。「MyMeasures」フォルダは、アナリティック・ワークスペースの各キューブ・フォルダに表示されます。ユーザーは「UNITS_CUBE」フォルダの「MyMeasures」フォルダを選択しました。<AWMNode>のSQL文の結果は「MyMeasures」フォルダに表示されます。プロパティ・インスペクタには、同じSQL文およびその結果が表示されます。結果は、キューブのメジャーおよび計算済メジャーのリストです。
図3-7に、cube.xmlドキュメントのMyMeasures <AWMNode>の名前のない子<AWMNode>の結果を示します。ユーザーは「MyMeasures」フォルダのUNITSメジャーを選択しました。プロパティ・インスペクタには、MeasureViewerPluginによって指定されたユーザー・インタフェースが表示されます。プラグインによってメジャーの名前が表示されます。
例3-7のaw.xmlドキュメントには、MyDimsという名前のフォルダを指定する<AWMNode>があります。MyDims <AWMNode>については、「DimEditorPluginの例」を参照してください。
aw.xmlドキュメントには、MyCubesという名前のフォルダを指定する<AWMNode>、およびUSER_CUBES表から現在のアナリティック・ワークスペースのキューブの名前を選択するSQL文もあります。名前のない子<AWMNode>はCubeViewerPluginを指定します。図3-8に、MyCubes <AWMNode>のナビゲーション・ツリーのフォルダおよびプロパティ・インスペクタの表示を示します。
例3-7 aw.xmlドキュメントの作成
<?xml version="1.0" encoding="US-ASCII" ?> <AWMTree> <AWMNode name="MyDims" type="mydimfolder" viewSql="select dimension_name, dimension_type from user_cube_dimensions where aw_name = {aw_name}"> <AWMNode type="dimobj" sql="select dimension_name from user_cube_dimensions where aw_name = {aw_name}" viewClass="plugin11202.DimEditorPlugin"> </AWMNode> <AWMNode name="MyLevels" type="levelobj" sql="select level_name from user_cube_dim_levels where dimension_name = {dimobj}"> <AWMNode sql="select * from user_cube_dim_levels where dimension_name = {dimobj} and level_name = {levelobj}"/> </AWMNode> </AWMNode> <AWMNode name="MyCubes" type="cubeobj" sql="select cube_name from user_cubes where aw_name = {aw_name}"> <AWMNode type="mycubeview" viewClass="plugin11202.CubeViewerPlugin"/> </AWMNode> </AWMTree>
例3-8に、CubeViewerPluginクラスを示します。図3-9に示すように、このクラスによって、現在選択されているキューブの名前が表示されます。
例3-8 CubeViewerPluginクラス
package plugin11202;
import java.awt.FlowLayout;
import java.sql.Connection;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JPanel;
import oracle.olap.awm.plugin.ViewerPlugin;
public class CubeViewerPlugin implements ViewerPlugin
{
public boolean isViewerForType(Connection conn, String name)
throws Exception
{
return true;
}
public JPanel getPanel(Connection conn, String name, Map params)
throws Exception
{
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
// Get the name of the current cube.
Object cubeobj = null;
if (params != null)
cubeobj = params.get("cubeobj");
if (cubeobj instanceof String)
{
String cubeName = (String)cubeobj;
panel.add(new JLabel(cubeName));
}
return panel;
}
public void cleanup(String name)
{
}
}
図3-8に、aw.xmlドキュメントのMyCubes <AWMNode>の結果を示します。「MyCubes」フォルダは、「GLOBAL」アナリティック・ワークスペース・フォルダに表示されます。ユーザーは「MyCubes」フォルダを選択しました。<AWMNode>のSQL文の結果はフォルダに表示されます。プロパティ・インスペクタには、同じSQL文とその結果が表示されます。この結果は、アナリティック・ワークスペースのキューブのリストです。
図3-9に、aw.xmlドキュメントのMyCubes <AWMNode>の名前のない子<AWMNode>の結果を示します。ユーザーは「MyCubes」フォルダのUNITS_CUBEキューブを選択しました。プロパティ・インスペクタには、CubeViewerPluginによって指定されたユーザー・インタフェースが表示されます。プラグインによってキューブの名前が表示されます。
例3-7のaw.xmlドキュメントには、MyDimsという名前のフォルダを指定する<AWMNode>、およびUSER_CUBE_DIMENSIONS表から現在のアナリティック・ワークスペースのディメンションの名前とタイプを選択するSQL文があります。図3-10に、MyDims <AWMNode>のナビゲーション・ツリーのフォルダおよびプロパティ・インスペクタの表示を示します。
名前のない子<AWMNode>はディメンションの名前を選択するSQLを指定し、DimEditorPluginも指定します。図3-11に、MyDims <AWMNode>のナビゲーション・ツリーのフォルダおよびプロパティ・インスペクタの表示を示します。
名前のない<AWMNode>にネストされたMyLevelsという名前の<AWMNode>は、現在選択されているディメンションのレベルの名前をUSER_CUBE_DIM_LEVELS表から選択します。MyLevels <AWMNode>には、現在選択されているディメンションおよびレベルのすべての列をUSER_CUBE_DIM_LEVELS表から選択する<AWMNode>があります。
例3-9に、DimEditorPluginクラスを示します。図3-11に示すように、このクラスによって、現在選択されているディメンションの名前と簡単な説明が表示されます。ユーザーは簡単な説明の値を変更できます。
例3-9 DimEditorPluginクラス
package plugin11202;
import java.awt.Component;
import java.awt.GridLayout;
import java.sql.Connection;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import oracle.olap.awm.plugin.EditorPlugin;
import oracle.olap.awm.plugin.PanelChanged;
import oracle.olapi.metadata.mdm.MdmDescriptionType;
import oracle.olapi.metadata.mdm.MdmMetadataProvider;
import oracle.olapi.metadata.mdm.MdmObject;
import oracle.olapi.metadata.mdm.MdmPrimaryDimension;
public class DimEditorPlugin implements EditorPlugin
{
private JTextField shortDescTextField;
private PanelChanged parentPanelChanged;
private JPanel panel;
private JLabel dimNameLabel;
private MdmDescriptionType mdmShortDescrDescrType;
public DimEditorPlugin()
{
panel = new JPanel();
panel.setLayout(new GridLayout(3, 1));
dimNameLabel = new JLabel();
panel.add(dimNameLabel);
shortDescTextField = new JTextField();
panel.add(new JLabel("Short Description:"));
panel.add(shortDescTextField);
shortDescTextField.getDocument().addDocumentListener(new DocumentListener()
{
public void insertUpdate(DocumentEvent e)
{
changed();
}
public void removeUpdate(DocumentEvent e)
{
changed();
}
public void changedUpdate(DocumentEvent e)
{
changed();
}
});
}
public boolean isViewerForType(Connection conn, String name)
throws Exception
{
return true;
}
// Get the MdmMetadataProvider of the session.
private MdmMetadataProvider getMetadataProvider(Map params)
{
Object dp = params.get("DATAPROVIDER");
if (dp instanceof MdmMetadataProvider)
{
MdmMetadataProvider mdp = (MdmMetadataProvider)dp;
return mdp;
}
return null;
}
// Get the currently selected dimension and the schema from the params Map.
// Get the MdmMetadataProvider and get the MdmPrimaryDimension for the
// dimension.
private MdmPrimaryDimension getDimension(Map params)
{
Object obj = null;
String schema = "";
if (params != null)
{
obj = params.get("dimobj");
schema = (String)params.get("schema");
}
if (obj instanceof String)
{
String dimName = (String)obj;
MdmMetadataProvider mdp = getMetadataProvider(params);
if (mdp != null)
{
MdmObject mobj = mdp.getMetadataObject(schema + "." + dimName);
if (mobj != null && mobj instanceof MdmPrimaryDimension)
{
MdmPrimaryDimension dim = (MdmPrimaryDimension)mobj;
return dim;
}
else
System.out.println("Cannot get the " + dimName + " dimension.");
}
}
return null;
}
// Get the dimension and the short description of it.
// Display the short description.
private void read(Map params)
{
MdmPrimaryDimension dim = getDimension(params);
if (dim != null)
{
dimNameLabel.setText(dim.getName());
mdmShortDescrDescrType =
MdmDescriptionType.getShortDescriptionDescriptionType();
String shortDesc = dim.getDescription(mdmShortDescrDescrType);
shortDescTextField.setText(shortDesc);
}
}
public JPanel getPanel(Connection conn, String name, Map params)
throws Exception
{
read(params);
return panel;
}
public void cleanup(String name)
{
}
public boolean validate(Connection conn, Component parent, String name,
Map params)
throws Exception
{
String invalidDescr = "foo";
if (shortDescTextField.getText().equals(invalidDescr))
{
JOptionPane.showMessageDialog(parent, "Description cannot be " +
invalidDescr + ".");
return false;
}
return true;
}
public void revert(Connection conn, Component parent, String name,
Map params)
throws Exception
{
read(params);
}
public void showHelp(Connection conn, Component parent, String name,
Map params)
throws Exception
{
JOptionPane.showMessageDialog(parent, "In Help.");
}
public boolean save(Connection conn, Component parent, String name,
Map params)
throws Exception
{
// Get the currently selected dimension and set the short description for
// it.
MdmPrimaryDimension dim = getDimension(params);
dim.setDescription(mdmShortDescrDescrType, shortDescTextField.getText());
// Get the MdmMetadataProvider.
MdmMetadataProvider mdp = getMetadataProvider(params);
if (mdp == null)
return false;
// Get the DataProvider and the TransactionProvider and commit the current
// Transaction. If the Transaction is not committable, roll it back.
try
{
mdp.getDataProvider().getTransactionProvider().commitCurrentTransaction();
}
catch (Exception e)
{
JOptionPane.showMessageDialog(parent, e.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
try
{
mdp.getDataProvider()
.getTransactionProvider()
.rollbackCurrentTransaction();
}
catch (Exception e2)
{
// Ignore the exception.
}
}
return true;
}
public void setValueChanged(Connection conn, String name, Map params,
PanelChanged parentPanelChanged)
{
this.parentPanelChanged = parentPanelChanged;
}
// Calls the changed() method of the PanelChanged object supplied by
// Analytic Workspace Manager when it calls the setValueChanged method.
public void changed()
{
if (parentPanelChanged != null)
parentPanelChanged.changed();
}
}
図3-10に、aw.xmlドキュメントのMyDims <AWMNode>の結果を示します。「MyDims」フォルダは「GLOBAL」アナリティック・ワークスペース・フォルダに表示されます。ユーザーは「MyDims」フォルダを選択しました。プロパティ・インスペクタには、MyDims <AWMNode>のSQL文とその結果が表示されます。結果は、DIMENSION_NAMEおよびDIMENSION_TYPEというヘッダーの列がある表です。列の行には、アナリティック・ワークスペースのディメンションの名前およびディメンションのタイプが含まれています。
MyDims <AWMNode>には、ディメンションの名前を取得するSQL文を含む名前のない子<AWMNode>があります。これらの名前は、ナビゲーション・ツリーの「MyDims」フォルダに表示されます。名前のない子<AWMNode>は、DimEditorPluginプラグインも指定します。
図3-11に、ユーザーがナビゲーション・ツリーの「MyDims」フォルダのCHANNELディメンションを選択した後のAnalytic Workspace Managerのユーザー・インタフェースを示します。プロパティ・インスペクタには、DimEditorPluginによって指定されたユーザー・インタフェースが表示されます。このユーザー・インタフェースにはテキスト・フィールドがあり、ユーザーは短い説明の属性の値を変更できます。
図3-12に、aw.xmlドキュメントのMyDims <AWMNODE>の子であるMyLevels <AWMNODE>の結果を示します。MyLevels <AWMNode>のSQL文は、現在選択されているディメンションのLEVEL_NAME列をUSER_CUBE_DIM_LEVELS表から選択します。図3-12に、「CHANNEL」フォルダの「MyLevels」フォルダが選択されたナビゲーション・ツリーを示します。プロパティ・インスペクタには、問合せの結果が表示されます。
図3-13に、aw.xmlドキュメントのMyLevels <AWMNODE>の子である名前のない<AWMNODE>の結果を示します。名前のない<AWMNode>のSQL文は、現在選択されているディメンションと表のすべての列をUSER_CUBE_DIM_LEVELS表から選択します。図3-13に、「CHANNEL」フォルダの「MyLevels」フォルダのTOTALレベルが選択されたナビゲーション・ツリーのフォルダを示します。プロパティ・インスペクタには、問合せの結果が表示されます。
図3-13 aw.xmlのMyLevels <AWMNode>にネストされた<AWMNode>の結果

「使用可能なプラグインの説明」で説明するように、awmplugin.xmlファイルにはAnalytic Workspace Managerによって表示されるJavaプラグインの説明が含まれています。図3-14に、例3-10のawmplugin.xmlドキュメントによって指定された情報を表示する「情報」ダイアログ・ボックスの「プラグイン」タブを示します。
例3-10に、図3-14に示す結果を生成するawmplugin.xmlドキュメントを示します。
例3-10 awmplugins.xmlドキュメントの作成
<?xml version="1.0" encoding="utf-8" ?>
<AWMPlugins>
<Plugin name="Cube Viewer Plug-in" version="1.0"
class="plugin11202.CubeViewerPlugin">
<Description>Displays the name of a cube.</Description>
</Plugin>
<Plugin name="Level Viewer Plug-in" version="1.0"
class="plugin11202.LevelViewerPlugin">
<Description>Displays the name of a level.</Description>
</Plugin>
<Plugin name="Measure Viewer Plug-in" version="1.0"
class="plugin11202.MeasureViewerPlugin">
<Description>Displays the name of a measure.</Description>
</Plugin>
<Plugin name="Delete Dimension Plug-in" version="2.0"
class="plugin11202.DeleteDimPlugin">
<Description>Deletes a dimension in the MyDims folder.</Description>
</Plugin>
<Plugin name="Edit Dimension Plug-in" version="2.0"
class="plugin11202.DimEditorPlugin">
<Description>Edits the short description of a dimension.</Description>
</Plugin>
<Plugin name="View XML Plug-in" version="1.0" class="plugin11202.ViewXMLPlugin">
<Description>Displays the XML for an OLAP measure.</Description>
</Plugin>
</AWMPlugins>