この章では、AWMPlugin
、ViewerPlugin
およびEditorPlugin
インタフェースを実装するJavaクラスの例を示します。また、プラグインを指定するXMLドキュメントの例も示します。
この章の内容は次のとおりです。
この章と第1章のJavaクラスおよびXMLドキュメントの例には、クラスまたはドキュメントの完全なコードが含まれています。完全なコードは、Oracle Technology Network (OTN)のWebサイトからダウンロードできる圧縮ファイルでも入手できます。ダウンロードには、プラグインのコンパイル済class
ファイルも含まれます。OTNのWebサイトは次の場所にあります。
http://www.oracle.com/technetwork/database/options/olap/index.html
サンプルを取得するには、Webページの「Download」セクションで、「Sample Code & Schemas」を選択します。「Oracle OLAP Downloads」ページで、「AWM Plug-ins for Oracle OLAP 11g」セクションのAWM Java Plug-in and XML for 11.2.0.1の行で、「examples」をクリックします。
圧縮ファイルをダウンロードし、その内容を抽出します。圧縮ファイルには、次のファイルが含まれています。
ファイル名 | 説明 |
---|---|
readme.txt |
zip ファイルの内容を簡単に説明しています。 |
awmcalcs.xml |
例1-9「AWMCalcsドキュメントの例」のXMLが含まれます。 |
awmtree.xml |
例1-3「SELECT文へのビューの名前の引渡し」のXMLが含まれます。 |
plugin112.jar |
plugin112 という名前のディレクトリが含まれます(このディレクトリは、サンプルを含むパッケージです)。ディレクトリには、第3章の例のxml 、java およびclass ファイルがあります。 |
awmcalcs.xml
ファイルとawmtree.xml
ファイルはAnalytic Workspace Managerの実行可能ファイルと同じディレクトリに配置します。plugin112.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 plugin112; 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
ドキュメントで作成されます。
ユーザーが「Example Plug-in: Delete Dimension 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="plugin112.LevelViewerPlugin"/> </AWMNode> </AWMTree>
例3-4に、LevelViewerPlugin
クラスを示します。図3-5に示すように、このクラスによって、現在選択されているレベルの名前が表示されます。
例3-4 LevelViewerPluginクラス
package plugin112; 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="plugin112.MeasureViewerPlugin"/> </AWMNode> </AWMTree>
例3-6に、MeasureViewerPlugin
クラスを示します。図3-7に示すように、このクラスによって、現在選択されているメジャーの名前が表示されます。
例3-6 MeasureViewerPluginクラス
package plugin112; 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="plugin112.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="plugin112.CubeViewerPlugin"/> </AWMNode> </AWMTree>
例3-8に、CubeViewerPlugin
クラスを示します。図3-9に示すように、このクラスによって、現在選択されているキューブの名前が表示されます。
例3-8 CubeViewerPluginクラス
package plugin112; 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 plugin112; 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="plugin112.CubeViewerPlugin"> <Description>Displays the name of a cube.</Description> </Plugin> <Plugin name="Level Viewer Plug-in" version="1.0" class="plugin112.LevelViewerPlugin"> <Description>Displays the name of a level.</Description> </Plugin> <Plugin name="Measure Viewer Plug-in" version="1.0" class="plugin112.MeasureViewerPlugin"> <Description>Displays the name of a measure.</Description> </Plugin> <Plugin name="Delete Dimension Plug-in" version="2.0" class="plugin112.DeleteDimPlugin"> <Description>Deletes a dimension in the MyDims folder.</Description> </Plugin> <Plugin name="Edit Dimension Plug-in" version="2.0" class="plugin112.DimEditorPlugin"> <Description>Edits the short description of a dimension.</Description> </Plugin> <Plugin name="View XML Plug-in" version="1.0" class="plugin112.ViewXMLPlugin"> <Description>Displays the XML for an OLAP measure.</Description> </Plugin> </AWMPlugins>