rowsetdefinition.java
来自「数据仓库展示程序」· Java 代码 · 共 1,174 行 · 第 1/5 页
JAVA
1,174 行
package mondrian.xmla;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import mondrian.olap.*;
import mondrian.rolap.RolapCube;
import mondrian.util.SAXHandler;
import org.xml.sax.SAXException;
/**
* <code>RowsetDefinition</code> defines a rowset, including the columns it
* should contain.
*
* <p>See "XML for Analysis Rowsets", page 38 of the XML for Analysis
* Specification, version 1.1.
*/
abstract class RowsetDefinition extends EnumeratedValues.BasicValue {
final Column[] columnDefinitions;
private static final String nl = Util.nl;
/** Returns a list of XML for Analysis data sources
* available on the server or Web Service. (For an
* example of how these may be published, see
* "XML for Analysis Implementation Walkthrough"
* in the XML for Analysis specification.) */
public static final int DISCOVER_DATASOURCES = 0;
public static final int DISCOVER_PROPERTIES = 1;
public static final int DISCOVER_SCHEMA_ROWSETS = 2;
public static final int DISCOVER_ENUMERATORS = 3;
public static final int DISCOVER_KEYWORDS = 4;
public static final int DISCOVER_LITERALS = 5;
public static final int DBSCHEMA_CATALOGS = 6;
public static final int DBSCHEMA_COLUMNS = 7;
public static final int DBSCHEMA_PROVIDER_TYPES = 8;
public static final int DBSCHEMA_TABLES = 9;
public static final int DBSCHEMA_TABLES_INFO = 10;
public static final int MDSCHEMA_ACTIONS = 11;
public static final int MDSCHEMA_CUBES = 12;
public static final int MDSCHEMA_DIMENSIONS = 13;
public static final int MDSCHEMA_FUNCTIONS = 14;
public static final int MDSCHEMA_HIERARCHIES = 15;
public static final int MDSCHEMA_LEVELS = 16;
public static final int MDSCHEMA_MEASURES = 17;
public static final int MDSCHEMA_MEMBERS = 18;
public static final int MDSCHEMA_PROPERTIES = 19;
public static final int MDSCHEMA_SETS = 20;
public static final int OTHER = 21;
public static final EnumeratedValues enumeration = new EnumeratedValues(
new RowsetDefinition[] {
DiscoverDatasourcesRowset.definition,
DiscoverEnumeratorsRowset.definition,
DiscoverPropertiesRowset.definition,
DiscoverSchemaRowsetsRowset.definition,
DiscoverKeywordsRowset.definition,
DiscoverLiteralsRowset.definition,
DbschemaCatalogsRowset.definition,
DbschemaColumnsRowset.definition,
DbschemaProviderTypesRowset.definition,
DbschemaTablesRowset.definition,
DbschemaTablesInfoRowset.definition,
MdschemaActionsRowset.definition,
MdschemaCubesRowset.definition,
MdschemaDimensionsRowset.definition,
MdschemaFunctionsRowset.definition,
MdschemaHierarchiesRowset.definition,
MdschemaLevelsRowset.definition,
MdschemaMeasuresRowset.definition,
MdschemaMembersRowset.definition,
MdschemaPropertiesRowset.definition,
MdschemaSetsRowset.definition,
}
);
RowsetDefinition(String name, int ordinal, String description, Column[] columnDefinitions) {
super(name, ordinal, description);
this.columnDefinitions = columnDefinitions;
}
public static RowsetDefinition getValue(String name) {
return (RowsetDefinition) enumeration.getValue(name, true);
}
public abstract Rowset getRowset(HashMap restrictions, Properties properties);
public Column lookupColumn(String name) {
for (int i = 0; i < columnDefinitions.length; i++) {
Column columnDefinition = columnDefinitions[i];
if (columnDefinition.name.equals(name)) {
return columnDefinition;
}
}
return null;
}
static class Type extends EnumeratedValues.BasicValue {
public static final int String_ORDINAL = 0;
public static final Type String = new Type("string", String_ORDINAL, "string");
public static final int StringArray_ORDINAL = 1;
public static final Type StringArray = new Type("StringArray", StringArray_ORDINAL, "string");
public static final int Array_ORDINAL = 2;
public static final Type Array = new Type("Array", Array_ORDINAL, "string");
public static final int Enumeration_ORDINAL = 3;
public static final Type Enumeration = new Type("Enumeration", Enumeration_ORDINAL, "string");
public static final int EnumerationArray_ORDINAL = 4;
public static final Type EnumerationArray = new Type("EnumerationArray", EnumerationArray_ORDINAL, "string");
public static final int EnumString_ORDINAL = 5;
public static final Type EnumString = new Type("EnumString", EnumString_ORDINAL, "string");
public static final int Boolean_ORDINAL = 6;
public static final Type Boolean = new Type("Boolean", Boolean_ORDINAL, "boolean");
public static final int StringSometimesArray_ORDINAL = 7;
public static final Type StringSometimesArray = new Type("StringSometimesArray", StringSometimesArray_ORDINAL, "string");
public static final int Integer_ORDINAL = 8;
public static final Type Integer = new Type("Integer", Integer_ORDINAL, "integer");
public static final int UnsignedInteger_ORDINAL = 9;
public static final Type UnsignedInteger = new Type("UnsignedInteger", UnsignedInteger_ORDINAL, "unsignedInteger");
public final String columnType;
public Type(String name, int ordinal, String columnType) {
super(name, ordinal, null);
this.columnType = columnType;
}
public static final EnumeratedValues enumeration = new EnumeratedValues(
new Type[] {
String, StringArray, Array, Enumeration, EnumerationArray, EnumString,
});
boolean isEnum() {
switch (ordinal) {
case Enumeration_ORDINAL:
case EnumerationArray_ORDINAL:
case EnumString_ORDINAL:
return true;
}
return false;
}
}
static class Column {
final String name;
final Type type;
final Enumeration enumeration;
final String description;
final boolean restriction;
final boolean nullable;
/**
* Creates a column.
* @param name
* @param type A {@link Type} value
* @param enumeratedType Must be specified for enumeration or array
* of enumerations
* @param description
* @param restriction
* @param nullable
* @pre type != null
* @pre (type == Type.Enumeration || type == Type.EnumerationArray || type == Type.EnumString) == (enumeratedType != null)
*/
Column(String name, Type type, Enumeration enumeratedType,
boolean restriction, boolean nullable, String description) {
Util.assertPrecondition(type != null, "Type.instance.isValid(type)");
Util.assertPrecondition((type == Type.Enumeration || type == Type.EnumerationArray || type == Type.EnumString) == (enumeratedType != null), "(type == Type.Enumeration || type == Type.EnumerationArray || type == Type.EnumString) == (enumeratedType != null)");
this.name = name;
this.type = type;
this.enumeration = enumeratedType;
this.description = description;
this.restriction = restriction;
this.nullable = nullable;
}
/**
* Retrieves a value of this column from a row. The base implementation
* uses reflection; a derived class may provide a different
* implementation.
*/
Object get(Object row) {
try {
String javaFieldName = name.substring(0, 1).toLowerCase() + name.substring(1);
Field field = row.getClass().getField(javaFieldName);
return field.get(row);
} catch (NoSuchFieldException e) {
throw Util.newInternal(e, "Error while accessing rowset column " + name);
} catch (SecurityException e) {
throw Util.newInternal(e, "Error while accessing rowset column " + name);
} catch (IllegalAccessException e) {
throw Util.newInternal(e, "Error while accessing rowset column " + name);
}
}
public String getColumnType() {
if (type.isEnum()) {
return enumeration.type.columnType;
}
return type.columnType;
}
}
// -------------------------------------------------------------------------
// From this point on, just rowset classess.
static class DiscoverDatasourcesRowset extends Rowset {
private static final Column DataSourceName = new Column("DataSourceName", Type.String, null, true, false,
"The name of the data source, such as FoodMart 2000.");
private static final Column DataSourceDescription = new Column("DataSourceDescription", Type.String, null, false, true,
"A description of the data source, as entered by the publisher.");
private static final Column URL = new Column("URL", Type.String, null, true, true,
"The unique path that shows where to invoke the XML for Analysis methods for that data source.");
private static final Column DataSourceInfo = new Column("DataSourceInfo", Type.String, null, false, true,
"A string containing any additional information required to connect to the data source. This can include the Initial Catalog property or other information for the provider." + nl +
"Example: \"Provider=MSOLAP;Data Source=Local;\"");
private static final Column ProviderName = new Column("ProviderName", Type.String, null, true, true,
"The name of the provider behind the data source. " + nl +
"Example: \"MSDASQL\"");
private static final Column ProviderType = new Column("ProviderType", Type.EnumerationArray, Enumeration.ProviderType.enumeration, true, false,
"The types of data supported by the provider. May include one or more of the following types. Example follows this table." + nl +
"TDP: tabular data provider." + nl +
"MDP: multidimensional data provider." + nl +
"DMP: data mining provider. A DMP provider implements the OLE DB for Data Mining specification.");
private static final Column AuthenticationMode = new Column("AuthenticationMode", Type.EnumString, Enumeration.AuthenticationMode.enumeration, true, false,
"Specification of what type of security mode the data source uses. Values can be one of the following:" + nl +
"Unauthenticated: no user ID or password needs to be sent." + nl +
"Authenticated: User ID and Password must be included in the information required for the connection." + nl +
"Integrated: the data source uses the underlying security to determine authorization, such as Integrated Security provided by Microsoft Internet Information Services (IIS).");
static final RowsetDefinition definition = new RowsetDefinition(
"DISCOVER_DATASOURCES", DISCOVER_DATASOURCES,
"Returns a list of XML for Analysis data sources available on the server or Web Service.",
new Column[] {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?