001 /* 002 // $Id: //open/mondrian/src/main/mondrian/olap4j/MondrianOlap4jDatabaseMetaData.java#2 $ 003 // This software is subject to the terms of the Common Public License 004 // Agreement, available at the following URL: 005 // http://www.opensource.org/licenses/cpl.html. 006 // Copyright (C) 2007-2008 Julian Hyde 007 // All Rights Reserved. 008 // You must accept the terms of that agreement to use this software. 009 */ 010 package mondrian.olap4j; 011 012 import mondrian.olap.MondrianServer; 013 import mondrian.xmla.XmlaUtil; 014 015 import org.olap4j.OlapDatabaseMetaData; 016 import org.olap4j.OlapException; 017 import org.olap4j.OlapConnection; 018 import org.olap4j.impl.NamedListImpl; 019 import org.olap4j.impl.Olap4jUtil; 020 import org.olap4j.metadata.*; 021 022 import java.sql.ResultSet; 023 import java.sql.SQLException; 024 import java.util.*; 025 026 /** 027 * Implementation of {@link org.olap4j.OlapDatabaseMetaData} 028 * for the Mondrian OLAP engine. 029 * 030 * <p>This class has sub-classes which implement JDBC 3.0 and JDBC 4.0 APIs; 031 * it is instantiated using {@link Factory#newDatabaseMetaData}.</p> 032 * 033 * @author jhyde 034 * @version $Id: //open/mondrian/src/main/mondrian/olap4j/MondrianOlap4jDatabaseMetaData.java#2 $ 035 * @since May 23, 2007 036 */ 037 abstract class MondrianOlap4jDatabaseMetaData implements OlapDatabaseMetaData { 038 final MondrianOlap4jConnection olap4jConnection; 039 final MondrianServer mondrianServer; 040 041 // A mondrian instance contains only one catalog (and one schema). 042 private final MondrianOlap4jCatalog olap4jCatalog = 043 new MondrianOlap4jCatalog(this); 044 045 MondrianOlap4jDatabaseMetaData( 046 MondrianOlap4jConnection olap4jConnection) 047 { 048 this.olap4jConnection = olap4jConnection; 049 mondrianServer = 050 MondrianServer.forConnection(olap4jConnection.connection); 051 } 052 053 // helpers 054 055 /** 056 * Executes a metadata query and returns the result as a JDBC 057 * {@link ResultSet}. 058 * 059 * @param methodName Name of the metadata request. Corresponds to the XMLA 060 * method name, e.g. "MDSCHEMA_CUBES" 061 * 062 * @param patternValues Array of alternating parameter name and value 063 * pairs. If the parameter value is null, it is ignored. 064 * 065 * @return Result set of metadata 066 */ 067 private ResultSet getMetadata( 068 String methodName, 069 Object... patternValues) 070 { 071 Map<String, Object> restrictionMap = 072 new HashMap<String, Object>(); 073 assert patternValues.length % 2 == 0; 074 for (int i = 0; i < patternValues.length / 2; ++i) { 075 final String key = (String) patternValues[i * 2]; 076 Object value = patternValues[i * 2 + 1]; 077 if (value != null) { 078 if (value instanceof String) { 079 value = Collections.singletonList((String) value); 080 } 081 restrictionMap.put(key, value); 082 } 083 } 084 XmlaUtil.MetadataRowset rowset = 085 XmlaUtil.getMetadataRowset( 086 olap4jConnection.connection, 087 MondrianOlap4jConnection.LOCALDB_CATALOG_NAME, 088 methodName, 089 restrictionMap); 090 return olap4jConnection.factory.newFixedResultSet( 091 olap4jConnection, rowset.headerList, rowset.rowList); 092 } 093 094 private XmlaUtil.Wildcard wildcard(String pattern) { 095 return pattern == null 096 ? null 097 : new XmlaUtil.Wildcard(pattern); 098 } 099 100 // package-protected 101 NamedList<Catalog> getCatalogObjects() { 102 NamedList<MondrianOlap4jCatalog> list = 103 new NamedListImpl<MondrianOlap4jCatalog>(); 104 list.add(olap4jCatalog); 105 return Olap4jUtil.cast(list); 106 } 107 108 // implement DatabaseMetaData 109 110 public boolean allProceduresAreCallable() throws SQLException { 111 throw new UnsupportedOperationException(); 112 } 113 114 public boolean allTablesAreSelectable() throws SQLException { 115 throw new UnsupportedOperationException(); 116 } 117 118 public String getURL() throws SQLException { 119 return olap4jConnection.connection.getConnectString(); 120 } 121 122 public String getUserName() throws SQLException { 123 // mondrian does not support a user name property 124 return null; 125 } 126 127 public boolean isReadOnly() throws SQLException { 128 // all mondrian databases are read-only 129 return true; 130 } 131 132 public boolean nullsAreSortedHigh() throws SQLException { 133 throw new UnsupportedOperationException(); 134 } 135 136 public boolean nullsAreSortedLow() throws SQLException { 137 throw new UnsupportedOperationException(); 138 } 139 140 public boolean nullsAreSortedAtStart() throws SQLException { 141 throw new UnsupportedOperationException(); 142 } 143 144 public boolean nullsAreSortedAtEnd() throws SQLException { 145 throw new UnsupportedOperationException(); 146 } 147 148 public String getDatabaseProductName() throws SQLException { 149 return mondrianServer.getVersion().getProductName(); 150 } 151 152 public String getDatabaseProductVersion() throws SQLException { 153 return mondrianServer.getVersion().getVersionString(); 154 } 155 156 public String getDriverName() throws SQLException { 157 return MondrianOlap4jDriver.NAME; 158 } 159 160 public String getDriverVersion() throws SQLException { 161 return MondrianOlap4jDriver.VERSION; 162 } 163 164 public int getDriverMajorVersion() { 165 return MondrianOlap4jDriver.MAJOR_VERSION; 166 } 167 168 public int getDriverMinorVersion() { 169 return MondrianOlap4jDriver.MINOR_VERSION; 170 } 171 172 public boolean usesLocalFiles() throws SQLException { 173 throw new UnsupportedOperationException(); 174 } 175 176 public boolean usesLocalFilePerTable() throws SQLException { 177 throw new UnsupportedOperationException(); 178 } 179 180 public boolean supportsMixedCaseIdentifiers() throws SQLException { 181 throw new UnsupportedOperationException(); 182 } 183 184 public boolean storesUpperCaseIdentifiers() throws SQLException { 185 throw new UnsupportedOperationException(); 186 } 187 188 public boolean storesLowerCaseIdentifiers() throws SQLException { 189 throw new UnsupportedOperationException(); 190 } 191 192 public boolean storesMixedCaseIdentifiers() throws SQLException { 193 throw new UnsupportedOperationException(); 194 } 195 196 public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { 197 throw new UnsupportedOperationException(); 198 } 199 200 public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { 201 throw new UnsupportedOperationException(); 202 } 203 204 public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { 205 throw new UnsupportedOperationException(); 206 } 207 208 public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { 209 throw new UnsupportedOperationException(); 210 } 211 212 public String getIdentifierQuoteString() throws SQLException { 213 throw new UnsupportedOperationException(); 214 } 215 216 public String getSQLKeywords() throws SQLException { 217 throw new UnsupportedOperationException(); 218 } 219 220 public String getNumericFunctions() throws SQLException { 221 throw new UnsupportedOperationException(); 222 } 223 224 public String getStringFunctions() throws SQLException { 225 throw new UnsupportedOperationException(); 226 } 227 228 public String getSystemFunctions() throws SQLException { 229 throw new UnsupportedOperationException(); 230 } 231 232 public String getTimeDateFunctions() throws SQLException { 233 throw new UnsupportedOperationException(); 234 } 235 236 public String getSearchStringEscape() throws SQLException { 237 throw new UnsupportedOperationException(); 238 } 239 240 public String getExtraNameCharacters() throws SQLException { 241 throw new UnsupportedOperationException(); 242 } 243 244 public boolean supportsAlterTableWithAddColumn() throws SQLException { 245 throw new UnsupportedOperationException(); 246 } 247 248 public boolean supportsAlterTableWithDropColumn() throws SQLException { 249 throw new UnsupportedOperationException(); 250 } 251 252 public boolean supportsColumnAliasing() throws SQLException { 253 throw new UnsupportedOperationException(); 254 } 255 256 public boolean nullPlusNonNullIsNull() throws SQLException { 257 throw new UnsupportedOperationException(); 258 } 259 260 public boolean supportsConvert() throws SQLException { 261 throw new UnsupportedOperationException(); 262 } 263 264 public boolean supportsConvert( 265 int fromType, int toType) throws SQLException { 266 throw new UnsupportedOperationException(); 267 } 268 269 public boolean supportsTableCorrelationNames() throws SQLException { 270 throw new UnsupportedOperationException(); 271 } 272 273 public boolean supportsDifferentTableCorrelationNames() throws SQLException { 274 throw new UnsupportedOperationException(); 275 } 276 277 public boolean supportsExpressionsInOrderBy() throws SQLException { 278 throw new UnsupportedOperationException(); 279 } 280 281 public boolean supportsOrderByUnrelated() throws SQLException { 282 throw new UnsupportedOperationException(); 283 } 284 285 public boolean supportsGroupBy() throws SQLException { 286 throw new UnsupportedOperationException(); 287 } 288 289 public boolean supportsGroupByUnrelated() throws SQLException { 290 throw new UnsupportedOperationException(); 291 } 292 293 public boolean supportsGroupByBeyondSelect() throws SQLException { 294 throw new UnsupportedOperationException(); 295 } 296 297 public boolean supportsLikeEscapeClause() throws SQLException { 298 throw new UnsupportedOperationException(); 299 } 300 301 public boolean supportsMultipleResultSets() throws SQLException { 302 throw new UnsupportedOperationException(); 303 } 304 305 public boolean supportsMultipleTransactions() throws SQLException { 306 throw new UnsupportedOperationException(); 307 } 308 309 public boolean supportsNonNullableColumns() throws SQLException { 310 throw new UnsupportedOperationException(); 311 } 312 313 public boolean supportsMinimumSQLGrammar() throws SQLException { 314 throw new UnsupportedOperationException(); 315 } 316 317 public boolean supportsCoreSQLGrammar() throws SQLException { 318 throw new UnsupportedOperationException(); 319 } 320 321 public boolean supportsExtendedSQLGrammar() throws SQLException { 322 throw new UnsupportedOperationException(); 323 } 324 325 public boolean supportsANSI92EntryLevelSQL() throws SQLException { 326 throw new UnsupportedOperationException(); 327 } 328 329 public boolean supportsANSI92IntermediateSQL() throws SQLException { 330 throw new UnsupportedOperationException(); 331 } 332 333 public boolean supportsANSI92FullSQL() throws SQLException { 334 throw new UnsupportedOperationException(); 335 } 336 337 public boolean supportsIntegrityEnhancementFacility() throws SQLException { 338 throw new UnsupportedOperationException(); 339 } 340 341 public boolean supportsOuterJoins() throws SQLException { 342 throw new UnsupportedOperationException(); 343 } 344 345 public boolean supportsFullOuterJoins() throws SQLException { 346 throw new UnsupportedOperationException(); 347 } 348 349 public boolean supportsLimitedOuterJoins() throws SQLException { 350 throw new UnsupportedOperationException(); 351 } 352 353 public String getSchemaTerm() throws SQLException { 354 throw new UnsupportedOperationException(); 355 } 356 357 public String getProcedureTerm() throws SQLException { 358 throw new UnsupportedOperationException(); 359 } 360 361 public String getCatalogTerm() throws SQLException { 362 throw new UnsupportedOperationException(); 363 } 364 365 public boolean isCatalogAtStart() throws SQLException { 366 throw new UnsupportedOperationException(); 367 } 368 369 public String getCatalogSeparator() throws SQLException { 370 throw new UnsupportedOperationException(); 371 } 372 373 public boolean supportsSchemasInDataManipulation() throws SQLException { 374 throw new UnsupportedOperationException(); 375 } 376 377 public boolean supportsSchemasInProcedureCalls() throws SQLException { 378 throw new UnsupportedOperationException(); 379 } 380 381 public boolean supportsSchemasInTableDefinitions() throws SQLException { 382 throw new UnsupportedOperationException(); 383 } 384 385 public boolean supportsSchemasInIndexDefinitions() throws SQLException { 386 throw new UnsupportedOperationException(); 387 } 388 389 public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { 390 throw new UnsupportedOperationException(); 391 } 392 393 public boolean supportsCatalogsInDataManipulation() throws SQLException { 394 throw new UnsupportedOperationException(); 395 } 396 397 public boolean supportsCatalogsInProcedureCalls() throws SQLException { 398 throw new UnsupportedOperationException(); 399 } 400 401 public boolean supportsCatalogsInTableDefinitions() throws SQLException { 402 throw new UnsupportedOperationException(); 403 } 404 405 public boolean supportsCatalogsInIndexDefinitions() throws SQLException { 406 throw new UnsupportedOperationException(); 407 } 408 409 public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { 410 throw new UnsupportedOperationException(); 411 } 412 413 public boolean supportsPositionedDelete() throws SQLException { 414 throw new UnsupportedOperationException(); 415 } 416 417 public boolean supportsPositionedUpdate() throws SQLException { 418 throw new UnsupportedOperationException(); 419 } 420 421 public boolean supportsSelectForUpdate() throws SQLException { 422 throw new UnsupportedOperationException(); 423 } 424 425 public boolean supportsStoredProcedures() throws SQLException { 426 throw new UnsupportedOperationException(); 427 } 428 429 public boolean supportsSubqueriesInComparisons() throws SQLException { 430 throw new UnsupportedOperationException(); 431 } 432 433 public boolean supportsSubqueriesInExists() throws SQLException { 434 throw new UnsupportedOperationException(); 435 } 436 437 public boolean supportsSubqueriesInIns() throws SQLException { 438 throw new UnsupportedOperationException(); 439 } 440 441 public boolean supportsSubqueriesInQuantifieds() throws SQLException { 442 throw new UnsupportedOperationException(); 443 } 444 445 public boolean supportsCorrelatedSubqueries() throws SQLException { 446 throw new UnsupportedOperationException(); 447 } 448 449 public boolean supportsUnion() throws SQLException { 450 throw new UnsupportedOperationException(); 451 } 452 453 public boolean supportsUnionAll() throws SQLException { 454 throw new UnsupportedOperationException(); 455 } 456 457 public boolean supportsOpenCursorsAcrossCommit() throws SQLException { 458 throw new UnsupportedOperationException(); 459 } 460 461 public boolean supportsOpenCursorsAcrossRollback() throws SQLException { 462 throw new UnsupportedOperationException(); 463 } 464 465 public boolean supportsOpenStatementsAcrossCommit() throws SQLException { 466 throw new UnsupportedOperationException(); 467 } 468 469 public boolean supportsOpenStatementsAcrossRollback() throws SQLException { 470 throw new UnsupportedOperationException(); 471 } 472 473 public int getMaxBinaryLiteralLength() throws SQLException { 474 throw new UnsupportedOperationException(); 475 } 476 477 public int getMaxCharLiteralLength() throws SQLException { 478 throw new UnsupportedOperationException(); 479 } 480 481 public int getMaxColumnNameLength() throws SQLException { 482 throw new UnsupportedOperationException(); 483 } 484 485 public int getMaxColumnsInGroupBy() throws SQLException { 486 throw new UnsupportedOperationException(); 487 } 488 489 public int getMaxColumnsInIndex() throws SQLException { 490 throw new UnsupportedOperationException(); 491 } 492 493 public int getMaxColumnsInOrderBy() throws SQLException { 494 throw new UnsupportedOperationException(); 495 } 496 497 public int getMaxColumnsInSelect() throws SQLException { 498 throw new UnsupportedOperationException(); 499 } 500 501 public int getMaxColumnsInTable() throws SQLException { 502 throw new UnsupportedOperationException(); 503 } 504 505 public int getMaxConnections() throws SQLException { 506 throw new UnsupportedOperationException(); 507 } 508 509 public int getMaxCursorNameLength() throws SQLException { 510 throw new UnsupportedOperationException(); 511 } 512 513 public int getMaxIndexLength() throws SQLException { 514 throw new UnsupportedOperationException(); 515 } 516 517 public int getMaxSchemaNameLength() throws SQLException { 518 throw new UnsupportedOperationException(); 519 } 520 521 public int getMaxProcedureNameLength() throws SQLException { 522 throw new UnsupportedOperationException(); 523 } 524 525 public int getMaxCatalogNameLength() throws SQLException { 526 throw new UnsupportedOperationException(); 527 } 528 529 public int getMaxRowSize() throws SQLException { 530 throw new UnsupportedOperationException(); 531 } 532 533 public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { 534 throw new UnsupportedOperationException(); 535 } 536 537 public int getMaxStatementLength() throws SQLException { 538 throw new UnsupportedOperationException(); 539 } 540 541 public int getMaxStatements() throws SQLException { 542 throw new UnsupportedOperationException(); 543 } 544 545 public int getMaxTableNameLength() throws SQLException { 546 throw new UnsupportedOperationException(); 547 } 548 549 public int getMaxTablesInSelect() throws SQLException { 550 throw new UnsupportedOperationException(); 551 } 552 553 public int getMaxUserNameLength() throws SQLException { 554 throw new UnsupportedOperationException(); 555 } 556 557 public int getDefaultTransactionIsolation() throws SQLException { 558 throw new UnsupportedOperationException(); 559 } 560 561 public boolean supportsTransactions() throws SQLException { 562 throw new UnsupportedOperationException(); 563 } 564 565 public boolean supportsTransactionIsolationLevel(int level) throws SQLException { 566 throw new UnsupportedOperationException(); 567 } 568 569 public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { 570 throw new UnsupportedOperationException(); 571 } 572 573 public boolean supportsDataManipulationTransactionsOnly() throws SQLException { 574 throw new UnsupportedOperationException(); 575 } 576 577 public boolean dataDefinitionCausesTransactionCommit() throws SQLException { 578 throw new UnsupportedOperationException(); 579 } 580 581 public boolean dataDefinitionIgnoredInTransactions() throws SQLException { 582 throw new UnsupportedOperationException(); 583 } 584 585 public ResultSet getProcedures( 586 String catalog, 587 String schemaPattern, 588 String procedureNamePattern) throws SQLException { 589 throw new UnsupportedOperationException(); 590 } 591 592 public ResultSet getProcedureColumns( 593 String catalog, 594 String schemaPattern, 595 String procedureNamePattern, 596 String columnNamePattern) throws SQLException { 597 throw new UnsupportedOperationException(); 598 } 599 600 public ResultSet getTables( 601 String catalog, 602 String schemaPattern, 603 String tableNamePattern, 604 String types[]) throws SQLException { 605 throw new UnsupportedOperationException(); 606 } 607 608 public ResultSet getSchemas() throws SQLException { 609 if (false) { 610 // Do not use DBSCHEMA_SCHEMATA: it has different columns than the 611 // JDBC spec requires 612 return getMetadata("DBSCHEMA_SCHEMATA"); 613 } 614 List<String> headerList = 615 Arrays.asList("TABLE_SCHEM", "TABLE_CAT"); 616 List<List<Object>> rowList = new ArrayList<List<Object>>(); 617 for (Schema schema : olap4jCatalog.getSchemas()) { 618 rowList.add( 619 Arrays.asList( 620 (Object) schema.getName(), 621 schema.getCatalog().getName())); 622 } 623 return olap4jConnection.factory.newFixedResultSet( 624 olap4jConnection, headerList, rowList); 625 } 626 627 public ResultSet getCatalogs() throws SQLException { 628 if (false) { 629 // Do not use DBSCHEMA_CATALOGS: it has different columns than the 630 // JDBC spec requires 631 return getMetadata("DBSCHEMA_CATALOGS"); 632 } 633 634 List<String> headerList = 635 Arrays.asList("TABLE_CAT"); 636 List<List<Object>> rowList = 637 Collections.singletonList( 638 Arrays.asList((Object) olap4jCatalog.getName())); 639 return olap4jConnection.factory.newFixedResultSet( 640 olap4jConnection, headerList, rowList); 641 } 642 643 public ResultSet getTableTypes() throws SQLException { 644 throw new UnsupportedOperationException(); 645 } 646 647 public ResultSet getColumns( 648 String catalog, 649 String schemaPattern, 650 String tableNamePattern, 651 String columnNamePattern) throws SQLException { 652 throw new UnsupportedOperationException(); 653 } 654 655 public ResultSet getColumnPrivileges( 656 String catalog, 657 String schema, 658 String table, 659 String columnNamePattern) throws SQLException { 660 throw new UnsupportedOperationException(); 661 } 662 663 public ResultSet getTablePrivileges( 664 String catalog, 665 String schemaPattern, 666 String tableNamePattern) throws SQLException { 667 throw new UnsupportedOperationException(); 668 } 669 670 public ResultSet getBestRowIdentifier( 671 String catalog, 672 String schema, 673 String table, 674 int scope, 675 boolean nullable) throws SQLException { 676 throw new UnsupportedOperationException(); 677 } 678 679 public ResultSet getVersionColumns( 680 String catalog, String schema, String table) throws SQLException { 681 throw new UnsupportedOperationException(); 682 } 683 684 public ResultSet getPrimaryKeys( 685 String catalog, String schema, String table) throws SQLException { 686 throw new UnsupportedOperationException(); 687 } 688 689 public ResultSet getImportedKeys( 690 String catalog, String schema, String table) throws SQLException { 691 throw new UnsupportedOperationException(); 692 } 693 694 public ResultSet getExportedKeys( 695 String catalog, String schema, String table) throws SQLException { 696 throw new UnsupportedOperationException(); 697 } 698 699 public ResultSet getCrossReference( 700 String parentCatalog, 701 String parentSchema, 702 String parentTable, 703 String foreignCatalog, 704 String foreignSchema, 705 String foreignTable) throws SQLException { 706 throw new UnsupportedOperationException(); 707 } 708 709 public ResultSet getTypeInfo() throws SQLException { 710 throw new UnsupportedOperationException(); 711 } 712 713 public ResultSet getIndexInfo( 714 String catalog, 715 String schema, 716 String table, 717 boolean unique, 718 boolean approximate) throws SQLException { 719 throw new UnsupportedOperationException(); 720 } 721 722 public boolean supportsResultSetType(int type) throws SQLException { 723 throw new UnsupportedOperationException(); 724 } 725 726 public boolean supportsResultSetConcurrency( 727 int type, int concurrency) throws SQLException { 728 throw new UnsupportedOperationException(); 729 } 730 731 public boolean ownUpdatesAreVisible(int type) throws SQLException { 732 throw new UnsupportedOperationException(); 733 } 734 735 public boolean ownDeletesAreVisible(int type) throws SQLException { 736 throw new UnsupportedOperationException(); 737 } 738 739 public boolean ownInsertsAreVisible(int type) throws SQLException { 740 throw new UnsupportedOperationException(); 741 } 742 743 public boolean othersUpdatesAreVisible(int type) throws SQLException { 744 throw new UnsupportedOperationException(); 745 } 746 747 public boolean othersDeletesAreVisible(int type) throws SQLException { 748 throw new UnsupportedOperationException(); 749 } 750 751 public boolean othersInsertsAreVisible(int type) throws SQLException { 752 throw new UnsupportedOperationException(); 753 } 754 755 public boolean updatesAreDetected(int type) throws SQLException { 756 throw new UnsupportedOperationException(); 757 } 758 759 public boolean deletesAreDetected(int type) throws SQLException { 760 throw new UnsupportedOperationException(); 761 } 762 763 public boolean insertsAreDetected(int type) throws SQLException { 764 throw new UnsupportedOperationException(); 765 } 766 767 public boolean supportsBatchUpdates() throws SQLException { 768 throw new UnsupportedOperationException(); 769 } 770 771 public ResultSet getUDTs( 772 String catalog, 773 String schemaPattern, 774 String typeNamePattern, 775 int[] types) throws SQLException { 776 throw new UnsupportedOperationException(); 777 } 778 779 public OlapConnection getConnection() { 780 return olap4jConnection; 781 } 782 783 public boolean supportsSavepoints() throws SQLException { 784 throw new UnsupportedOperationException(); 785 } 786 787 public boolean supportsNamedParameters() throws SQLException { 788 throw new UnsupportedOperationException(); 789 } 790 791 public boolean supportsMultipleOpenResults() throws SQLException { 792 throw new UnsupportedOperationException(); 793 } 794 795 public boolean supportsGetGeneratedKeys() throws SQLException { 796 throw new UnsupportedOperationException(); 797 } 798 799 public ResultSet getSuperTypes( 800 String catalog, 801 String schemaPattern, 802 String typeNamePattern) throws SQLException { 803 throw new UnsupportedOperationException(); 804 } 805 806 public ResultSet getSuperTables( 807 String catalog, 808 String schemaPattern, 809 String tableNamePattern) throws SQLException { 810 throw new UnsupportedOperationException(); 811 } 812 813 public ResultSet getAttributes( 814 String catalog, 815 String schemaPattern, 816 String typeNamePattern, 817 String attributeNamePattern) throws SQLException { 818 throw new UnsupportedOperationException(); 819 } 820 821 public boolean supportsResultSetHoldability(int holdability) throws SQLException { 822 throw new UnsupportedOperationException(); 823 } 824 825 public int getResultSetHoldability() throws SQLException { 826 throw new UnsupportedOperationException(); 827 } 828 829 public int getDatabaseMajorVersion() throws SQLException { 830 return mondrianServer.getVersion().getMajorVersion(); 831 } 832 833 public int getDatabaseMinorVersion() throws SQLException { 834 return mondrianServer.getVersion().getMajorVersion(); 835 } 836 837 public int getJDBCMajorVersion() throws SQLException { 838 // mondrian olap4j supports jdbc 4.0 839 return 4; 840 } 841 842 public int getJDBCMinorVersion() throws SQLException { 843 // mondrian olap4j supports jdbc 4.0 844 return 0; 845 } 846 847 public int getSQLStateType() throws SQLException { 848 throw new UnsupportedOperationException(); 849 } 850 851 public boolean locatorsUpdateCopy() throws SQLException { 852 throw new UnsupportedOperationException(); 853 } 854 855 public boolean supportsStatementPooling() throws SQLException { 856 throw new UnsupportedOperationException(); 857 } 858 859 // implement java.sql.Wrapper 860 861 // straightforward implementation of unwrap and isWrapperFor, since this 862 // class already implements the interface they most likely require: 863 // DatabaseMetaData and OlapDatabaseMetaData 864 865 public <T> T unwrap(Class<T> iface) throws SQLException { 866 if (iface.isInstance(this)) { 867 return iface.cast(this); 868 } 869 throw olap4jConnection.helper.createException( 870 "does not implement '" + iface + "'"); 871 } 872 873 public boolean isWrapperFor(Class<?> iface) throws SQLException { 874 return iface.isInstance(this); 875 } 876 877 // implement OlapDatabaseMetaData 878 879 public ResultSet getActions( 880 String catalog, 881 String schemaPattern, 882 String cubeNamePattern, 883 String actionNamePattern) throws OlapException 884 { 885 return getMetadata( 886 "MDSCHEMA_ACTIONS", 887 "SCHEMA_NAME", wildcard(schemaPattern), 888 "CUBE_NAME", wildcard(cubeNamePattern), 889 "ACTION_NAME", wildcard(actionNamePattern)); 890 } 891 892 public ResultSet getDatasources() throws OlapException { 893 return getMetadata("DISCOVER_DATASOURCES"); 894 } 895 896 public ResultSet getLiterals() throws OlapException { 897 return getMetadata("DISCOVER_LITERALS"); 898 } 899 900 public ResultSet getDatabaseProperties( 901 String dataSourceName, 902 String propertyNamePattern) throws OlapException 903 { 904 return getMetadata("DISCOVER_PROPERTIES"); 905 } 906 907 public ResultSet getProperties( 908 String catalog, 909 String schemaPattern, 910 String cubeNamePattern, 911 String dimensionUniqueName, 912 String hierarchyUniqueName, 913 String levelUniqueName, 914 String memberUniqueName, 915 String propertyNamePattern) throws OlapException 916 { 917 return getMetadata( 918 "MDSCHEMA_PROPERTIES", 919 "CATALOG_NAME", catalog, 920 "SCHEMA_NAME", wildcard(schemaPattern), 921 "CUBE_NAME", wildcard(cubeNamePattern), 922 "DIMENSION_UNIQUE_NAME", dimensionUniqueName, 923 "HIERARCHY_UNIQUE_NAME", hierarchyUniqueName, 924 "LEVEL_UNIQUE_NAME", levelUniqueName, 925 "MEMBER_UNIQUE_NAME", memberUniqueName, 926 "PROPERTY_NAME", wildcard(propertyNamePattern)); 927 } 928 929 public String getMdxKeywords() throws OlapException { 930 StringBuilder buf = new StringBuilder(); 931 for (String keyword : mondrianServer.getKeywords()) { 932 if (buf.length() > 0) { 933 buf.append(','); 934 } 935 buf.append(keyword); 936 } 937 return buf.toString(); 938 } 939 940 public ResultSet getCubes( 941 String catalog, 942 String schemaPattern, 943 String cubeNamePattern) 944 throws OlapException 945 { 946 return getMetadata( 947 "MDSCHEMA_CUBES", 948 "CATALOG_NAME", catalog, 949 "SCHEMA_NAME", wildcard(schemaPattern), 950 "CUBE_NAME", wildcard(cubeNamePattern)); 951 } 952 953 public ResultSet getDimensions( 954 String catalog, 955 String schemaPattern, 956 String cubeNamePattern, 957 String dimensionNamePattern) 958 throws OlapException 959 { 960 return getMetadata( 961 "MDSCHEMA_DIMENSIONS", 962 "SCHEMA_NAME", wildcard(schemaPattern), 963 "CUBE_NAME", wildcard(cubeNamePattern), 964 "DIMSENSION_NAME", wildcard(dimensionNamePattern)); 965 } 966 967 public ResultSet getOlapFunctions( 968 String functionNamePattern) throws OlapException 969 { 970 return getMetadata( 971 "MDSCHEMA_FUNCTIONS", 972 "FUNCTION_NAME", wildcard(functionNamePattern)); 973 } 974 975 public ResultSet getHierarchies( 976 String catalog, 977 String schemaPattern, 978 String cubeNamePattern, 979 String dimensionNamePattern, 980 String hierarchyNamePattern) 981 throws OlapException 982 { 983 return getMetadata( 984 "MDSCHEMA_HIERARCHIES", 985 "CATALOG_NAME", catalog, 986 "SCHEMA_NAME", wildcard(schemaPattern), 987 "CUBE_NAME", wildcard(cubeNamePattern), 988 "DIMENSION_NAME", wildcard(dimensionNamePattern), 989 "HIERARCHY_NAME", wildcard(hierarchyNamePattern)); 990 } 991 992 public ResultSet getMeasures( 993 String catalog, 994 String schemaPattern, 995 String cubeNamePattern, 996 String measureNamePattern, 997 String measureUniqueName) throws OlapException 998 { 999 return getMetadata( 1000 "MDSCHEMA_MEASURES", 1001 "CATALOG_NAME", catalog, 1002 "SCHEMA_NAME", wildcard(schemaPattern), 1003 "CUBE_NAME", wildcard(cubeNamePattern), 1004 "MEASURE_NAME", wildcard(measureNamePattern), 1005 "MEASURE_UNIQUE_NAME", measureUniqueName); 1006 } 1007 1008 public ResultSet getMembers( 1009 String catalog, 1010 String schemaPattern, 1011 String cubeNamePattern, 1012 String dimensionUniqueName, 1013 String hierarchyUniqueName, 1014 String levelUniqueName, 1015 String memberUniqueName, 1016 Set<Member.TreeOp> treeOps) throws OlapException 1017 { 1018 String treeOpString; 1019 if (treeOps != null) { 1020 int op = 0; 1021 for (Member.TreeOp treeOp : treeOps) { 1022 op |= treeOp.xmlaOrdinal(); 1023 } 1024 treeOpString = String.valueOf(op); 1025 } else { 1026 treeOpString = null; 1027 } 1028 return getMetadata( 1029 "MDSCHEMA_MEMBERS", 1030 "CATALOG_NAME", catalog, 1031 "SCHEMA_NAME", wildcard(schemaPattern), 1032 "CUBE_NAME", wildcard(cubeNamePattern), 1033 "DIMENSION_UNIQUE_NAME", dimensionUniqueName, 1034 "HIERARCHY_UNIQUE_NAME", hierarchyUniqueName, 1035 "LEVEL_UNIQUE_NAME", levelUniqueName, 1036 "MEMBER_UNIQUE_NAME", memberUniqueName, 1037 "TREE_OP", treeOpString); 1038 } 1039 1040 public ResultSet getLevels( 1041 String catalog, 1042 String schemaPattern, 1043 String cubeNamePattern, 1044 String dimensionUniqueName, 1045 String hierarchyUniqueName, 1046 String levelNamePattern) throws OlapException 1047 { 1048 return getMetadata( 1049 "MDSCHEMA_LEVELS", 1050 "CATALOG_NAME", catalog, 1051 "SCHEMA_NAME", wildcard(schemaPattern), 1052 "CUBE_NAME", wildcard(cubeNamePattern), 1053 "DIMENSION_UNIQUE_NAME", dimensionUniqueName, 1054 "HIERARCHY_UNIQUE_NAME", hierarchyUniqueName, 1055 "LEVEL_NAME", wildcard(levelNamePattern)); 1056 } 1057 1058 public ResultSet getSets( 1059 String catalog, 1060 String schemaPattern, 1061 String cubeNamePattern, 1062 String setNamePattern) throws OlapException 1063 { 1064 return getMetadata( 1065 "MDSCHEMA_SETS", 1066 "CATALOG_NAME", catalog, 1067 "SCHEMA_NAME", wildcard(schemaPattern), 1068 "CUBE_NAME", wildcard(cubeNamePattern), 1069 "SET_NAME", wildcard(setNamePattern)); 1070 } 1071 } 1072 1073 // End MondrianOlap4jDatabaseMetaData.java