|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Contributors to the Eclipse Foundation. |
| 3 | + * |
| 4 | + * This program and the accompanying materials are made |
| 5 | + * available under the terms of the Eclipse Public License 2.0 |
| 6 | + * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| 7 | + * |
| 8 | + * SPDX-License-Identifier: EPL-2.0 |
| 9 | + * |
| 10 | + * Contributors: |
| 11 | + * |
| 12 | + */ |
| 13 | +package org.eclipse.daanse.rolap.mapping.instance.emf.tutorial.cube.hierarchy.query.join.base; |
| 14 | + |
| 15 | +import org.eclipse.daanse.olap.check.model.check.AggregatorType; |
| 16 | +import org.eclipse.daanse.olap.check.model.check.CatalogCheck; |
| 17 | +import org.eclipse.daanse.olap.check.model.check.CellValueCheck; |
| 18 | +import org.eclipse.daanse.olap.check.model.check.CubeCheck; |
| 19 | +import org.eclipse.daanse.olap.check.model.check.DatabaseColumnAttribute; |
| 20 | +import org.eclipse.daanse.olap.check.model.check.DatabaseColumnAttributeCheck; |
| 21 | +import org.eclipse.daanse.olap.check.model.check.DatabaseColumnCheck; |
| 22 | +import org.eclipse.daanse.olap.check.model.check.DatabaseSchemaCheck; |
| 23 | +import org.eclipse.daanse.olap.check.model.check.DatabaseTableCheck; |
| 24 | +import org.eclipse.daanse.olap.check.model.check.DimensionCheck; |
| 25 | +import org.eclipse.daanse.olap.check.model.check.HierarchyAttribute; |
| 26 | +import org.eclipse.daanse.olap.check.model.check.HierarchyAttributeCheck; |
| 27 | +import org.eclipse.daanse.olap.check.model.check.HierarchyCheck; |
| 28 | +import org.eclipse.daanse.olap.check.model.check.LevelCheck; |
| 29 | +import org.eclipse.daanse.olap.check.model.check.MeasureAttributeCheck; |
| 30 | +import org.eclipse.daanse.olap.check.model.check.MeasureCheck; |
| 31 | +import org.eclipse.daanse.olap.check.model.check.OlapCheckFactory; |
| 32 | +import org.eclipse.daanse.olap.check.model.check.OlapCheckSuite; |
| 33 | +import org.eclipse.daanse.olap.check.model.check.OlapConnectionCheck; |
| 34 | +import org.eclipse.daanse.olap.check.model.check.QueryCheck; |
| 35 | +import org.eclipse.daanse.olap.check.model.check.QueryLanguage; |
| 36 | +import org.eclipse.daanse.olap.check.runtime.api.OlapCheckSuiteSupplier; |
| 37 | +import org.osgi.service.component.annotations.Component; |
| 38 | + |
| 39 | +/** |
| 40 | + * Provides a check suite for the minimal cube mapping. |
| 41 | + * Checks that the catalog, cube, and measure exist and are accessible. |
| 42 | + */ |
| 43 | +@Component(service = OlapCheckSuiteSupplier.class) |
| 44 | +public class CheckSuiteSupplier implements OlapCheckSuiteSupplier { |
| 45 | + |
| 46 | + private static final OlapCheckFactory factory = OlapCheckFactory.eINSTANCE; |
| 47 | + |
| 48 | + @Override |
| 49 | + public OlapCheckSuite get() { |
| 50 | + // Create measure check |
| 51 | + MeasureCheck theMeasureCheck = factory.createMeasureCheck(); |
| 52 | + theMeasureCheck.setName("MeasureCheck-theMeasure"); |
| 53 | + theMeasureCheck.setDescription("Check that measure 'theMeasure' exists"); |
| 54 | + theMeasureCheck.setMeasureName("theMeasure"); |
| 55 | + |
| 56 | + MeasureAttributeCheck measureSumAttributeCheck = factory.createMeasureAttributeCheck(); |
| 57 | + measureSumAttributeCheck.setExpectedAggregator(AggregatorType.SUM); |
| 58 | + |
| 59 | + theMeasureCheck.getMeasureAttributeChecks().add(measureSumAttributeCheck); |
| 60 | + |
| 61 | + // Create Level check |
| 62 | + LevelCheck levelTownCheck = factory.createLevelCheck(); |
| 63 | + levelTownCheck.setName("levelCheck for Town"); |
| 64 | + levelTownCheck.setLevelName("Town"); |
| 65 | + |
| 66 | + LevelCheck levelCountryCheck = factory.createLevelCheck(); |
| 67 | + levelCountryCheck.setName("levelCheck for County"); |
| 68 | + levelCountryCheck.setLevelName("County"); |
| 69 | + |
| 70 | + HierarchyAttributeCheck hierarchyTownHasAllAttributeCheck = factory.createHierarchyAttributeCheck(); |
| 71 | + hierarchyTownHasAllAttributeCheck.setAttributeType(HierarchyAttribute.HAS_ALL); |
| 72 | + hierarchyTownHasAllAttributeCheck.setExpectedBoolean(true); |
| 73 | + |
| 74 | + // Create hierarchy check |
| 75 | + HierarchyCheck hierarchyTownCheck = factory.createHierarchyCheck(); |
| 76 | + hierarchyTownCheck.setName("HierarchyCheck for TownHierarchy"); |
| 77 | + hierarchyTownCheck.setHierarchyName("TownHierarchy"); |
| 78 | + hierarchyTownCheck.getHierarchyAttributeChecks().add(hierarchyTownHasAllAttributeCheck); |
| 79 | + hierarchyTownCheck.getLevelChecks().add(levelTownCheck); |
| 80 | + hierarchyTownCheck.getLevelChecks().add(levelCountryCheck); |
| 81 | + |
| 82 | + |
| 83 | + // Create dimension check |
| 84 | + DimensionCheck dimensionTownCheck = factory.createDimensionCheck(); |
| 85 | + dimensionTownCheck.setName("DimensionCheck for Town"); |
| 86 | + dimensionTownCheck.setDimensionName("Town"); |
| 87 | + dimensionTownCheck.getHierarchyChecks().add(hierarchyTownCheck); |
| 88 | + |
| 89 | + // Create cube check with measure check |
| 90 | + CubeCheck cubeCheck = factory.createCubeCheck(); |
| 91 | + cubeCheck.setName("CubeCheck-Cube Query linked Tables"); |
| 92 | + cubeCheck.setDescription("Check that cube 'Cube Query linked Tables' exists"); |
| 93 | + cubeCheck.setCubeName("Cube Query linked Tables"); |
| 94 | + cubeCheck.getMeasureChecks().add(theMeasureCheck); |
| 95 | + cubeCheck.getDimensionChecks().add(dimensionTownCheck); |
| 96 | + |
| 97 | + CellValueCheck queryCheck1CellValueCheck = factory.createCellValueCheck(); |
| 98 | + queryCheck1CellValueCheck.setName("[Measures].[theMeasure]"); |
| 99 | + queryCheck1CellValueCheck.setExpectedValue("378"); |
| 100 | + |
| 101 | + QueryCheck queryCheck1 = factory.createQueryCheck(); |
| 102 | + queryCheck1.setName("Measure Query Check theMeasure"); |
| 103 | + queryCheck1.setDescription("Verify MDX query returns Measure data for theMeasure"); |
| 104 | + queryCheck1.setQuery("SELECT FROM [Cube Query linked Tables] WHERE ([Measures].[theMeasure])"); |
| 105 | + queryCheck1.setQueryLanguage(QueryLanguage.MDX); |
| 106 | + queryCheck1.setExpectedColumnCount(1); |
| 107 | + queryCheck1.getCellChecks().add(queryCheck1CellValueCheck); |
| 108 | + queryCheck1.setEnabled(true); |
| 109 | + |
| 110 | + DatabaseColumnAttributeCheck columnAttributeCheckFactTownId = factory.createDatabaseColumnAttributeCheck(); |
| 111 | + columnAttributeCheckFactTownId.setAttributeType(DatabaseColumnAttribute.TYPE); |
| 112 | + columnAttributeCheckFactTownId.setExpectedValue("INTEGER"); |
| 113 | + |
| 114 | + DatabaseColumnCheck columnCheckFactTownId = factory.createDatabaseColumnCheck(); |
| 115 | + columnCheckFactTownId.setName("Database Column Check TOWN_ID"); |
| 116 | + columnCheckFactTownId.setColumnName("TOWN_ID"); |
| 117 | + columnCheckFactTownId.getColumnAttributeChecks().add(columnAttributeCheckFactTownId); |
| 118 | + |
| 119 | + DatabaseColumnAttributeCheck columnAttributeCheckFactValue = factory.createDatabaseColumnAttributeCheck(); |
| 120 | + columnAttributeCheckFactValue.setAttributeType(DatabaseColumnAttribute.TYPE); |
| 121 | + columnAttributeCheckFactValue.setExpectedValue("INTEGER"); |
| 122 | + |
| 123 | + DatabaseColumnCheck columnCheckFactValue = factory.createDatabaseColumnCheck(); |
| 124 | + columnCheckFactValue.setName("Database Column Check Value"); |
| 125 | + columnCheckFactValue.setColumnName("VALUE"); |
| 126 | + columnCheckFactValue.getColumnAttributeChecks().add(columnAttributeCheckFactValue); |
| 127 | + |
| 128 | + // Create Database Table Check |
| 129 | + DatabaseTableCheck databaseTableFactCheck = factory.createDatabaseTableCheck(); |
| 130 | + databaseTableFactCheck.setName("Database Table Fact Check"); |
| 131 | + databaseTableFactCheck.setTableName("Fact"); |
| 132 | + databaseTableFactCheck.getColumnChecks().add(columnCheckFactTownId); |
| 133 | + databaseTableFactCheck.getColumnChecks().add(columnCheckFactValue); |
| 134 | + |
| 135 | + |
| 136 | + DatabaseColumnAttributeCheck columnAttributeCheckTownId = factory.createDatabaseColumnAttributeCheck(); |
| 137 | + columnAttributeCheckTownId.setAttributeType(DatabaseColumnAttribute.TYPE); |
| 138 | + columnAttributeCheckTownId.setExpectedValue("INTEGER"); |
| 139 | + |
| 140 | + DatabaseColumnCheck columnCheckTownId = factory.createDatabaseColumnCheck(); |
| 141 | + columnCheckTownId.setName("Database Column Check Town ID"); |
| 142 | + columnCheckTownId.setColumnName("ID"); |
| 143 | + columnCheckTownId.getColumnAttributeChecks().add(columnAttributeCheckTownId); |
| 144 | + |
| 145 | + DatabaseColumnAttributeCheck columnAttributeCheckTownName = factory.createDatabaseColumnAttributeCheck(); |
| 146 | + columnAttributeCheckTownName.setAttributeType(DatabaseColumnAttribute.TYPE); |
| 147 | + columnAttributeCheckTownName.setExpectedValue("VARCHAR"); |
| 148 | + |
| 149 | + DatabaseColumnCheck columnCheckTownName = factory.createDatabaseColumnCheck(); |
| 150 | + columnCheckTownName.setName("Database Column Check Town Name"); |
| 151 | + columnCheckTownName.setColumnName("NAME"); |
| 152 | + columnCheckTownName.getColumnAttributeChecks().add(columnAttributeCheckTownName); |
| 153 | + |
| 154 | + DatabaseColumnAttributeCheck columnAttributeCheckTownCountryId = factory.createDatabaseColumnAttributeCheck(); |
| 155 | + columnAttributeCheckTownCountryId.setAttributeType(DatabaseColumnAttribute.TYPE); |
| 156 | + columnAttributeCheckTownCountryId.setExpectedValue("INTEGER"); |
| 157 | + |
| 158 | + DatabaseColumnCheck columnCheckTownCountryId = factory.createDatabaseColumnCheck(); |
| 159 | + columnCheckTownCountryId.setName("Database Column Check Town Country Id"); |
| 160 | + columnCheckTownCountryId.setColumnName("COUNTRY_ID"); |
| 161 | + columnCheckTownCountryId.getColumnAttributeChecks().add(columnAttributeCheckTownCountryId); |
| 162 | + |
| 163 | + // Create Database Table Town Check |
| 164 | + DatabaseTableCheck databaseTableTownCheck = factory.createDatabaseTableCheck(); |
| 165 | + databaseTableTownCheck.setName("Database Table Town Check"); |
| 166 | + databaseTableTownCheck.setTableName("Town"); |
| 167 | + databaseTableTownCheck.getColumnChecks().add(columnCheckTownId); |
| 168 | + databaseTableTownCheck.getColumnChecks().add(columnCheckTownName); |
| 169 | + databaseTableTownCheck.getColumnChecks().add(columnCheckTownCountryId); |
| 170 | + |
| 171 | + DatabaseColumnAttributeCheck columnAttributeCheckCountryId = factory.createDatabaseColumnAttributeCheck(); |
| 172 | + columnAttributeCheckCountryId.setAttributeType(DatabaseColumnAttribute.TYPE); |
| 173 | + columnAttributeCheckCountryId.setExpectedValue("INTEGER"); |
| 174 | + |
| 175 | + DatabaseColumnCheck columnCheckCountryId = factory.createDatabaseColumnCheck(); |
| 176 | + columnCheckCountryId.setName("Database Column Check Country ID"); |
| 177 | + columnCheckCountryId.setColumnName("ID"); |
| 178 | + columnCheckCountryId.getColumnAttributeChecks().add(columnAttributeCheckCountryId); |
| 179 | + |
| 180 | + DatabaseColumnAttributeCheck columnAttributeCheckCountryName = factory.createDatabaseColumnAttributeCheck(); |
| 181 | + columnAttributeCheckCountryName.setAttributeType(DatabaseColumnAttribute.TYPE); |
| 182 | + columnAttributeCheckCountryName.setExpectedValue("VARCHAR"); |
| 183 | + |
| 184 | + DatabaseColumnCheck columnCheckCountryName = factory.createDatabaseColumnCheck(); |
| 185 | + columnCheckCountryName.setName("Database Column Check Country Name"); |
| 186 | + columnCheckCountryName.setColumnName("NAME"); |
| 187 | + columnCheckCountryName.getColumnAttributeChecks().add(columnAttributeCheckCountryName); |
| 188 | + |
| 189 | + // Create Database Table Check |
| 190 | + DatabaseTableCheck databaseCountryCheck = factory.createDatabaseTableCheck(); |
| 191 | + databaseCountryCheck.setName("Database Table Country Check"); |
| 192 | + databaseCountryCheck.setTableName("Country"); |
| 193 | + databaseCountryCheck.getColumnChecks().add(columnCheckCountryId); |
| 194 | + databaseCountryCheck.getColumnChecks().add(columnCheckCountryName); |
| 195 | + |
| 196 | + // Create Database Schema Check |
| 197 | + DatabaseSchemaCheck databaseSchemaCheck = factory.createDatabaseSchemaCheck(); |
| 198 | + databaseSchemaCheck.setName("Database Schema Check"); |
| 199 | + databaseSchemaCheck.setDescription("Database Schema Check for Daanse Tutorial - Hierarchy Query Join Base"); |
| 200 | + databaseSchemaCheck.getTableChecks().add(databaseTableFactCheck); |
| 201 | + databaseSchemaCheck.getTableChecks().add(databaseCountryCheck); |
| 202 | + databaseSchemaCheck.getTableChecks().add(databaseTableTownCheck); |
| 203 | + |
| 204 | + // Create catalog check with cube check |
| 205 | + CatalogCheck catalogCheck = factory.createCatalogCheck(); |
| 206 | + catalogCheck.setName("Daanse Tutorial - Hierarchy Query Join Base"); |
| 207 | + catalogCheck.setDescription("Check that catalog 'Daanse Tutorial - Hierarchy Query Join Base' exists with its cubes"); |
| 208 | + catalogCheck.setCatalogName("Daanse Tutorial - Hierarchy Query Join Base"); |
| 209 | + catalogCheck.getCubeChecks().add(cubeCheck); |
| 210 | + catalogCheck.getQueryChecks().add(queryCheck1); |
| 211 | + catalogCheck.getDatabaseSchemaChecks().add(databaseSchemaCheck); |
| 212 | + |
| 213 | + // Create connection check (uses default connection) |
| 214 | + OlapConnectionCheck connectionCheck = factory.createOlapConnectionCheck(); |
| 215 | + connectionCheck.setName("Connection Check Daanse Tutorial - Hierarchy Query Join Base"); |
| 216 | + connectionCheck.setDescription("Connection check for Daanse Tutorial - Hierarchy Query Join Base"); |
| 217 | + connectionCheck.getCatalogChecks().add(catalogCheck); |
| 218 | + |
| 219 | + // Create suite containing the connection check |
| 220 | + OlapCheckSuite suite = factory.createOlapCheckSuite(); |
| 221 | + suite.setName("Daanse Tutorial - Hierarchy Query Join Base"); |
| 222 | + suite.setDescription("Check suite for the Daanse Tutorial - Hierarchy Query Join Base"); |
| 223 | + suite.getConnectionChecks().add(connectionCheck); |
| 224 | + |
| 225 | + return suite; |
| 226 | + } |
| 227 | +} |
0 commit comments