diff --git a/check/model/emf/src/main/resources/model/org.eclipse.daanse.olap.check.ecore b/check/model/emf/src/main/resources/model/org.eclipse.daanse.olap.check.ecore
index e57210df..3b2e8404 100644
--- a/check/model/emf/src/main/resources/model/org.eclipse.daanse.olap.check.ecore
+++ b/check/model/emf/src/main/resources/model/org.eclipse.daanse.olap.check.ecore
@@ -262,6 +262,8 @@
+
+
@@ -646,8 +648,8 @@
-
-
+
+
@@ -662,8 +664,8 @@
-
-
+
+
diff --git a/check/model/emf/src/main/resources/model/org.eclipse.daanse.olap.check.genmodel b/check/model/emf/src/main/resources/model/org.eclipse.daanse.olap.check.genmodel
index 058bf7e3..7fa27788 100644
--- a/check/model/emf/src/main/resources/model/org.eclipse.daanse.olap.check.genmodel
+++ b/check/model/emf/src/main/resources/model/org.eclipse.daanse.olap.check.genmodel
@@ -268,6 +268,7 @@
+
@@ -558,8 +559,8 @@
-
-
+
+
@@ -572,8 +573,8 @@
-
-
+
+
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/CheckExecutorImpl.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/CheckExecutorImpl.java
index bd28a623..3d7281be 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/CheckExecutorImpl.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/CheckExecutorImpl.java
@@ -13,8 +13,8 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl;
+import java.time.Instant;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.Locale;
@@ -64,7 +64,7 @@ private CheckExecutionResult execute(OlapConnectionCheck connectionCheck, Contex
CheckExecutionResult result = factory.createCheckExecutionResult();
result.setName(connectionCheck.getName());
result.setDescription(connectionCheck.getDescription());
- result.setStartTime(new Date());
+ result.setStartedAt(Instant.now());
result.setSourceConnectionCheck(connectionCheck);
// Create connection from ConnectionConfig
@@ -73,7 +73,7 @@ private CheckExecutionResult execute(OlapConnectionCheck connectionCheck, Contex
connection = createConnection(connectionCheck.getConnectionConfig(), context);
} catch (Exception e) {
// Return failure if connection cannot be created
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setSuccess(false);
result.setFailureCount(1);
@@ -113,8 +113,9 @@ private CheckExecutionResult execute(OlapConnectionCheck connectionCheck, Contex
}
}
- result.setEndTime(new Date());
- result.setTotalExecutionTimeMs(result.getEndTime().getTime() - result.getStartTime().getTime());
+ Instant endedAt = Instant.now();
+ result.setEndedAt(endedAt);
+ result.setTotalExecutionTimeMs(endedAt.toEpochMilli() - result.getStartedAt().toEpochMilli());
result.setSuccessCount(successCount);
result.setFailureCount(failureCount);
result.setSkippedCount(skippedCount);
@@ -146,26 +147,33 @@ private Connection createConnection(ConnectionConfig config, Context> context)
private int countSuccesses(CheckResult result) {
int count = result.getStatus() == CheckStatus.SUCCESS ? 1 : 0;
- if (result instanceof CatalogCheckResult catalogResult) {
- for (CubeCheckResult cubeResult : catalogResult.getCubeResults()) {
- count += countSuccesses(cubeResult);
+ switch (result) {
+ case CatalogCheckResult catalogResult -> {
+ for (CubeCheckResult cubeResult : catalogResult.getCubeResults()) {
+ count += countSuccesses(cubeResult);
+ }
}
- } else if (result instanceof CubeCheckResult cubeResult) {
- for (DimensionCheckResult dimResult : cubeResult.getDimensionResults()) {
- count += countSuccesses(dimResult);
+ case CubeCheckResult cubeResult -> {
+ for (DimensionCheckResult dimResult : cubeResult.getDimensionResults()) {
+ count += countSuccesses(dimResult);
+ }
}
- } else if (result instanceof DimensionCheckResult dimResult) {
- for (HierarchyCheckResult hierResult : dimResult.getHierarchyResults()) {
- count += countSuccesses(hierResult);
+ case DimensionCheckResult dimResult -> {
+ for (HierarchyCheckResult hierResult : dimResult.getHierarchyResults()) {
+ count += countSuccesses(hierResult);
+ }
}
- } else if (result instanceof HierarchyCheckResult hierResult) {
- for (LevelCheckResult levelResult : hierResult.getLevelResults()) {
- count += countSuccesses(levelResult);
+ case HierarchyCheckResult hierResult -> {
+ for (LevelCheckResult levelResult : hierResult.getLevelResults()) {
+ count += countSuccesses(levelResult);
+ }
}
- } else if (result instanceof LevelCheckResult levelResult) {
- for (MemberCheckResult memberResult : levelResult.getMemberResults()) {
- count += countSuccesses(memberResult);
+ case LevelCheckResult levelResult -> {
+ for (MemberCheckResult memberResult : levelResult.getMemberResults()) {
+ count += countSuccesses(memberResult);
+ }
}
+ default -> {}
}
return count;
@@ -174,26 +182,33 @@ private int countSuccesses(CheckResult result) {
private int countFailures(CheckResult result) {
int count = result.getStatus() == CheckStatus.FAILURE ? 1 : 0;
- if (result instanceof CatalogCheckResult catalogResult) {
- for (CubeCheckResult cubeResult : catalogResult.getCubeResults()) {
- count += countFailures(cubeResult);
+ switch (result) {
+ case CatalogCheckResult catalogResult -> {
+ for (CubeCheckResult cubeResult : catalogResult.getCubeResults()) {
+ count += countFailures(cubeResult);
+ }
}
- } else if (result instanceof CubeCheckResult cubeResult) {
- for (DimensionCheckResult dimResult : cubeResult.getDimensionResults()) {
- count += countFailures(dimResult);
+ case CubeCheckResult cubeResult -> {
+ for (DimensionCheckResult dimResult : cubeResult.getDimensionResults()) {
+ count += countFailures(dimResult);
+ }
}
- } else if (result instanceof DimensionCheckResult dimResult) {
- for (HierarchyCheckResult hierResult : dimResult.getHierarchyResults()) {
- count += countFailures(hierResult);
+ case DimensionCheckResult dimResult -> {
+ for (HierarchyCheckResult hierResult : dimResult.getHierarchyResults()) {
+ count += countFailures(hierResult);
+ }
}
- } else if (result instanceof HierarchyCheckResult hierResult) {
- for (LevelCheckResult levelResult : hierResult.getLevelResults()) {
- count += countFailures(levelResult);
+ case HierarchyCheckResult hierResult -> {
+ for (LevelCheckResult levelResult : hierResult.getLevelResults()) {
+ count += countFailures(levelResult);
+ }
}
- } else if (result instanceof LevelCheckResult levelResult) {
- for (MemberCheckResult memberResult : levelResult.getMemberResults()) {
- count += countFailures(memberResult);
+ case LevelCheckResult levelResult -> {
+ for (MemberCheckResult memberResult : levelResult.getMemberResults()) {
+ count += countFailures(memberResult);
+ }
}
+ default -> {}
}
return count;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/CatalogCheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/CatalogCheckExecutor.java
index e80aa22d..cf306ddd 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/CatalogCheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/CatalogCheckExecutor.java
@@ -13,7 +13,7 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl.executors;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -53,13 +53,13 @@ public CatalogCheckExecutor(CatalogCheck check, CatalogReader catalogReader, Con
public CheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
CatalogCheckResult result = factory.createCatalogCheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setCatalogName(check.getCatalogName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -126,7 +126,7 @@ public CheckResult execute() {
// Create a failure message
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/CubeCheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/CubeCheckExecutor.java
index 0cef6894..aeeb28f5 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/CubeCheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/CubeCheckExecutor.java
@@ -14,7 +14,7 @@
package org.eclipse.daanse.olap.check.runtime.impl.executors;
import java.util.Arrays;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -63,13 +63,13 @@ public CubeCheckExecutor(CubeCheck check, List cubes, CatalogReader catalo
public CubeCheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
CubeCheckResult result = factory.createCubeCheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setCubeName(check.getCubeName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -78,7 +78,7 @@ public CubeCheckResult execute() {
if (foundCube.isEmpty()) {
result.setStatus(CheckStatus.FAILURE);
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
}
@@ -181,7 +181,7 @@ public CubeCheckResult execute() {
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DatabaseColumnCheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DatabaseColumnCheckExecutor.java
index 9e83e72d..60612136 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DatabaseColumnCheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DatabaseColumnCheckExecutor.java
@@ -13,7 +13,7 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl.executors;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -45,13 +45,13 @@ public DatabaseColumnCheckExecutor(DatabaseColumnCheck check, List
public DatabaseTableCheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
DatabaseTableCheckResult result = factory.createDatabaseTableCheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setTableName(check.getTableName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -62,7 +62,7 @@ public DatabaseTableCheckResult execute() {
if (foundTable.isEmpty()) {
result.setStatus(CheckStatus.FAILURE);
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
}
@@ -100,7 +100,7 @@ public DatabaseTableCheckResult execute() {
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DimensionCheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DimensionCheckExecutor.java
index 9cff89cc..c33778d0 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DimensionCheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DimensionCheckExecutor.java
@@ -13,7 +13,7 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl.executors;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -56,13 +56,13 @@ public DimensionCheckExecutor(DimensionCheck check, List dimensions,
public DimensionCheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
DimensionCheckResult result = factory.createDimensionCheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setDimensionName(check.getDimensionName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -71,7 +71,7 @@ public DimensionCheckResult execute() {
if (foundDimension.isEmpty()) {
result.setStatus(CheckStatus.FAILURE);
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
}
@@ -110,7 +110,7 @@ public DimensionCheckResult execute() {
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DrillThroughActionCheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DrillThroughActionCheckExecutor.java
index a9447636..f84a7873 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DrillThroughActionCheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/DrillThroughActionCheckExecutor.java
@@ -13,7 +13,7 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl.executors;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -45,13 +45,13 @@ public DrillThroughActionCheckExecutor(DrillThroughActionCheck check, List ext
public DrillThroughActionCheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
DrillThroughActionCheckResult result = factory.createDrillThroughActionCheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setActionName(check.getActionName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -60,7 +60,7 @@ public DrillThroughActionCheckResult execute() {
if (foundAction.isEmpty()) {
result.setStatus(CheckStatus.FAILURE);
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
}
@@ -81,7 +81,7 @@ public DrillThroughActionCheckResult execute() {
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/HierarchyCheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/HierarchyCheckExecutor.java
index 8ddf5fec..e9975017 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/HierarchyCheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/HierarchyCheckExecutor.java
@@ -13,7 +13,7 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl.executors;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -57,13 +57,13 @@ public HierarchyCheckExecutor(HierarchyCheck check, List hierarchies,
public HierarchyCheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
HierarchyCheckResult result = factory.createHierarchyCheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setHierarchyName(check.getHierarchyName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -72,7 +72,7 @@ public HierarchyCheckResult execute() {
if (foundHierarchy.isEmpty()) {
result.setStatus(CheckStatus.FAILURE);
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
}
@@ -111,7 +111,7 @@ public HierarchyCheckResult execute() {
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/KPICheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/KPICheckExecutor.java
index c5b0c045..8b25cffd 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/KPICheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/KPICheckExecutor.java
@@ -13,7 +13,7 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl.executors;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -43,13 +43,13 @@ public KPICheckExecutor(KPICheck check, List extends KPI> kpis, OlapCheckFacto
public KPICheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
KPICheckResult result = factory.createKPICheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setKpiName(check.getKpiName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -58,7 +58,7 @@ public KPICheckResult execute() {
if (foundKpi.isEmpty()) {
result.setStatus(CheckStatus.FAILURE);
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
}
@@ -79,7 +79,7 @@ public KPICheckResult execute() {
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/LevelCheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/LevelCheckExecutor.java
index 50cedede..182eb9b9 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/LevelCheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/LevelCheckExecutor.java
@@ -13,7 +13,7 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl.executors;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -56,13 +56,13 @@ public LevelCheckExecutor(LevelCheck check, List levels, Cube cube, Catal
public LevelCheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
LevelCheckResult result = factory.createLevelCheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setLevelName(check.getLevelName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -71,7 +71,7 @@ public LevelCheckResult execute() {
if (foundLevel.isEmpty()) {
result.setStatus(CheckStatus.FAILURE);
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
}
@@ -110,7 +110,7 @@ public LevelCheckResult execute() {
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/MeasureCheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/MeasureCheckExecutor.java
index 6d24e161..6fa4f3a0 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/MeasureCheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/MeasureCheckExecutor.java
@@ -13,7 +13,7 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl.executors;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -53,13 +53,13 @@ public MeasureCheckExecutor(MeasureCheck check, List measures, Cube cube
public MeasureCheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
MeasureCheckResult result = factory.createMeasureCheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setMeasureName(check.getMeasureName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -68,7 +68,7 @@ public MeasureCheckResult execute() {
if (foundMeasure.isEmpty()) {
result.setStatus(CheckStatus.FAILURE);
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
}
@@ -90,7 +90,7 @@ public MeasureCheckResult execute() {
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/MemberCheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/MemberCheckExecutor.java
index 00fbbb40..fb7543ab 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/MemberCheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/MemberCheckExecutor.java
@@ -13,7 +13,7 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl.executors;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -55,13 +55,13 @@ public MemberCheckExecutor(MemberCheck check, List members, Cube cube, C
public MemberCheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
MemberCheckResult result = factory.createMemberCheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setMemberName(check.getMemberName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -70,7 +70,7 @@ public MemberCheckResult execute() {
if (foundMember.isEmpty()) {
result.setStatus(CheckStatus.FAILURE);
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
}
@@ -106,7 +106,7 @@ public MemberCheckResult execute() {
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
@@ -198,13 +198,13 @@ private Integer getMemberIntAttribute(Member member, MemberAttribute attributeTy
private PropertyCheckResult executePropertyCheck(PropertyCheck propertyCheck, Member member) {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
PropertyCheckResult result = factory.createPropertyCheckResult();
result.setCheckName(propertyCheck.getName());
result.setCheckDescription(propertyCheck.getDescription());
result.setPropertyName(propertyCheck.getPropertyName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(propertyCheck);
try {
@@ -225,7 +225,7 @@ private PropertyCheckResult executePropertyCheck(PropertyCheck propertyCheck, Me
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/NamedSetCheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/NamedSetCheckExecutor.java
index 33658a65..872e722d 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/NamedSetCheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/NamedSetCheckExecutor.java
@@ -13,7 +13,7 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl.executors;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.Optional;
@@ -43,13 +43,13 @@ public NamedSetCheckExecutor(NamedSetCheck check, List extends NamedSet> named
public NamedSetCheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
NamedSetCheckResult result = factory.createNamedSetCheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setNamedSetName(check.getNamedSetName());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -58,7 +58,7 @@ public NamedSetCheckResult execute() {
if (foundNamedSet.isEmpty()) {
result.setStatus(CheckStatus.FAILURE);
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
}
@@ -79,7 +79,7 @@ public NamedSetCheckResult execute() {
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/QueryCheckExecutor.java b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/QueryCheckExecutor.java
index 17925d2c..5788a6ed 100644
--- a/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/QueryCheckExecutor.java
+++ b/check/runtime/src/main/java/org/eclipse/daanse/olap/check/runtime/impl/executors/QueryCheckExecutor.java
@@ -13,7 +13,7 @@
*/
package org.eclipse.daanse.olap.check.runtime.impl.executors;
-import java.util.Date;
+import java.time.Instant;
import org.eclipse.daanse.olap.api.connection.Connection;
import org.eclipse.daanse.olap.api.result.Axis;
@@ -46,14 +46,14 @@ public QueryCheckExecutor(QueryCheck check, Connection connection, OlapCheckFact
public QueryCheckResult execute() {
long startTime = System.currentTimeMillis();
- Date start = new Date();
+ Instant start = Instant.now();
QueryCheckResult result = factory.createQueryCheckResult();
result.setCheckName(check.getName());
result.setCheckDescription(check.getDescription());
result.setQuery(check.getQuery());
result.setQueryLanguage(check.getQueryLanguage());
- result.setStartTime(start);
+ result.setStartedAt(start);
result.setSourceCheck(check);
try {
@@ -63,18 +63,13 @@ public QueryCheckResult execute() {
}
switch (language) {
- case MDX:
- executeMdxQuery(result, startTime);
- break;
- case SQL:
- executeSqlQuery(result, startTime);
- break;
- case DAX:
- executeDaxQuery(result, startTime);
- break;
- default:
- result.setExecutedSuccessfully(false);
- result.setStatus(CheckStatus.FAILURE);
+ case MDX -> executeMdxQuery(result, startTime);
+ case SQL -> executeSqlQuery(result, startTime);
+ case DAX -> executeDaxQuery(result, startTime);
+ default -> {
+ result.setExecutedSuccessfully(false);
+ result.setStatus(CheckStatus.FAILURE);
+ }
}
} catch (Exception e) {
@@ -82,7 +77,7 @@ public QueryCheckResult execute() {
result.setStatus(CheckStatus.FAILURE);
}
- result.setEndTime(new Date());
+ result.setEndedAt(Instant.now());
result.setExecutionTimeMs(System.currentTimeMillis() - startTime);
return result;
diff --git a/common/src/main/java/org/eclipse/daanse/olap/access/RoleImpl.java b/common/src/main/java/org/eclipse/daanse/olap/access/RoleImpl.java
index 19ecd6e7..b0e37b28 100644
--- a/common/src/main/java/org/eclipse/daanse/olap/access/RoleImpl.java
+++ b/common/src/main/java/org/eclipse/daanse/olap/access/RoleImpl.java
@@ -799,21 +799,15 @@ public AccessMember getAccess(NamedSet set) {
@Override
public boolean canAccess(OlapElement olapElement) {
Util.assertPrecondition(olapElement != null, "olapElement != null");
- if (olapElement instanceof Member member) {
- return getAccess(member) != AccessMember.NONE;
- } else if (olapElement instanceof Level level) {
- return getAccess(level) != AccessMember.NONE;
- } else if (olapElement instanceof NamedSet namedSet) {
- return getAccess(namedSet) != AccessMember.NONE;
- } else if (olapElement instanceof Hierarchy hierarchy) {
- return getAccess(hierarchy) != AccessHierarchy.NONE;
- } else if (olapElement instanceof Cube cube) {
- return getAccess(cube) != AccessCube.NONE;
- } else if (olapElement instanceof Dimension dimension) {
- return getAccess(dimension) != AccessDimension.NONE;
- } else {
- return false;
- }
+ return switch (olapElement) {
+ case Member member -> getAccess(member) != AccessMember.NONE;
+ case Level level -> getAccess(level) != AccessMember.NONE;
+ case NamedSet namedSet -> getAccess(namedSet) != AccessMember.NONE;
+ case Hierarchy hierarchy -> getAccess(hierarchy) != AccessHierarchy.NONE;
+ case Cube cube -> getAccess(cube) != AccessCube.NONE;
+ case Dimension dimension -> getAccess(dimension) != AccessDimension.NONE;
+ default -> false;
+ };
}
@Override
@@ -941,7 +935,7 @@ private static class HierarchyAccessImpl implements AllHierarchyAccess
this.access = access;
this.rollupPolicy = rollupPolicy;
this.topLevel = topLevel == null
- ? hierarchy.getLevels().get(0)
+ ? hierarchy.getLevels().getFirst()
: topLevel;
this.bottomLevel = bottomLevel == null
? hierarchy.getLevels().getLast()
diff --git a/common/src/main/java/org/eclipse/daanse/olap/common/DaansePropertiesBase.java b/common/src/main/java/org/eclipse/daanse/olap/common/DaansePropertiesBase.java
index bf6d339a..5380f808 100644
--- a/common/src/main/java/org/eclipse/daanse/olap/common/DaansePropertiesBase.java
+++ b/common/src/main/java/org/eclipse/daanse/olap/common/DaansePropertiesBase.java
@@ -28,9 +28,8 @@
package org.eclipse.daanse.olap.common;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
+import java.nio.file.Files;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
@@ -160,8 +159,8 @@ static class FilePropertySource implements PropertySource {
public InputStream openStream() {
try {
this.lastModified = file.lastModified();
- return new FileInputStream(file);
- } catch (FileNotFoundException e) {
+ return Files.newInputStream(file.toPath());
+ } catch (IOException e) {
throw Util.newInternal(
e,
new StringBuilder("Error while opening properties file '").append(file).append("'").toString());
diff --git a/common/src/main/java/org/eclipse/daanse/olap/impl/IdentifierNode.java b/common/src/main/java/org/eclipse/daanse/olap/impl/IdentifierNode.java
index b00651ad..6bf22de9 100644
--- a/common/src/main/java/org/eclipse/daanse/olap/impl/IdentifierNode.java
+++ b/common/src/main/java/org/eclipse/daanse/olap/impl/IdentifierNode.java
@@ -173,7 +173,7 @@ static void quoteMdxIdentifier(String id, StringBuilder buf) {
static ParseRegion sumSegmentRegions(
final List extends IdentifierSegment> segments)
{
- return ParseRegionImpl.sum(
+ return ParseRegionR.sum(
new AbstractList() {
public ParseRegion get(int index) {
return segments.get(index).getRegion();
diff --git a/common/src/main/java/org/eclipse/daanse/olap/impl/IdentifierParser.java b/common/src/main/java/org/eclipse/daanse/olap/impl/IdentifierParser.java
index f0648c1a..5437e7af 100644
--- a/common/src/main/java/org/eclipse/daanse/olap/impl/IdentifierParser.java
+++ b/common/src/main/java/org/eclipse/daanse/olap/impl/IdentifierParser.java
@@ -421,7 +421,7 @@ public interface Builder {
* segment, or continuation of a key segment
*/
void segmentComplete(
- ParseRegionImpl region,
+ ParseRegionR region,
String name,
Quoting quoting,
IdentifierParser.Builder.Syntax syntax);
@@ -463,7 +463,7 @@ private void flushSubSegments() {
}
public void segmentComplete(
- ParseRegionImpl region,
+ ParseRegionR region,
String name,
Quoting quoting,
Syntax syntax)
diff --git a/common/src/main/java/org/eclipse/daanse/olap/impl/ParseRegionImpl.java b/common/src/main/java/org/eclipse/daanse/olap/impl/ParseRegionR.java
similarity index 53%
rename from common/src/main/java/org/eclipse/daanse/olap/impl/ParseRegionImpl.java
rename to common/src/main/java/org/eclipse/daanse/olap/impl/ParseRegionR.java
index afabb405..f439ecc9 100644
--- a/common/src/main/java/org/eclipse/daanse/olap/impl/ParseRegionImpl.java
+++ b/common/src/main/java/org/eclipse/daanse/olap/impl/ParseRegionR.java
@@ -1,25 +1,5 @@
- /*
- * Licensed to Julian Hyde under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for
- * additional information regarding copyright ownership.
- *
- * Julian Hyde licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * ---- All changes after Fork in 2023 ------------------------
- *
- * Project: Eclipse daanse
- *
- * Copyright (c) 2023 Contributors to the Eclipse Foundation.
+/*
+ * Copyright (c) 2023-2025 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
@@ -27,7 +7,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors after Fork in 2023:
+ * Contributors:
* SmartCity Jena - initial
* Stefan Bischof (bipolis.org) - initial
*/
@@ -58,112 +38,49 @@
* the SELECT token has region [1:1, 1:6].
*
* Regions are immutable.
- *
- * @author jhyde
*/
-public class ParseRegionImpl implements ParseRegion {
- private final int startLine;
- private final int startColumn;
- private final int endLine;
- private final int endColumn;
+public record ParseRegionR(int startLine, int startColumn, int endLine, int endColumn) implements ParseRegion {
/**
- * Creates a ParseRegion.
- *
- * All lines and columns are 1-based and inclusive. For example, the
- * token "select" in "select from [Sales]" has a region [1:1, 1:6].
- *
- * @param startLine Line of the beginning of the region
- * @param startColumn Column of the beginning of the region
- * @param endLine Line of the end of the region
- * @param endColumn Column of the end of the region
+ * Compact constructor with validation.
*/
- public ParseRegionImpl(
- int startLine,
- int startColumn,
- int endLine,
- int endColumn)
- {
+ public ParseRegionR {
assert endLine >= startLine;
assert endLine > startLine || endColumn >= startColumn;
- this.startLine = startLine;
- this.startColumn = startColumn;
- this.endLine = endLine;
- this.endColumn = endColumn;
}
/**
- * Creates a ParseRegion.
- *
- * All lines and columns are 1-based.
+ * Creates a point ParseRegion (same start and end).
*
* @param line Line of the beginning and end of the region
* @param column Column of the beginning and end of the region
+ * @return ParseRegionR representing a point
*/
- public ParseRegionImpl(
- int line,
- int column)
- {
- this(line, column, line, column);
+ public static ParseRegionR of(int line, int column) {
+ return new ParseRegionR(line, column, line, column);
}
- /**
- * Return starting line number (1-based).
- *
- * @return 1-based starting line number
- */
+ // Interface methods - delegate to record accessors
@Override
- public int getStartLine() {
+ public int getStartLine() {
return startLine;
}
- /**
- * Return starting column number (1-based).
- *
- * @return 1-based starting column number
- */
@Override
- public int getStartColumn() {
+ public int getStartColumn() {
return startColumn;
}
- /**
- * Return ending line number (1-based).
- *
- * @return 1-based ending line number
- */
@Override
- public int getEndLine() {
+ public int getEndLine() {
return endLine;
}
- /**
- * Return ending column number (1-based).
- *
- * @return 1-based starting endings column number
- */
@Override
- public int getEndColumn() {
+ public int getEndColumn() {
return endColumn;
}
- /**
- * Returns a string representation of this ParseRegion.
- *
- * Regions are of the form
- * [startLine:startColumn, endLine:endColumn], or
- * [startLine:startColumn] for point regions.
- *
- * @return string representation of this ParseRegion
- */
- public String toString() {
- return "[" + startLine + ":" + startColumn
- + ((isPoint())
- ? ""
- : ", " + endLine + ":" + endColumn)
- + "]";
- }
-
/**
* Returns whether this region has the same start and end point.
*
@@ -173,22 +90,11 @@ public boolean isPoint() {
return endLine == startLine && endColumn == startColumn;
}
- public int hashCode() {
- return startLine ^
- (startColumn << 2) ^
- (endLine << 4) ^
- (endColumn << 8);
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof ParseRegionImpl that) {
- return this.startLine == that.startLine
- && this.startColumn == that.startColumn
- && this.endLine == that.endLine
- && this.endColumn == that.endColumn;
- } else {
- return false;
- }
+ @Override
+ public String toString() {
+ return "[" + startLine + ":" + startColumn
+ + (isPoint() ? "" : ", " + endLine + ":" + endColumn)
+ + "]";
}
/**
@@ -197,8 +103,7 @@ public boolean equals(Object obj) {
* @param nodes Source code regions
* @return region which represents the span of the given regions
*/
- public ParseRegion plus(final ParseTreeNode... nodes)
- {
+ public ParseRegion plus(final ParseTreeNode... nodes) {
return plusAll(
new AbstractList() {
public ParseRegion get(int index) {
@@ -241,8 +146,7 @@ public int size() {
* @param regions Source code regions
* @return region which represents the span of the given regions
*/
- public ParseRegion plus(ParseRegionImpl... regions)
- {
+ public ParseRegion plus(ParseRegionR... regions) {
return plusAll(Arrays.asList(regions));
}
@@ -254,8 +158,7 @@ public ParseRegion plus(ParseRegionImpl... regions)
* @param regions Collection of source code regions
* @return region which represents the span of the given regions
*/
- public ParseRegion plusAll(Iterable regions)
- {
+ public ParseRegion plusAll(Iterable regions) {
return sum(
regions,
getStartLine(),
@@ -271,9 +174,7 @@ public ParseRegion plusAll(Iterable regions)
* @param nodes Collection of parse tree nodes
* @return region which represents the span of the given nodes
*/
- public static ParseRegion sum(
- Iterable nodes)
- {
+ public static ParseRegion sum(Iterable nodes) {
return sum(nodes, Integer.MAX_VALUE, Integer.MAX_VALUE, -1, -1);
}
@@ -308,70 +209,46 @@ private static ParseRegion sum(
endColumn = testColumn;
}
}
- return new ParseRegionImpl(startLine, startColumn, endLine, endColumn);
+ return new ParseRegionR(startLine, startColumn, endLine, endColumn);
}
/**
* Looks for one or two carets in an MDX string, and if present, converts
* them into a parser position.
*
- * Examples:
- *
- *
- * findPos("xxx^yyy") yields {"xxxyyy", position 3, line 1 column 4}
- * findPos("xxxyyy") yields {"xxxyyy", null}
- * findPos("xxx^yy^y") yields {"xxxyyy", position 3, line 4 column 4
- * through line 1 column 6}
- *
- *
* @param code Source code
* @return object containing source code annotated with region
*/
- public static RegionAndSource findPos(String code)
- {
+ public static RegionAndSourceR findPos(String code) {
int firstCaret = code.indexOf('^');
if (firstCaret < 0) {
- return new RegionAndSource(code, null);
+ return new RegionAndSourceR(code, null);
}
int secondCaret = code.indexOf('^', firstCaret + 1);
if (secondCaret < 0) {
String codeSansCaret =
code.substring(0, firstCaret)
+ code.substring(firstCaret + 1);
- int [] start = indexToLineCol(code, firstCaret);
- return new RegionAndSource(
+ int[] start = indexToLineCol(code, firstCaret);
+ return new RegionAndSourceR(
codeSansCaret,
- new ParseRegionImpl(start[0], start[1]));
+ ParseRegionR.of(start[0], start[1]));
} else {
String codeSansCaret =
code.substring(0, firstCaret)
+ code.substring(firstCaret + 1, secondCaret)
+ code.substring(secondCaret + 1);
- int [] start = indexToLineCol(code, firstCaret);
-
- // subtract 1 because first caret pushed the string out
- --secondCaret;
-
- // subtract 1 because the col position needs to be inclusive
- --secondCaret;
- int [] end = indexToLineCol(code, secondCaret);
- return new RegionAndSource(
+ int[] start = indexToLineCol(code, firstCaret);
+ secondCaret--;
+ secondCaret--;
+ int[] end = indexToLineCol(code, secondCaret);
+ return new RegionAndSourceR(
codeSansCaret,
- new ParseRegionImpl(start[0], start[1], end[0], end[1]));
+ new ParseRegionR(start[0], start[1], end[0], end[1]));
}
}
- /**
- * Returns the (1-based) line and column corresponding to a particular
- * (0-based) offset in a string.
- *
- * Converse of {@link #lineColToIndex(String, int, int)}.
- *
- * @param code Source code
- * @param i Offset within source code
- * @return 2-element array containing line and column
- */
- private static int [] indexToLineCol(String code, int i) {
+ private static int[] indexToLineCol(String code, int i) {
int line = 0;
int j = 0;
while (true) {
@@ -395,7 +272,7 @@ public static RegionAndSource findPos(String code)
j = n;
}
if ((j < 0) || (j > i)) {
- return new int[] { line + 1, i - prevj + 1 };
+ return new int[]{line + 1, i - prevj + 1};
}
assert s != null;
j += s.length();
@@ -403,28 +280,12 @@ public static RegionAndSource findPos(String code)
}
}
- /**
- * Finds the position (0-based) in a string which corresponds to a given
- * line and column (1-based).
- *
- * Converse of {@link #indexToLineCol(String, int)}.
- *
- * @param code Source code
- * @param line Line number
- * @param column Column number
- * @return Offset within source code
- */
- private static int lineColToIndex(String code, int line, int column)
- {
+ private static int lineColToIndex(String code, int line, int column) {
--line;
--column;
int i = 0;
while (line-- > 0) {
- // Works on linux where line ending is "\n";
- // also works on windows where line ending is "\r\n".
- // Even works if they supply linux strings on windows.
- i = code.indexOf("\n", i)
- + "\n".length();
+ i = code.indexOf("\n", i) + "\n".length();
}
return i + column;
}
@@ -433,10 +294,6 @@ private static int lineColToIndex(String code, int line, int column)
* Generates a string of the source code annotated with caret symbols ("^")
* at the beginning and end of the region.
*
- * For example, for the region (1, 9, 1, 12) and source
- * "values (foo)",
- * yields the string "values (^foo^)".
- *
* @param source Source code
* @return Source code annotated with position
*/
@@ -444,18 +301,6 @@ public String annotate(String source) {
return addCarets(source, startLine, startColumn, endLine, endColumn);
}
- /**
- * Converts a string to a string with one or two carets in it. For example,
- * addCarets("values (foo)", 1, 9, 1, 11) yields "values
- * (^foo^)".
- *
- * @param sql Source code
- * @param line Line number
- * @param col Column number
- * @param endLine Line number of end of region
- * @param endCol Column number of end of region
- * @return String annotated with region
- */
private static String addCarets(
String sql,
int line,
@@ -469,7 +314,7 @@ private static String addCarets(
+ sql.substring(cut);
if ((col != endCol) || (line != endLine)) {
cut = lineColToIndex(sqlWithCarets, endLine, endCol + 1);
- ++cut; // for caret
+ ++cut;
if (cut < sqlWithCarets.length()) {
sqlWithCarets =
sqlWithCarets.substring(0, cut)
@@ -484,35 +329,7 @@ private static String addCarets(
/**
* Combination of a region within an MDX statement with the source text
* of the whole MDX statement.
- *
- * Useful for reporting errors. For example, the error in the statement
- *
- *
- *
- * SELECT {[Measures].[Units In Stock]} ON COLUMNS
- * FROM [Sales]
- *
- *
- *
- * has source
- * "SELECT {[Measures].[Units In Stock]} ON COLUMNS\nFROM [Sales]" and
- * region [1:9, 1:34].
*/
- public static class RegionAndSource {
- public final String source;
- public final ParseRegion region;
-
- /**
- * Creates a RegionAndSource.
- *
- * @param source Source MDX code
- * @param region Coordinates of region within MDX code
- */
- public RegionAndSource(String source, ParseRegion region) {
- this.source = source;
- this.region = region;
- }
+ public record RegionAndSourceR(String source, ParseRegion region) {
}
}
-
-// End ParseRegion.java
diff --git a/common/src/main/java/org/eclipse/daanse/olap/query/component/QueryImpl.java b/common/src/main/java/org/eclipse/daanse/olap/query/component/QueryImpl.java
index 411da4b5..58834e88 100644
--- a/common/src/main/java/org/eclipse/daanse/olap/query/component/QueryImpl.java
+++ b/common/src/main/java/org/eclipse/daanse/olap/query/component/QueryImpl.java
@@ -1215,10 +1215,10 @@ ScopedNamedSet lookupScopedNamedSet(
if (nameParts.size() != 1) {
return null;
}
- if (!(nameParts.get(0) instanceof NameSegment)) {
+ if (!(nameParts.getFirst() instanceof NameSegment)) {
return null;
}
- String name = ((NameSegment) nameParts.get(0)).getName();
+ String name = ((NameSegment) nameParts.getFirst()).getName();
ScopedNamedSet bestScopedNamedSet = null;
int bestScopeOrdinal = -1;
for (ScopedNamedSet scopedNamedSet : scopedNamedSets) {
diff --git a/common/src/main/java/org/eclipse/daanse/olap/util/Format.java b/common/src/main/java/org/eclipse/daanse/olap/util/Format.java
index 696d8f69..2b8bf49f 100644
--- a/common/src/main/java/org/eclipse/daanse/olap/util/Format.java
+++ b/common/src/main/java/org/eclipse/daanse/olap/util/Format.java
@@ -2171,14 +2171,14 @@ public Format(String formatString, FormatLocale locale)
// Later entries in the formats list default to the first (e.g.
// "#.00;;Nil"), but the first entry must be set.
if (alternateFormatList.isEmpty()
- || alternateFormatList.get(0) == null)
+ || alternateFormatList.getFirst() == null)
{
formatValue = new JavaFormat(locale.locale);
} else if (alternateFormatList.size() == 1
&& (formatType[0] == FormatType.DATE
|| formatType[0] == FormatType.STRING))
{
- formatValue = alternateFormatList.get(0);
+ formatValue = alternateFormatList.getFirst();
} else {
BasicFormat[] alternateFormats =
alternateFormatList.toArray(
@@ -2887,7 +2887,7 @@ private String parseFormatString(
alternateFormat = null;
break;
case 1:
- alternateFormat = formatList.get(0);
+ alternateFormat = formatList.getFirst();
break;
default:
alternateFormat =
diff --git a/common/src/main/java/org/eclipse/daanse/olap/util/type/TypeUtil.java b/common/src/main/java/org/eclipse/daanse/olap/util/type/TypeUtil.java
index c0543b0e..d53794ff 100644
--- a/common/src/main/java/org/eclipse/daanse/olap/util/type/TypeUtil.java
+++ b/common/src/main/java/org/eclipse/daanse/olap/util/type/TypeUtil.java
@@ -116,7 +116,7 @@ public static MemberType toMemberType(Type type) {
} else if (type instanceof DimensionType || type instanceof HierarchyType || type instanceof LevelType) {
return MemberType.forType(type);
} else if (type instanceof TupleType tupleType && tupleType.getArity() == 1) {
- return MemberType.forHierarchy(tupleType.getHierarchies().get(0));
+ return MemberType.forHierarchy(tupleType.getHierarchies().getFirst());
} else {
return null;
}
diff --git a/common/test.bndrun b/common/test.bndrun
index c847d180..3e0dfd80 100644
--- a/common/test.bndrun
+++ b/common/test.bndrun
@@ -69,8 +69,8 @@
org.eclipse.daanse.olap.common;version='[0.0.1,0.0.2)',\
org.eclipse.daanse.olap.common-tests;version='[0.0.1,0.0.2)',\
org.eclipse.daanse.sql.guard.api;version='[0.0.1,0.0.2)',\
- org.mockito.junit-jupiter;version='[5.18.0,5.18.1)',\
- org.mockito.mockito-core;version='[5.18.0,5.18.1)',\
+ org.mockito.junit-jupiter;version='[4.9.0,4.9.1)',\
+ org.mockito.mockito-core;version='[4.9.0,4.9.1)',\
org.objenesis;version='[3.3.0,3.3.1)',\
org.opentest4j;version='[1.3.0,1.3.1)',\
org.osgi.service.component;version='[1.5.1,1.5.2)',\
diff --git a/format/src/main/java/org/eclipse/daanse/olap/format/FormatterFactory.java b/format/src/main/java/org/eclipse/daanse/olap/format/FormatterFactory.java
index 9da87768..aa2bd334 100644
--- a/format/src/main/java/org/eclipse/daanse/olap/format/FormatterFactory.java
+++ b/format/src/main/java/org/eclipse/daanse/olap/format/FormatterFactory.java
@@ -85,7 +85,7 @@ public CellFormatter createCellFormatter(FormatterCreateContext context) {
if (context.getFormatterClassName() != null) {
return createFormatter(context.getFormatterClassName());
}
- } catch (Exception e) {
+ } catch (ReflectiveOperationException e) {
throw new OlapRuntimeException(MessageFormat.format(cellFormatterLoadFailed,
context.getFormatterClassName(),
context.getElementName(),
@@ -97,10 +97,10 @@ public CellFormatter createCellFormatter(FormatterCreateContext context) {
/**
* Given the name of a member formatter class
* and/or a member formatter script, returns a member formatter.
- *
+ *
* Returns default formatter implementation
* if empty context is passed.
- *
+ *
*/
public MemberFormatter createRolapMemberFormatter(
FormatterCreateContext context)
@@ -109,7 +109,7 @@ public MemberFormatter createRolapMemberFormatter(
if (context.getFormatterClassName() != null) {
return createFormatter(context.getFormatterClassName());
}
- } catch (Exception e) {
+ } catch (ReflectiveOperationException e) {
throw new OlapRuntimeException(MessageFormat.format(memberFormatterLoadFailed,
context.getFormatterClassName(),
context.getElementName(),
@@ -122,10 +122,10 @@ public MemberFormatter createRolapMemberFormatter(
* Given the name of a property formatter class
* and/or a property formatter script,
* returns a property formatter.
- *
+ *
* Returns default formatter implementation
* if empty context is passed.
- *
+ *
*/
public MemberPropertyFormatter createPropertyFormatter(
FormatterCreateContext context)
@@ -134,7 +134,7 @@ public MemberPropertyFormatter createPropertyFormatter(
if (context.getFormatterClassName() != null) {
return createFormatter(context.getFormatterClassName());
}
- } catch (Exception e) {
+ } catch (ReflectiveOperationException e) {
throw new OlapRuntimeException(MessageFormat.format(propertyFormatterLoadFailed,
context.getFormatterClassName(),
context.getElementName(),
diff --git a/odc/src/main/java/org/eclipse/daanse/olap/odc/simple/impl/AutoOdc.java b/odc/src/main/java/org/eclipse/daanse/olap/odc/simple/impl/AutoOdc.java
index e821e8e3..f73a6951 100644
--- a/odc/src/main/java/org/eclipse/daanse/olap/odc/simple/impl/AutoOdc.java
+++ b/odc/src/main/java/org/eclipse/daanse/olap/odc/simple/impl/AutoOdc.java
@@ -12,6 +12,7 @@
*/
package org.eclipse.daanse.olap.odc.simple.impl;
+import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
@@ -72,7 +73,7 @@ public void bindContext(Context> context) throws Exception {
Files.write(path.resolve("cube_measures_" + cube.getName() + ".odc"), out.getBytes());
}
- } catch (Exception e) {
+ } catch (IOException e) {
e.printStackTrace();
}
diff --git a/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/discover/OtherDiscoverService.java b/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/discover/OtherDiscoverService.java
index 8cf49e2a..8f67c9d6 100644
--- a/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/discover/OtherDiscoverService.java
+++ b/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/discover/OtherDiscoverService.java
@@ -201,7 +201,7 @@ public List discoverEnumerators(DiscoverEnumerat
public List discoverKeywords(DiscoverKeywordsRequest request, RequestMetaData metaData) {
List result = new ArrayList<>();
if (this.contextsListSupplyer.getContexts() != null && !this.contextsListSupplyer.getContexts().isEmpty()) {
- for (String keyword : this.contextsListSupplyer.getContexts().get(0).getKeywordList()) {
+ for (String keyword : this.contextsListSupplyer.getContexts().getFirst().getKeywordList()) {
result.add(new DiscoverKeywordsResponseRowR(keyword));
}
}
diff --git a/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/discover/Utils.java b/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/discover/Utils.java
index a9598936..5514c1ba 100644
--- a/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/discover/Utils.java
+++ b/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/discover/Utils.java
@@ -1546,7 +1546,7 @@ private static List getMdSchemaMeasuresResponseRow(
}
String levelListStr = builder.toString();
//get measure level
- Level measuresLevel = cube.getDimensions().getFirst().getHierarchies().getFirst().getLevels().get(0);
+ Level measuresLevel = cube.getDimensions().getFirst().getHierarchies().getFirst().getLevels().getFirst();
List members = catalogReader.getLevelMembers(measuresLevel, true);
List measures = getMeasureWithFilterByUniqueName(
getMeasureWithFilterByName(members, oMeasureName), oMeasureUniqueName);
diff --git a/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/execute/Convertor.java b/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/execute/Convertor.java
index efee4876..4e27ea5a 100644
--- a/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/execute/Convertor.java
+++ b/xmla/bridge/src/main/java/org/eclipse/daanse/olap/xmla/bridge/execute/Convertor.java
@@ -36,6 +36,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import org.eclipse.daanse.olap.api.NameSegment;
import org.eclipse.daanse.olap.api.Statement;
@@ -116,7 +117,7 @@ public class Convertor {
longProps.put("DisplayInfo", Property.StandardMemberProperty.DISPLAY_INFO);
}
- protected static Map cellPropertyMap = new HashMap<>();
+ protected static Map cellPropertyMap = new HashMap<>();
public static final String CELL_ORDINAL = "CELL_ORDINAL";
@@ -127,14 +128,14 @@ public class Convertor {
public static final String XSD_UNSIGNED_INT = "xsd:unsignedInt";
static {
- cellPropertyMap.put(CELL_ORDINAL, new CellProperty(CELL_ORDINAL, "CellOrdinal", XSD_UNSIGNED_INT));
- cellPropertyMap.put(VALUE, new CellProperty(VALUE, "Value", null));
- cellPropertyMap.put(FORMATTED_VALUE, new CellProperty(FORMATTED_VALUE, "FmtValue", "xsd:string"));
- cellPropertyMap.put("FORMAT_STRING", new CellProperty("FORMAT_STRING", "FormatString", "xsd:string"));
- cellPropertyMap.put("LANGUAGE", new CellProperty("LANGUAGE", "Language", XSD_UNSIGNED_INT));
- cellPropertyMap.put("BACK_COLOR", new CellProperty("BACK_COLOR", "BackColor", XSD_UNSIGNED_INT));
- cellPropertyMap.put("FORE_COLOR", new CellProperty("FORE_COLOR", "ForeColor", XSD_UNSIGNED_INT));
- cellPropertyMap.put("FONT_FLAGS", new CellProperty("FONT_FLAGS", "FontFlags", "xsd:int"));
+ cellPropertyMap.put(CELL_ORDINAL, new CellPropertyR(CELL_ORDINAL, "CellOrdinal", XSD_UNSIGNED_INT));
+ cellPropertyMap.put(VALUE, new CellPropertyR(VALUE, "Value", null));
+ cellPropertyMap.put(FORMATTED_VALUE, new CellPropertyR(FORMATTED_VALUE, "FmtValue", "xsd:string"));
+ cellPropertyMap.put("FORMAT_STRING", new CellPropertyR("FORMAT_STRING", "FormatString", "xsd:string"));
+ cellPropertyMap.put("LANGUAGE", new CellPropertyR("LANGUAGE", "Language", XSD_UNSIGNED_INT));
+ cellPropertyMap.put("BACK_COLOR", new CellPropertyR("BACK_COLOR", "BackColor", XSD_UNSIGNED_INT));
+ cellPropertyMap.put("FORE_COLOR", new CellPropertyR("FORE_COLOR", "ForeColor", XSD_UNSIGNED_INT));
+ cellPropertyMap.put("FONT_FLAGS", new CellPropertyR("FONT_FLAGS", "FontFlags", "xsd:int"));
}
protected static final List defaultProps = List.of(
@@ -159,14 +160,14 @@ private Convertor() {
public static StatementResponse toStatementResponseRowSet(ResultSet rs, int totalCount) throws SQLException {
List rowSetRows = new ArrayList<>();
RowSetR rowSet = new RowSetR(rowSetRows);
- List columns = new ArrayList<>();
+ List columns = new ArrayList<>();
List