rowsetdefinition.java
来自「数据仓库展示程序」· Java 代码 · 共 1,174 行 · 第 1/5 页
JAVA
1,174 行
DataSourceName,
DataSourceDescription,
URL,
DataSourceInfo,
ProviderName,
ProviderType,
AuthenticationMode,
}) {
public Rowset getRowset(HashMap restrictions, Properties properties) {
return new DiscoverDatasourcesRowset(restrictions, properties);
}
};
public DiscoverDatasourcesRowset(HashMap restrictions, Properties properties) {
super(definition, restrictions, properties);
}
public void unparse(SAXHandler saxHandler) throws SAXException {
for (Iterator it = XmlaMediator.dataSourcesMap.values().iterator(); it.hasNext();) {
DataSourcesConfig.DataSource ds = (DataSourcesConfig.DataSource)it.next();
Row row = new Row();
row.set(DataSourceName.name, ds.getDataSourceName());
row.set(DataSourceDescription.name, ds.getDataSourceDescription());
row.set(URL.name, ds.getURL());
row.set(DataSourceInfo.name, ds.getDataSourceName());
row.set(ProviderName.name, ds.getProviderName());
row.set(ProviderType.name, ds.getProviderType());
row.set(AuthenticationMode.name, ds.getAuthenticationMode());
emit(row, saxHandler);
}
}
}
static class DiscoverSchemaRowsetsRowset extends Rowset {
private static final Column SchemaName = new Column("SchemaName", Type.StringArray, null, true, false, "The name of the schema/request. This returns the values in the RequestTypes enumeration, plus any additional types supported by the provider. The provider defines rowset structures for the additional types");
private static final Column Restrictions = new Column("Restrictions", Type.Array,null, false, true, "An array of the restrictions suppoted by provider. An example follows this table.");
private static final Column Description = new Column("Description", Type.String, null, false, true, "A localizable description of the schema");
private static RowsetDefinition definition = new RowsetDefinition(
"DISCOVER_SCHEMA_ROWSETS", DISCOVER_SCHEMA_ROWSETS,
"Returns the names, values, and other information of all supported RequestType enumeration values.",
new Column[] {
SchemaName,
Restrictions,
Description,
}) {
public Rowset getRowset(HashMap restrictions, Properties properties) {
return new DiscoverSchemaRowsetsRowset(restrictions, properties);
}
};
public DiscoverSchemaRowsetsRowset(HashMap restrictions, Properties properties) {
super(definition, restrictions, properties);
}
public void unparse(SAXHandler saxHandler) throws SAXException {
final RowsetDefinition[] rowsetDefinitions = (RowsetDefinition[])
enumeration.getValuesSortedByName().
toArray(new RowsetDefinition[0]);
for (int i = 0; i < rowsetDefinitions.length; i++) {
RowsetDefinition rowsetDefinition = rowsetDefinitions[i];
Row row = new Row();
row.set(SchemaName.name, rowsetDefinition.name);
row.set(Restrictions.name, getRestrictions(rowsetDefinition));
row.set(Description.name, rowsetDefinition.description);
emit(row, saxHandler);
}
}
private Rowset.XmlElement[] getRestrictions(RowsetDefinition rowsetDefinition) {
ArrayList restrictionList = new ArrayList();
final Column[] columns = rowsetDefinition.columnDefinitions;
for (int j = 0; j < columns.length; j++) {
Column column = columns[j];
if (column.restriction) {
restrictionList.add(
new Rowset.XmlElement(Restrictions.name, null, new Rowset.XmlElement[] {
new Rowset.XmlElement("Name", null, column.name),
new Rowset.XmlElement("Type", null, column.getColumnType())
}));
}
}
final Rowset.XmlElement[] restrictions = (Rowset.XmlElement[])
restrictionList.toArray(
new Rowset.XmlElement[restrictionList.size()]);
return restrictions;
}
}
static class DiscoverPropertiesRowset extends Rowset {
DiscoverPropertiesRowset(HashMap restrictions, Properties properties) {
super(definition, restrictions, properties);
}
private static final Column PropertyName = new Column("PropertyName", Type.StringSometimesArray, null, true, false,
"The name of the property.");
private static final Column PropertyDescription = new Column("PropertyDescription", Type.String, null, false, true,
"A localizable text description of the property.");
private static final Column PropertyType = new Column("PropertyType", Type.String, null, false, true,
"The XML data type of the property.");
private static final Column PropertyAccessType = new Column("PropertyAccessType", Type.EnumString, Enumeration.Access.enumeration, false, false,
"Access for the property. The value can be Read, Write, or ReadWrite.");
private static final Column IsRequired = new Column("IsRequired", Type.Boolean, null, false, true,
"True if a property is required, false if it is not required.");
private static final Column Value = new Column("Value", Type.String, null, false, true,
"The current value of the property.");
public static final RowsetDefinition definition = new RowsetDefinition(
"DISCOVER_PROPERTIES", DISCOVER_PROPERTIES,
"Returns a list of information and values about the requested properties that are supported by the specified data source provider.",
new Column[] {
PropertyName,
PropertyDescription,
PropertyType,
PropertyAccessType,
IsRequired,
Value,
}) {
public Rowset getRowset(HashMap restrictions, Properties properties) {
return new DiscoverPropertiesRowset(restrictions, properties);
}
};
public void unparse(SAXHandler saxHandler) throws SAXException {
final String[] propertyNames = PropertyDefinition.enumeration.getNames();
for (int i = 0; i < propertyNames.length; i++) {
PropertyDefinition propertyDefinition = PropertyDefinition.getValue(propertyNames[i]);
Row row = new Row();
row.set(PropertyName.name, propertyDefinition.name);
row.set(PropertyDescription.name, propertyDefinition.description);
row.set(PropertyType.name, propertyDefinition.type);
row.set(PropertyAccessType.name, propertyDefinition.access);
//row.set(IsRequired.name, false);
//row.set(Value.name, null);
emit(row, saxHandler);
}
}
}
static class DiscoverEnumeratorsRowset extends Rowset {
DiscoverEnumeratorsRowset(HashMap restrictions, Properties properties) {
super(definition, restrictions, properties);
}
private static final Column EnumName = new Column("EnumName", Type.StringArray, null, true, false,
"The name of the enumerator that contains a set of values.");
private static final Column EnumDescription = new Column("EnumDescription", Type.String, null, false, true,
"A localizable description of the enumerator.");
private static final Column EnumType = new Column("EnumType", Type.String, null, false, false,
"The data type of the Enum values.");
private static final Column ElementName = new Column("ElementName", Type.String, null, false, false,
"The name of one of the value elements in the enumerator set." + nl +
"Example: TDP");
private static final Column ElementDescription = new Column("ElementDescription", Type.String, null, false, true,
"A localizable description of the element (optional).");
private static final Column ElementValue = new Column("ElementValue", Type.String, null, false, true, "The value of the element." + nl +
"Example: 01");
public static final RowsetDefinition definition = new RowsetDefinition(
"DISCOVER_ENUMERATORS", DISCOVER_ENUMERATORS,
"Returns a list of names, data types, and enumeration values for enumerators supported by the provider of a specific data source.",
new Column[] {
EnumName,
EnumDescription,
EnumType,
ElementName,
ElementDescription,
ElementValue,
}) {
public Rowset getRowset(HashMap restrictions, Properties properties) {
return new DiscoverEnumeratorsRowset(restrictions, properties);
}
};
public void unparse(SAXHandler saxHandler) throws SAXException {
Enumeration[] enumerators = getEnumerators();
for (int i = 0; i < enumerators.length; i++) {
Enumeration enumerator = enumerators[i];
final String[] valueNames = enumerator.getNames();
for (int j = 0; j < valueNames.length; j++) {
String valueName = valueNames[j];
final EnumeratedValues.Value value = enumerator.getValue(valueName, true);
Row row = new Row();
row.set(EnumName.name, enumerator.name);
row.set(EnumDescription.name, enumerator.description);
row.set(EnumType.name, enumerator.type);
row.set(ElementName.name, value.getName());
row.set(ElementDescription.name, value.getDescription());
switch (enumerator.type.ordinal) {
case RowsetDefinition.Type.String_ORDINAL:
case RowsetDefinition.Type.StringArray_ORDINAL:
// these don't have ordinals
break;
default:
row.set(ElementValue.name, value.getOrdinal());
break;
}
emit(row, saxHandler);
}
}
}
private static Enumeration[] getEnumerators() {
HashSet enumeratorSet = new HashSet();
final String[] rowsetNames = RowsetDefinition.enumeration.getNames();
for (int i = 0; i < rowsetNames.length; i++) {
String rowsetName = rowsetNames[i];
final RowsetDefinition rowsetDefinition = (RowsetDefinition)
RowsetDefinition.enumeration.getValue(rowsetName, true);
for (int j = 0; j < rowsetDefinition.columnDefinitions.length; j++) {
Column column = rowsetDefinition.columnDefinitions[j];
if (column.enumeration != null) {
enumeratorSet.add(column.enumeration);
}
}
}
final Enumeration[] enumerators = (Enumeration[])
enumeratorSet.toArray(new Enumeration[enumeratorSet.size()]);
Arrays.sort(enumerators, new Comparator() {
public int compare(Object o1, Object o2) {
return ((Enumeration) o1).name.compareTo(
((Enumeration) o2).name);
}
});
return enumerators;
}
}
static class DiscoverKeywordsRowset extends Rowset {
DiscoverKeywordsRowset(HashMap restrictions, Properties properties) {
super(definition, restrictions, properties);
}
private static final Column Keyword = new Column("Keyword", Type.StringSometimesArray, null, true, false,
"A list of all the keywords reserved by a provider." + nl +
"Example: AND");
public static final RowsetDefinition definition = new RowsetDefinition(
"DISCOVER_KEYWORDS", DISCOVER_KEYWORDS,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?