Commit 48569a6b authored by gmantele's avatar gmantele
Browse files

[ADQL] Rename UnresolvedJoin and UnresolvedFunction so that normalizing all...

[ADQL] Rename UnresolvedJoin and UnresolvedFunction so that normalizing all UnresolvedXxx exceptions.
parent 8b182b3f
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ package adql.db;
 * You should have received a copy of the GNU Lesser General Public License
 * along with ADQLLibrary.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2011,2013-2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 * Copyright 2011,2013-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 *                            Astronomisches Rechen Institut (ARI)
 */

@@ -34,7 +34,7 @@ import adql.db.STCS.CoordSys;
import adql.db.STCS.Region;
import adql.db.STCS.RegionType;
import adql.db.exception.UnresolvedColumnException;
import adql.db.exception.UnresolvedFunction;
import adql.db.exception.UnresolvedFunctionException;
import adql.db.exception.UnresolvedIdentifiersException;
import adql.db.exception.UnresolvedTableException;
import adql.parser.ParseException;
@@ -97,7 +97,7 @@ import adql.search.SimpleSearchHandler;
 * </i></p>
 * 
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 1.3 (10/2014)
 * @version 1.3 (05/2015)
 */
public class DBChecker implements QueryChecker {

@@ -790,7 +790,7 @@ public class DBChecker implements QueryChecker {
		// If no UDF are allowed, throw immediately an error:
		if (allowedUdfs.length == 0){
			for(ADQLObject result : sHandler)
				errors.addException(new UnresolvedFunction((UserDefinedFunction)result));
				errors.addException(new UnresolvedFunctionException((UserDefinedFunction)result));
		}
		// 2. Try to resolve all of them:
		else{
@@ -816,7 +816,7 @@ public class DBChecker implements QueryChecker {
				if (match < 0){
					// ...if the type of all parameters is resolved, add an error (no match is possible):
					if (isAllParamTypesResolved(udf))
						errors.addException(new UnresolvedFunction(udf));	// TODO Add the ADQLOperand position!
						errors.addException(new UnresolvedFunctionException(udf));	// TODO Add the ADQLOperand position!
					// ...otherwise, try to resolved it later (when other UDFs will be mostly resolved):
					else
						toResolveLater.add(udf);
@@ -833,7 +833,7 @@ public class DBChecker implements QueryChecker {
				match = binSearch.search(udf, allowedUdfs);
				// if no match, add an error:
				if (match < 0)
					errors.addException(new UnresolvedFunction(udf));	// TODO Add the ADQLOperand position!
					errors.addException(new UnresolvedFunctionException(udf));	// TODO Add the ADQLOperand position!
				// otherwise, metadata may be attached (particularly if the function is built automatically by the syntactic parser):
				else if (udf instanceof DefaultUDF)
					((DefaultUDF)udf).setDefinition(allowedUdfs[match]);
@@ -958,7 +958,7 @@ public class DBChecker implements QueryChecker {
		if (allowedGeo.length != 0)
			match = binSearch.search(fctName, allowedGeo);
		if (match < 0)
			errors.addException(new UnresolvedFunction("The geometrical function \"" + fctName + "\" is not available in this implementation!", fct));
			errors.addException(new UnresolvedFunctionException("The geometrical function \"" + fctName + "\" is not available in this implementation!", fct));
	}

	/**
@@ -1093,7 +1093,7 @@ public class DBChecker implements QueryChecker {
		// Check that the region type is allowed:
		if (allowedGeo != null){
			if (allowedGeo.length == 0)
				errors.addException(new UnresolvedFunction("The region type \"" + r.type + "\" is not available in this implementation!", fct));
				errors.addException(new UnresolvedFunctionException("The region type \"" + r.type + "\" is not available in this implementation!", fct));
			else
				checkGeometryFunction((r.type == RegionType.POSITION) ? "POINT" : r.type.toString(), fct, binSearch, errors);
		}
@@ -1350,7 +1350,7 @@ public class DBChecker implements QueryChecker {
			}catch(Exception ex){
				// IF NO INSTANCE CAN BE CREATED...
				// ...keep the error for further report:
				errors.addException(new UnresolvedFunction("Impossible to represent the function \"" + ((DefaultUDF)objToReplace).getName() + "\": the following error occured while creating this representation: \"" + ((ex instanceof InvocationTargetException) ? "[" + ex.getCause().getClass().getSimpleName() + "] " + ex.getCause().getMessage() : ex.getMessage()) + "\"", (DefaultUDF)objToReplace));
				errors.addException(new UnresolvedFunctionException("Impossible to represent the function \"" + ((DefaultUDF)objToReplace).getName() + "\": the following error occured while creating this representation: \"" + ((ex instanceof InvocationTargetException) ? "[" + ex.getCause().getClass().getSimpleName() + "] " + ex.getCause().getMessage() : ex.getMessage()) + "\"", (DefaultUDF)objToReplace));
				// ...keep the same object (i.e. no replacement):
				return objToReplace;
			}
+6 −6
Original line number Diff line number Diff line
@@ -16,13 +16,13 @@ package adql.db;
 * You should have received a copy of the GNU Lesser General Public License
 * along with ADQLLibrary.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2014 - Astronomisches Rechen Institut (ARI)
 * Copyright 2014-2015 - Astronomisches Rechen Institut (ARI)
 */

import java.util.ArrayList;
import java.util.Iterator;

import adql.db.exception.UnresolvedJoin;
import adql.db.exception.UnresolvedJoinException;
import adql.query.ADQLQuery;

/**
@@ -34,7 +34,7 @@ import adql.query.ADQLQuery;
 * in case of several JOINs.
 * 
 * @author Gr&eacute;gory Mantelet (ARI) - gmantele@ari.uni-heidelberg.de
 * @version 1.3 (10/2014)
 * @version 1.3 (05/2015)
 * @since 1.2
 */
public class DBCommonColumn implements DBColumn {
@@ -56,12 +56,12 @@ public class DBCommonColumn implements DBColumn {
	 * @param leftCol	Column of the left join table. May be a {@link DBCommonColumn}.
	 * @param rightCol	Column of the right join table. May be a {@link DBCommonColumn}.
	 * 
	 * @throws UnresolvedJoin	If the type of the two given columns are not roughly (just testing numeric, string or geometry) compatible.
	 * @throws UnresolvedJoinException	If the type of the two given columns are not roughly (just testing numeric, string or geometry) compatible.
	 */
	public DBCommonColumn(final DBColumn leftCol, final DBColumn rightCol) throws UnresolvedJoin{
	public DBCommonColumn(final DBColumn leftCol, final DBColumn rightCol) throws UnresolvedJoinException{
		// Test whether type of both columns are compatible:
		if (leftCol.getDatatype() != null && rightCol.getDatatype() != null && !leftCol.getDatatype().isCompatible(rightCol.getDatatype()))
			throw new UnresolvedJoin("JOIN impossible: incompatible column types when trying to join the columns " + leftCol.getADQLName() + " (" + leftCol.getDatatype() + ") and " + rightCol.getADQLName() + " (" + rightCol.getDatatype() + ")!");
			throw new UnresolvedJoinException("JOIN impossible: incompatible column types when trying to join the columns " + leftCol.getADQLName() + " (" + leftCol.getDatatype() + ") and " + rightCol.getADQLName() + " (" + rightCol.getDatatype() + ")!");

		// LEFT COLUMN:
		if (leftCol instanceof DBCommonColumn){
+6 −6
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ package adql.db.exception;
 * You should have received a copy of the GNU Lesser General Public License
 * along with ADQLLibrary.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2014 - Astronomisches Rechen Institut (ARI)
 * Copyright 2014-2015 - Astronomisches Rechen Institut (ARI)
 */

import adql.parser.ParseException;
@@ -26,10 +26,10 @@ import adql.query.operand.function.ADQLFunction;
 * Exception thrown when a function can not be resolved by the library.
 * 
 * @author Gr&eacute;gory Mantelet (ARI)
 * @version 1.3 (10/2014)
 * @version 1.3 (05/2015)
 * @since 1.3
 */
public class UnresolvedFunction extends ParseException {
public class UnresolvedFunctionException extends ParseException {
	private static final long serialVersionUID = 1L;

	/** Function which can not be resolved. */
@@ -40,7 +40,7 @@ public class UnresolvedFunction extends ParseException {
	 * 
	 * @param message	Description of the error.
	 */
	public UnresolvedFunction(final String message){
	public UnresolvedFunctionException(final String message){
		super(message);
		functionInError = null;
	}
@@ -51,7 +51,7 @@ public class UnresolvedFunction extends ParseException {
	 * 
	 * @param fct	The unresolved function.
	 */
	public UnresolvedFunction(final ADQLFunction fct){
	public UnresolvedFunctionException(final ADQLFunction fct){
		super("Unresolved function: \"" + fct.toADQL() + "\"! No UDF has been defined or found with the signature: " + getFctSignature(fct) + "."); // TODO Add the position of the function in the ADQL query!
		functionInError = fct;
	}
@@ -63,7 +63,7 @@ public class UnresolvedFunction extends ParseException {
	 * @param message	Description of the error.
	 * @param fct		The unresolved function.
	 */
	public UnresolvedFunction(final String message, final ADQLFunction fct){
	public UnresolvedFunctionException(final String message, final ADQLFunction fct){
		super(message); // TODO Add the position of the function in the ADQL query!
		functionInError = fct;
	}
+2 −2
Original line number Diff line number Diff line
@@ -72,8 +72,8 @@ public class UnresolvedIdentifiersException extends ParseException implements It
				String tableName = ((UnresolvedTableException)pe).getTableName();
				if (tableName != null && !tableName.trim().isEmpty())
					addIdentifierName(tableName + " " + pe.getPosition());
			}else if (pe instanceof UnresolvedFunction){
				String fctName = (((UnresolvedFunction)pe).getFunction() == null) ? null : ((UnresolvedFunction)pe).getFunction().getName() + "(...)";
			}else if (pe instanceof UnresolvedFunctionException){
				String fctName = (((UnresolvedFunctionException)pe).getFunction() == null) ? null : ((UnresolvedFunctionException)pe).getFunction().getName() + "(...)";
				if (fctName != null && !fctName.trim().isEmpty())
					addIdentifierName(fctName /*+ " " + pe.getPosition()*/);	// TODO Add the position of the function in the ADQL query!
			}else if (pe instanceof UnresolvedIdentifiersException)
+6 −5
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ package adql.db.exception;
 * You should have received a copy of the GNU Lesser General Public License
 * along with ADQLLibrary.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2013-2014 - Astronomisches Rechen Institut (ARI)
 * Copyright 2013-2015 - Astronomisches Rechen Institut (ARI)
 */

import adql.parser.ParseException;
@@ -27,9 +27,10 @@ import adql.query.TextPosition;
 * and particularly because of the join condition (i.e. column names not found, ...).
 * 
 * @author Gr&eacute;gory Mantelet (ARI) - gmantele@ari.uni-heidelberg.de
 * @version 1.2 (11/2013)
 * @version 1.3 (05/2015)
 * @since 1.2
 */
public class UnresolvedJoin extends ParseException {
public class UnresolvedJoinException extends ParseException {
	private static final long serialVersionUID = 1L;

	/**
@@ -38,7 +39,7 @@ public class UnresolvedJoin extends ParseException {
	 * 
	 * @param message	Message to display explaining why the join can't be resolved.
	 */
	public UnresolvedJoin(String message){
	public UnresolvedJoinException(String message){
		super(message);
	}

@@ -48,7 +49,7 @@ public class UnresolvedJoin extends ParseException {
	 * @param message		Message to display explaining why the join can't be resolved.
	 * @param errorPosition	Position of the wrong part of the join.
	 */
	public UnresolvedJoin(String message, TextPosition errorPosition){
	public UnresolvedJoinException(String message, TextPosition errorPosition){
		super(message, errorPosition);
	}

Loading