rowsetdefinition.java

来自「数据仓库展示程序」· Java 代码 · 共 1,174 行 · 第 1/5 页

JAVA
1,174
字号
                    TableSchema,
                    TableName,
                    TableType,
                }) {
            public Rowset getRowset(HashMap restrictions, Properties properties) {
                return new DbschemaTablesInfoRowset(restrictions, properties);
            }
        };

        public void unparse(SAXHandler saxHandler) throws SAXException {
            //TODO
            throw new UnsupportedOperationException();
        }
    }

    static class MdschemaActionsRowset extends Rowset {
        MdschemaActionsRowset(HashMap restrictions, Properties properties) {
            super(definition, restrictions, properties);
        }

        private static final Column CubeName = new Column("CUBE_NAME", Type.String, null, true, false, null);
        private static final Column Coordinate = new Column("COORDINATE", Type.String, null, true, false, null);
        private static final Column CoordinateType = new Column("COORDINATE_TYPE", Type.String, null, true, false, null);
        public static final RowsetDefinition definition = new RowsetDefinition(
                "MDSCHEMA_ACTIONS", MDSCHEMA_ACTIONS, null, new Column[] {
                    CubeName,
                    Coordinate,
                    CoordinateType,
                }) {
            public Rowset getRowset(HashMap restrictions, Properties properties) {
                return new MdschemaActionsRowset(restrictions, properties);
            }
        };

        public void unparse(SAXHandler saxHandler) throws SAXException {
            //TODO
            throw new UnsupportedOperationException();
        }
    }

    // REF http://msdn.microsoft.com/library/en-us/oledb/htm/olapcubes_rowset.asp
    static class MdschemaCubesRowset extends Rowset {
        MdschemaCubesRowset(HashMap restrictions, Properties properties) {
            super(definition, restrictions, properties);
        }

        private static final String MD_CUBTYPE_CUBE = "CUBE";
        private static final String MD_CUBTYPE_VIRTUAL_CUBE = "VIRTUAL CUBE";
        
        
        private static final Column CatalogName = new Column("CATALOG_NAME", Type.String, null, true, false, null);
        private static final Column SchemaName = new Column("SCHEMA_NAME", Type.String, null, true, true, null);
        private static final Column CubeName = new Column("CUBE_NAME", Type.String, null, true, false, null);
        private static final Column CubeType = new Column("CUBE_TYPE", Type.String, null, true, false, "Cube type.");
        private static final Column IsDrillthroughEnabled = new Column("IS_DRILLTHROUGH_ENABLED", Type.Boolean, null, false, false,
                "Describes whether DRILLTHROUGH can be performed on the members of a cube");
        private static final Column IsWriteEnabled = new Column("IS_WRITE_ENABLED", Type.Boolean, null, false, false,
                "Describes whether a cube is write-enabled");
        private static final Column IsLinkable = new Column("IS_LINKABLE", Type.Boolean, null, false, false,
                "Describes whether a cube can be used in a linked cube");
        private static final Column IsSqlAllowed = new Column("IS_SQL_ALLOWED", Type.Boolean, null, false, false,
                "Describes whether or not SQL can be used on the cube");
        public static final RowsetDefinition definition = new RowsetDefinition(
                "MDSCHEMA_CUBES", MDSCHEMA_CUBES, null, new Column[] {
                    CatalogName,
                    SchemaName,
                    CubeName,
                    CubeType,
                    IsDrillthroughEnabled,
                    IsWriteEnabled,
                    IsLinkable,
                    IsSqlAllowed,
                }) {
            public Rowset getRowset(HashMap restrictions, Properties properties) {
                return new MdschemaCubesRowset(restrictions, properties);
            }
        };

        public void unparse(SAXHandler saxHandler) throws SAXException {
            final Connection connection = XmlaMediator.getConnection(properties);
            final Cube[] cubes = connection.getSchema().getCubes();
            for (int i = 0; i < cubes.length; i++) {
                Cube cube = cubes[i];
                Row row = new Row();
                row.set(CatalogName.name, cube.getSchema().getName());
                row.set(SchemaName.name, cube.getSchema().getName());
                row.set(CubeName.name, cube.getName());
                row.set(CubeType.name, ((RolapCube)cube).isVirtual() ? MD_CUBTYPE_VIRTUAL_CUBE : MD_CUBTYPE_CUBE);
                row.set(IsDrillthroughEnabled.name, true);
                row.set(IsWriteEnabled.name, false);
                row.set(IsLinkable.name, false);
                row.set(IsSqlAllowed.name, false);
                emit(row, saxHandler);
            }
        }
    }

    // REF http://msdn.microsoft.com/library/en-us/oledb/htm/olapdimensions_rowset.asp
    static class MdschemaDimensionsRowset extends Rowset {
        MdschemaDimensionsRowset(HashMap restrictions, Properties properties) {
            super(definition, restrictions, properties);
        }

        public static final int MD_DIMTYPE_OTHER = 3;
        public static final int MD_DIMTYPE_MEASURE = 2;
        public static final int MD_DIMTYPE_TIME = 1;
        
        private static final Column CatalogName = new Column("CATALOG_NAME", Type.String, null, true, false, null);
        private static final Column SchemaName = new Column("SCHEMA_NAME", Type.String, null, true, true, null);
        private static final Column CubeName = new Column("CUBE_NAME", Type.String, null, true, false, null);
        private static final Column DimensionName = new Column("DIMENSION_NAME", Type.String, null, true, false, null);
        private static final Column DimensionUniqueName = new Column("DIMENSION_UNIQUE_NAME", Type.String, null, true, false, null);
        private static final Column DimensionCaption = new Column("DIMENSION_CAPTION", Type.String, null, true, false, null);
        private static final Column DimensionOrdinal = new Column("DIMENSION_ORDINAL", Type.Integer, null, true, false, null);
        private static final Column DimensionType = new Column("DIMENSION_TYPE", Type.Integer, null, true, false, null);
        public static final RowsetDefinition definition = new RowsetDefinition(
                "MDSCHEMA_DIMENSIONS", MDSCHEMA_DIMENSIONS, null, new Column[] {
                    CatalogName,
                    SchemaName,
                    CubeName,
                    DimensionName,
                    DimensionUniqueName,
                    DimensionCaption,
                    DimensionOrdinal,
                    DimensionType,
                }) {
            public Rowset getRowset(HashMap restrictions, Properties properties) {
                return new MdschemaDimensionsRowset(restrictions, properties);
            }
        };

        public void unparse(SAXHandler saxHandler) throws SAXException {
            final Connection connection = XmlaMediator.getConnection(properties);
            final Cube[] cubes = connection.getSchema().getCubes();
            for (int i = 0; i < cubes.length; i++) {
                Cube cube = cubes[i];
                final Dimension[] dimensions = cube.getDimensions();
                for (int j = 0; j < dimensions.length; j++) {
                    Dimension dimension = dimensions[j];
                    Row row = new Row();
                    row.set(CatalogName.name, cube.getSchema().getName());
                    row.set(SchemaName.name, cube.getSchema().getName());
                    row.set(CubeName.name, cube.getName());
                    row.set(DimensionName.name, dimension.getName());
                    row.set(DimensionUniqueName.name, dimension.getUniqueName());
                    row.set(DimensionCaption.name, dimension.getCaption());
                    row.set(DimensionOrdinal.name, dimension.getOrdinal(cube));
                    row.set(DimensionType.name, getDimensionType(dimension));
                    emit(row, saxHandler);
                }
            }
        }
    }

    static int getDimensionType(Dimension dim) {
        if (dim.isMeasures())
            return MdschemaDimensionsRowset.MD_DIMTYPE_MEASURE;
        else if (mondrian.olap.DimensionType.TimeDimension.equals(dim.getDimensionType())) {
            return MdschemaDimensionsRowset.MD_DIMTYPE_TIME;
        } else {
            return MdschemaDimensionsRowset.MD_DIMTYPE_OTHER;
        }
    }
    
    // REF http://msdn.microsoft.com/library/en-us/oledb/htm/olapfunctions_rowset.asp
    static class MdschemaFunctionsRowset extends Rowset {
        MdschemaFunctionsRowset(HashMap restrictions, Properties properties) {
            super(definition, restrictions, properties);
        }
        private static final Column LibraryName = new Column("LIBRARY_NAME", Type.String, null, true, true, null);
        private static final Column InterfaceName = new Column("INTERFACE_NAME", Type.String, null, true, true, null);
        private static final Column FunctionName = new Column("FUNCTION_NAME", Type.String, null, true, true, null);
        private static final Column Origin = new Column("ORIGIN", Type.Integer, null, true, true, null);
        public static final RowsetDefinition definition = new RowsetDefinition(
                "MDSCHEMA_FUNCTIONS", MDSCHEMA_FUNCTIONS, null, new Column[] {
                    LibraryName,
                    InterfaceName,
                    FunctionName,
                    Origin,
                }) {
            public Rowset getRowset(HashMap restrictions, Properties properties) {
                return new MdschemaFunctionsRowset(restrictions, properties);
            }
        };

        public void unparse(SAXHandler saxHandler) throws SAXException {
            //TODO
            throw new UnsupportedOperationException();
        }
    }

    
    // REF http://msdn.microsoft.com/library/en-us/oledb/htm/olaphierarchies_rowset.asp
    static class MdschemaHierarchiesRowset extends Rowset {
        MdschemaHierarchiesRowset(HashMap restrictions, Properties properties) {
            super(definition, restrictions, properties);
        }

        private static final Column CatalogName = new Column("CATALOG_NAME", Type.String, null, true, false, null);
        private static final Column SchemaName = new Column("SCHEMA_NAME", Type.String, null, true, true, null);
        private static final Column CubeName = new Column("CUBE_NAME", Type.String, null, true, false, null);
        private static final Column DimensionUniqueName = new Column("DIMENSION_UNIQUE_NAME", Type.String, null, true, false, null);
        private static final Column HierarchyName = new Column("HIERARCHY_NAME", Type.String, null, true, false, null);
        private static final Column HierarchyUniqueName = new Column("HIERARCHY_UNIQUE_NAME", Type.String, null, true, false, null);
        private static final Column HierarchyCaption = new Column("HIERARCHY_CAPTION", Type.String, null, true, false, null);
        private static final Column DimensionType = new Column("DIMENSION_TYPE", Type.Integer, null, true, false, null);
        private static final Column DefaultMember = new Column("DEFAULT_MEMBER", Type.String, null, true, true, null);
        private static final Column AllMember = new Column("ALL_MEMBER", Type.String, null, true, true, null);
        
        public static final RowsetDefinition definition = new RowsetDefinition(
                "MDSCHEMA_HIERARCHIES", MDSCHEMA_HIERARCHIES, null, new Column[] {
                    CatalogName,
                    SchemaName,
                    CubeName,
                    DimensionUniqueName,
                    HierarchyName,
                    HierarchyUniqueName,
                    HierarchyCaption,
                    DimensionType,
                    DefaultMember,
                    AllMember,
                }) {
            public Rowset getRowset(HashMap restrictions, Properties properties) {
                return new MdschemaHierarchiesRowset(restrictions, properties);
            }
        };

        public void unparse(SAXHandler saxHandler) throws SAXException {
            final Connection connection = XmlaMediator.getConnection(properties);
            final Cube[] cubes = connection.getSchema().getCubes();
            for (int i = 0; i < cubes.length; i++) {
                Cube cube = cubes[i];
                final Dimension[] dimensions = cube.getDimensions();
                for (int j = 0; j < dimensions.length; j++) {
                    Dimension dimension = dimensions[j];

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?