Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions mondrian/src/main/java/mondrian/olap/ConnectionBase.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
/*
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2001-2005 Julian Hyde
// Copyright (C) 2005-2017 Hitachi Vantara and others
// All Rights Reserved.
*/
* This software is subject to the terms of the Eclipse Public License v1.0
* Agreement, available at the following URL:
* http://www.eclipse.org/legal/epl-v10.html.
* You must accept the terms of that agreement to use this software.
*
* Copyright (c) 2002-2017 Hitachi Vantara.. All rights reserved.
*
* ---- All changes after Fork in 2023 ------------------------
*
* Project: Eclipse daanse
*
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors after Fork in 2023:
* SmartCity Jena - initial
*/

package mondrian.olap;

Expand All @@ -25,13 +38,12 @@
import org.eclipse.daanse.olap.api.function.FunctionService;
import org.eclipse.daanse.olap.api.query.ExpressionProvider;
import org.eclipse.daanse.olap.api.query.QueryProvider;
import org.eclipse.daanse.olap.api.query.component.Query;
import org.eclipse.daanse.olap.api.query.component.QueryComponent;
import org.eclipse.daanse.olap.query.base.ExpressionProviderImpl;
import org.eclipse.daanse.olap.query.base.QueryProviderImpl;
import org.eclipse.daanse.olap.query.component.QueryImpl;
import org.eclipse.daanse.sql.guard.api.SqlGuard;
import org.eclipse.daanse.sql.guard.api.SqlGuardFactory;
import org.eclipse.daanse.sql.guard.api.elements.DatabaseCatalog;
import org.eclipse.daanse.sql.guard.api.exception.GuardException;
import org.eclipse.daanse.sql.guard.api.exception.UnparsableStatementGuardException;
import org.slf4j.Logger;
Expand Down Expand Up @@ -63,8 +75,8 @@ protected ConnectionBase() {


@Override
public QueryImpl parseQuery(String query) {
return (QueryImpl) parseStatement(query);
public Query parseQuery(String query) {
return (Query) parseStatement(query);
}

/**
Expand Down
39 changes: 27 additions & 12 deletions mondrian/src/main/java/mondrian/olap/IdBatchResolver.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
/*
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2006-2017 Hitachi Vantara and others
// All Rights Reserved.
* This software is subject to the terms of the Eclipse Public License v1.0
* Agreement, available at the following URL:
* http://www.eclipse.org/legal/epl-v10.html.
* You must accept the terms of that agreement to use this software.
*
* Copyright (c) 2002-2017 Hitachi Vantara.. All rights reserved.
*
* ---- All changes after Fork in 2023 ------------------------
*
* Project: Eclipse daanse
*
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors after Fork in 2023:
* SmartCity Jena - initial
*/

package mondrian.olap;

import java.util.ArrayList;
Expand Down Expand Up @@ -34,14 +49,14 @@
import org.eclipse.daanse.olap.api.query.component.DimensionExpression;
import org.eclipse.daanse.olap.api.query.component.Expression;
import org.eclipse.daanse.olap.api.query.component.Formula;
import org.eclipse.daanse.olap.api.query.component.HierarchyExpression;
import org.eclipse.daanse.olap.api.query.component.Id;
import org.eclipse.daanse.olap.api.query.component.MemberExpression;
import org.eclipse.daanse.olap.api.query.component.Query;
import org.eclipse.daanse.olap.api.query.component.QueryAxis;
import org.eclipse.daanse.olap.api.query.component.QueryComponent;
import org.eclipse.daanse.olap.api.query.component.visit.QueryComponentVisitor;
import org.eclipse.daanse.olap.query.component.HierarchyExpressionImpl;
import org.eclipse.daanse.olap.query.component.IdImpl;
import org.eclipse.daanse.olap.query.component.QueryImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -67,7 +82,7 @@
public final class IdBatchResolver {
static final Logger LOGGER = LoggerFactory.getLogger(IdBatchResolver.class);

private final QueryImpl query;
private final Query query;
private final Formula[] formulas;
private final QueryAxis[] axes;
private final Cube cube;
Expand All @@ -87,7 +102,7 @@ public final class IdBatchResolver {
// first on segment length (shortest to longest), then alphabetically.
private SortedSet<Id> identifiers = new TreeSet<>(new IdComparator());

public IdBatchResolver(QueryImpl query) {
public IdBatchResolver(Query query) {
this.query = query;
formulas = query.getFormulas();
axes = query.getAxes();
Expand Down Expand Up @@ -323,7 +338,7 @@ private Member getMemberFromExp(Expression exp) {
if (hier.hasAll()) {
return hier.getAllMember();
}
} else if (exp instanceof HierarchyExpressionImpl hierarchyExpr) {
} else if (exp instanceof HierarchyExpression hierarchyExpr) {
Hierarchy hier = hierarchyExpr
.getHierarchy();
if (hier.hasAll()) {
Expand Down
128 changes: 58 additions & 70 deletions mondrian/src/main/java/mondrian/recorder/AbstractRecorder.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
/*
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// You must accept the terms of that agreement to use this software.
//
// Copyright (C) 2005-2005 Julian Hyde
// Copyright (C) 2005-2017 Hitachi Vantara and others
// All Rights Reserved.
*/
* This software is subject to the terms of the Eclipse Public License v1.0
* Agreement, available at the following URL:
* http://www.eclipse.org/legal/epl-v10.html.
* You must accept the terms of that agreement to use this software.
*
* Copyright (C) 2005-2005 Julian Hyde
* Copyright (c) 2002-2017 Hitachi Vantara.. All rights reserved.
*
* ---- All changes after Fork in 2023 ------------------------
*
* Project: Eclipse daanse
*
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors after Fork in 2023:
* SmartCity Jena - initial
*/

package mondrian.recorder;

Expand All @@ -23,20 +37,14 @@
*/
public abstract class AbstractRecorder implements MessageRecorder {

private final static String tooManyMessageRecorderErrors =
"Context ''{0}'': Exceeded number of allowed errors ''{1,number}''";
private final static String forceMessageRecorderError =
"Context ''{0}'': Client forcing return with errors ''{1,number}''";
private final static String tooManyMessageRecorderErrors = "Context ''{0}'': Exceeded number of allowed errors ''{1,number}''";
private final static String forceMessageRecorderError = "Context ''{0}'': Client forcing return with errors ''{1,number}''";

/**
* Helper method to format a message and write to logger.
*/
public static void logMessage(
final String context,
final String msg,
final MsgType msgType,
final Logger logger)
{
public static void logMessage(final String context, final String msg, final MessageType msgType,
final Logger logger) {
StringBuilder buf = new StringBuilder(64);
buf.append(context);
buf.append(": ");
Expand All @@ -53,15 +61,12 @@ public static void logMessage(
logger.error(logMsg);
break;
default:
logger.warn(
"Unknown message type enum \"{}\" for message: {}", msgType, logMsg);
logger.warn("Unknown message type enum \"{}\" for message: {}", msgType, logMsg);
}
}

enum MsgType {
INFO,
WARN,
ERROR
enum MessageType {
INFO, WARN, ERROR
}

public static final int DEFAULT_MSG_LIMIT = 10;
Expand All @@ -88,7 +93,7 @@ protected AbstractRecorder(final int errorMsgLimit) {
* Resets this MessageRecorder.
*/
@Override
public void clear() {
public void clear() {
errorMsgCount = 0;
warningMsgCount = 0;
infoMsgCount = 0;
Expand All @@ -98,27 +103,27 @@ public void clear() {
}

@Override
public long getStartTimeMillis() {
public long getStartTimeMillis() {
return this.startTime;
}

@Override
public long getRunTimeMillis() {
public long getRunTimeMillis() {
return (System.currentTimeMillis() - this.startTime);
}

@Override
public boolean hasInformation() {
public boolean hasInformation() {
return (infoMsgCount > 0);
}

@Override
public boolean hasWarnings() {
public boolean hasWarnings() {
return (warningMsgCount > 0);
}

@Override
public boolean hasErrors() {
public boolean hasErrors() {
return (errorMsgCount > 0);
}

Expand All @@ -135,7 +140,7 @@ public int getErrorCount() {
}

@Override
public String getContext() {
public String getContext() {
// heavy weight
if (contextMsgCache == null) {
final StringBuilder buf = new StringBuilder();
Expand All @@ -152,100 +157,83 @@ public String getContext() {
}

@Override
public void pushContextName(final String name) {
public void pushContextName(final String name) {
// light weight
contexts.add(name);
contextMsgCache = null;
}

@Override
public void popContextName() {
public void popContextName() {
// light weight
contexts.remove(contexts.size() - 1);
contextMsgCache = null;
}

@Override
public void throwRTException() throws RecorderException {
public void throwRTException() throws RecorderException {
if (hasErrors()) {
final String errorMsg =
MessageFormat.format(forceMessageRecorderError,
getContext(),
errorMsgCount);
final String errorMsg = MessageFormat.format(forceMessageRecorderError, getContext(), errorMsgCount);
throw new RecorderException(errorMsg);
}
}

@Override
public void reportError(final Exception ex)
throws RecorderException
{
public void reportError(final Exception ex) throws RecorderException {
reportError(ex, null);
}

@Override
public void reportError(final Exception ex, final Object info)
throws RecorderException
{
public void reportError(final Exception ex, final Object info) throws RecorderException {
reportError(ex.toString(), info);
}

@Override
public void reportError(final String msg)
throws RecorderException
{
public void reportError(final String msg) throws RecorderException {
reportError(msg, null);
}

@Override
public void reportError(final String msg, final Object info)
throws RecorderException
{
public void reportError(final String msg, final Object info) throws RecorderException {
errorMsgCount++;
recordMessage(msg, info, MsgType.ERROR);
recordMessage(msg, info, MessageType.ERROR);

if (errorMsgCount >= errorMsgLimit) {
final String errorMsg =
MessageFormat.format(tooManyMessageRecorderErrors,
getContext(),
final String errorMsg = MessageFormat.format(tooManyMessageRecorderErrors, getContext(),
String.valueOf(errorMsgCount));
throw new RecorderException(errorMsg);
}
}

@Override
public void reportWarning(final String msg) {
public void reportWarning(final String msg) {
reportWarning(msg, null);
}

@Override
public void reportWarning(final String msg, final Object info) {
public void reportWarning(final String msg, final Object info) {
warningMsgCount++;
recordMessage(msg, info, MsgType.WARN);
recordMessage(msg, info, MessageType.WARN);
}

@Override
public void reportInfo(final String msg) {
public void reportInfo(final String msg) {
reportInfo(msg, null);
}

@Override
public void reportInfo(final String msg, final Object info) {
public void reportInfo(final String msg, final Object info) {
infoMsgCount++;
recordMessage(msg, info, MsgType.INFO);
recordMessage(msg, info, MessageType.INFO);
}

/**
* Handles a message.
* Classes implementing this abstract class must provide an implemention
* of this method; it receives all warning/error messages.
* Handles a message. Classes implementing this abstract class must provide an
* implemention of this method; it receives all warning/error messages.
*
* @param msg the error or warning message.
* @param info the information Object which might be null.
* @param msg the error or warning message.
* @param info the information Object which might be null.
* @param msgType one of the message type enum values
*/
protected abstract void recordMessage(
String msg,
Object info,
MsgType msgType);
protected abstract void recordMessage(String msg, Object info, MessageType msgType);
}
Loading
Loading