Commit f7adf914 authored by gmantele's avatar gmantele
Browse files

[TAP] Log format reports and end of ADQLExecutor execution, add an OVERFLOW...

[TAP] Log format reports and end of ADQLExecutor execution, add an OVERFLOW notification for the text/plain output and check by default that the given service connection is not null in constructor.
parent 17ee5de9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -370,6 +370,9 @@ public class ADQLExecutor {

			// Set the total duration in the report:
			report.setTotalDuration(System.currentTimeMillis() - start);

			// Log and report the end of this execution:
			logger.logTAP(LogLevel.INFO, report, "END_EXEC", "ADQL query execution finished.", null);
		}
	}

+13 −6
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ import adql.db.DBColumn;
 * Format any given query (table) result into JSON.
 * 
 * @author Grégory Mantelet (CDS;ARI)
 * @version 2.0 (09/2014)
 * @version 2.0 (10/2014)
 */
public class JSONFormat implements OutputFormat {

@@ -59,9 +59,11 @@ public class JSONFormat implements OutputFormat {
	 * However if you want this behavior you must you {@link #JSONFormat(ServiceConnection, boolean)}.</i></p>
	 * 
	 * @param service	Description of the TAP service.
	 * 
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public JSONFormat(final ServiceConnection service){
		this(service, false);
	public JSONFormat(final ServiceConnection service) throws NullPointerException{
		this(service, true);
	}

	/**
@@ -69,8 +71,13 @@ public class JSONFormat implements OutputFormat {
	 * 
	 * @param service			Description of the TAP service.
	 * @param logFormatReport	<i>true</i> to write a log entry (with nb rows and columns + writing duration) each time a result is written, <i>false</i> otherwise.
	 * 
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public JSONFormat(final ServiceConnection service, final boolean logFormatReport){
	public JSONFormat(final ServiceConnection service, final boolean logFormatReport) throws NullPointerException{
		if (service == null)
			throw new NullPointerException("The given service connection is NULL!");

		this.service = service;
		this.logFormatReport = logFormatReport;
	}
+19 −6
Original line number Diff line number Diff line
@@ -63,8 +63,10 @@ public class SVFormat implements OutputFormat {
	 * 
	 * @param service		Description of the TAP service.
	 * @param colSeparator	Column separator to use.
	 * 
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public SVFormat(final ServiceConnection service, char colSeparator){
	public SVFormat(final ServiceConnection service, char colSeparator) throws NullPointerException{
		this(service, colSeparator, true);
	}

@@ -74,9 +76,11 @@ public class SVFormat implements OutputFormat {
	 * @param service			Description of the TAP service.
	 * @param colSeparator		Column separator to use.
	 * @param delimitStrings	<i>true</i> if String values must be delimited by double quotes, <i>false</i> otherwise.
	 * 
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public SVFormat(final ServiceConnection service, char colSeparator, boolean delimitStrings){
		this(service, colSeparator, delimitStrings, false);
	public SVFormat(final ServiceConnection service, char colSeparator, boolean delimitStrings) throws NullPointerException{
		this(service, colSeparator, delimitStrings, true);
	}

	/**
@@ -86,8 +90,10 @@ public class SVFormat implements OutputFormat {
	 * @param colSeparator		Column separator to use.
	 * @param delimitStrings	<i>true</i> if String values must be delimited by double quotes, <i>false</i> otherwise.
	 * @param logFormatReport	<i>true</i> to write a log entry (with nb rows and columns + writing duration) each time a result is written, <i>false</i> otherwise.
	 * 
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public SVFormat(final ServiceConnection service, char colSeparator, boolean delimitStrings, final boolean logFormatReport){
	public SVFormat(final ServiceConnection service, char colSeparator, boolean delimitStrings, final boolean logFormatReport) throws NullPointerException{
		separator = "" + colSeparator;
		delimitStr = delimitStrings;
		this.service = service;
@@ -99,8 +105,10 @@ public class SVFormat implements OutputFormat {
	 * 
	 * @param service		Description of the TAP service.
	 * @param colSeparator	Column separator to use.
	 * 
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public SVFormat(final ServiceConnection service, String colSeparator){
	public SVFormat(final ServiceConnection service, String colSeparator) throws NullPointerException{
		this(service, colSeparator, true);
	}

@@ -110,8 +118,13 @@ public class SVFormat implements OutputFormat {
	 * @param service			Description of the TAP service.
	 * @param colSeparator		Column separator to use.
	 * @param delimitStrings	<i>true</i> if String values must be delimited by double quotes, <i>false</i> otherwise.
	 * 
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public SVFormat(final ServiceConnection service, String colSeparator, boolean delimitStrings){
	public SVFormat(final ServiceConnection service, String colSeparator, boolean delimitStrings) throws NullPointerException{
		if (service == null)
			throw new NullPointerException("The given service connection is NULL!");

		separator = (colSeparator == null) ? ("" + COMMA_SEPARATOR) : colSeparator;
		delimitStr = delimitStrings;
		this.service = service;
+16 −4
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ import cds.util.AsciiTable;
 * (columns' width are adjusted so that all columns are well aligned and of the same width).
 * 
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 2.0 (09/2014)
 * @version 2.0 (10/2014)
 */
public class TextFormat implements OutputFormat {

@@ -50,9 +50,11 @@ public class TextFormat implements OutputFormat {
	 * Build a {@link TextFormat}.
	 * 
	 * @param service	Description of the TAP service.
	 * 
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public TextFormat(final ServiceConnection service){
		this(service, false);
	public TextFormat(final ServiceConnection service) throws NullPointerException{
		this(service, true);
	}

	/**
@@ -60,8 +62,13 @@ public class TextFormat implements OutputFormat {
	 * 
	 * @param service			Description of the TAP service.
	 * @param logFormatReport	<i>true</i> to write a log entry (with nb rows and columns + writing duration) each time a result is written, <i>false</i> otherwise.
	 * 
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public TextFormat(final ServiceConnection service, final boolean logFormatReport){
	public TextFormat(final ServiceConnection service, final boolean logFormatReport) throws NullPointerException{
		if (service == null)
			throw new NullPointerException("The given service connection is NULL!");

		this.service = service;
		this.logFormatReport = logFormatReport;
	}
@@ -108,6 +115,11 @@ public class TextFormat implements OutputFormat {
				output.write(l.getBytes());
				output.write('\n');
			}

			// Add a line in case of an OVERFLOW:
			if (execReport.parameters.getMaxRec() > 0 && nbRows >= execReport.parameters.getMaxRec())
				output.write("\nOVERFLOW (more rows were available but have been truncated by the TAP service)".getBytes());

			output.flush();

			// Report stats about the result writing:
+8 −7
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ public class VOTableFormat implements OutputFormat {
	protected String shortMimeType;

	/**
	 * <p>Creates a VOTable formatter without format report.</p>
	 * <p>Creates a VOTable formatter.</p>
	 * 
	 * <p><i>Note:
	 * 	The MIME type is automatically set to "application/x-votable+xml" = "votable".
@@ -119,7 +119,7 @@ public class VOTableFormat implements OutputFormat {
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public VOTableFormat(final ServiceConnection service) throws NullPointerException{
		this(service, false);
		this(service, true);
	}

	/**
@@ -141,7 +141,7 @@ public class VOTableFormat implements OutputFormat {
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public VOTableFormat(final ServiceConnection service, final DataFormat votFormat) throws NullPointerException{
		this(service, votFormat, null, false);
		this(service, votFormat, null, true);
	}

	/**
@@ -164,7 +164,7 @@ public class VOTableFormat implements OutputFormat {
	 * @throws NullPointerException	If the given service connection is <code>null</code>.
	 */
	public VOTableFormat(final ServiceConnection service, final DataFormat votFormat, final VOTableVersion votVersion) throws NullPointerException{
		this(service, votFormat, votVersion, false);
		this(service, votFormat, votVersion, true);
	}

	/**
@@ -610,7 +610,7 @@ public class VOTableFormat implements OutputFormat {
	 * </p>
	 * 
	 * @author Gr&eacute;gory Mantelet (CDS;ARI)
	 * @version 2.0 (07/2014)
	 * @version 2.0 (10/2014)
	 * @since 2.0
	 */
	private static class LimitedStarTable extends AbstractStarTable {
@@ -702,6 +702,7 @@ public class VOTableFormat implements OutputFormat {
							if (hasNext){
								for(int i = 0; i < nbCol && tableIt.hasNextCol(); i++)
									row[i] = tableIt.nextCol();
								nbRows++;
							}else
								row = null;
							return hasNext;