Skip to content

Commit

Permalink
[UWS,TAP] Add the property 'creationTime' to a UWS (and so TAP as wel…
Browse files Browse the repository at this point in the history
…l) job.

This property is displayed in the XML and JSON serialization of a job item.
It is also backuped and restored from a UWS backup file.

/!\ WARNING: Small modification of the API! Since creationTime must be
             set by the UWS service at creation of a job, this date must also
             be imported at backup restoration. Hence the modification of the
             interface uws.service.UWSFactory and its implementations
             (particularly tap.AbstractTAPFactory). Similarly the class
             uws.job.UWSJob and tap.job.TAPJob have underwent exactly the same
             modification in one of their constructors.

This commit also adds the new optional jobRef items: creationTime, runID and
ownerID in the XML and JSON serializations.
  • Loading branch information
gmantele committed Feb 26, 2018
1 parent 15f2fb8 commit a8d98f6
Show file tree
Hide file tree
Showing 13 changed files with 591 additions and 454 deletions.
7 changes: 4 additions & 3 deletions src/org/json/Json4Uws.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,16 @@ public final static JSONObject getJson(final UWSJob job, final UWSUrl jobsListUr
json.put("version", UWS.VERSION);
json.put(UWSJob.PARAM_JOB_ID, job.getJobId());
json.put(UWSJob.PARAM_PHASE, job.getPhase());
json.put(UWSJob.PARAM_RUN_ID, job.getRunId());
if (job.getOwner() != null)
json.put(UWSJob.PARAM_OWNER, job.getOwner().getPseudo());
json.put(UWSJob.PARAM_CREATION_TIME, ISO8601Format.format(job.getCreationTime()));
if (reference){
if (jobsListUrl != null){
jobsListUrl.setJobId(job.getJobId());
json.put("href", jobsListUrl.getRequestURL());
}
}else{
json.put(UWSJob.PARAM_RUN_ID, job.getRunId());
if (job.getOwner() != null)
json.put(UWSJob.PARAM_OWNER, job.getOwner().getPseudo());
json.put(UWSJob.PARAM_QUOTE, job.getQuote());
if (job.getStartTime() != null)
json.put(UWSJob.PARAM_START_TIME, ISO8601Format.format(job.getStartTime()));
Expand Down
75 changes: 38 additions & 37 deletions src/tap/AbstractTAPFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

/*
* This file is part of TAPLibrary.
*
*
* TAPLibrary is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* TAPLibrary is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2012-2016 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
*
* Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI)
*/

Expand All @@ -28,6 +28,12 @@

import javax.servlet.http.HttpServletRequest;

import adql.db.DBChecker;
import adql.parser.ADQLParser;
import adql.parser.ADQLQueryFactory;
import adql.parser.ParseException;
import adql.parser.QueryChecker;
import adql.query.ADQLQuery;
import tap.db.DBConnection;
import tap.error.DefaultTAPErrorWriter;
import tap.metadata.TAPMetadata;
Expand All @@ -43,19 +49,13 @@
import uws.service.UWSService;
import uws.service.backup.UWSBackupManager;
import uws.service.error.ServiceErrorWriter;
import adql.db.DBChecker;
import adql.parser.ADQLParser;
import adql.parser.ADQLQueryFactory;
import adql.parser.ParseException;
import adql.parser.QueryChecker;
import adql.query.ADQLQuery;

/**
* Default implementation of most of the {@link TAPFactory} function.
* Only the functions related with the database connection stay abstract.
*
*
* @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 2.1 (01/2016)
* @version 2.2 (09/2017)
*/
public abstract class AbstractTAPFactory extends TAPFactory {

Expand All @@ -65,11 +65,11 @@ public abstract class AbstractTAPFactory extends TAPFactory {
/**
* Build a basic TAPFactory.
* Nothing is done except setting the service connection.
*
*
* @param service Configuration of the TAP service. <i>MUST NOT be NULL</i>
*
*
* @throws NullPointerException If the given {@link ServiceConnection} is NULL.
*
*
* @see AbstractTAPFactory#AbstractTAPFactory(ServiceConnection, ServiceErrorWriter)
*/
protected AbstractTAPFactory(ServiceConnection service) throws NullPointerException{
Expand All @@ -79,14 +79,14 @@ protected AbstractTAPFactory(ServiceConnection service) throws NullPointerExcept
/**
* <p>Build a basic TAPFactory.
* Nothing is done except setting the service connection and the given error writer.</p>
*
*
* <p>Then the error writer will be used when creating a UWS service and a job thread.</p>
*
*
* @param service Configuration of the TAP service. <i>MUST NOT be NULL</i>
* @param errorWriter Object to use to format and write the errors for the user.
*
*
* @throws NullPointerException If the given {@link ServiceConnection} is NULL.
*
*
* @see TAPFactory#TAPFactory(ServiceConnection)
*/
protected AbstractTAPFactory(final ServiceConnection service, final ServiceErrorWriter errorWriter) throws NullPointerException{
Expand Down Expand Up @@ -141,7 +141,7 @@ public ADQLQueryFactory createQueryFactory() throws TAPException{
* by the user. Then it calls {@link #createQueryChecker(Collection)} with this list in order
* to create a query checked.
* </p>
*
*
* <p><i>Note:
* This function can not be overridded, but {@link #createQueryChecker(Collection)} can be.
* </i></p>
Expand Down Expand Up @@ -173,15 +173,15 @@ public final QueryChecker createQueryChecker(final TAPSchema uploadSchema) throw
* <p>Create an object able to check the consistency between the ADQL query and the database.
* That's to say, it checks whether the tables and columns used in the query really exist
* in the database.</p>
*
*
* <p><i>Note:
* This implementation just create a {@link DBChecker} instance with the list given in parameter.
* </i></p>
*
*
* @param tables List of all available tables (and indirectly, columns).
*
*
* @return A new ADQL query checker.
*
*
* @throws TAPException If any error occurs while creating the query checker.
*/
protected QueryChecker createQueryChecker(final Collection<TAPTable> tables) throws TAPException{
Expand All @@ -198,7 +198,7 @@ protected QueryChecker createQueryChecker(final Collection<TAPTable> tables) thr

/**
* <p>This implementation just create an {@link Uploader} instance with the given database connection.</p>
*
*
* <p><i>Note:
* This function should be overrided if you need to change the DB name of the TAP_UPLOAD schema.
* Indeed, by overriding this function you can specify a given TAPSchema to use as TAP_UPLOAD schema
Expand All @@ -217,7 +217,7 @@ public Uploader createUploader(final DBConnection dbConn) throws TAPException{

/**
* <p>This implementation just create a {@link UWSService} instance.</p>
*
*
* <p><i>Note:
* This implementation is largely enough for a TAP service. It is not recommended to override
* this function.
Expand All @@ -238,7 +238,7 @@ public UWSService createUWS() throws TAPException{
/**
* <p>This implementation does not provided a backup manager.
* It means that no asynchronous job will be restored and backuped.</p>
*
*
* <p>You must override this function if you want enable the backup feature.</p>
*/
@Override
Expand All @@ -248,7 +248,7 @@ public UWSBackupManager createUWSBackupManager(final UWSService uws) throws TAPE

/**
* <p>This implementation provides a basic {@link TAPJob} instance.</p>
*
*
* <p>
* If you need to add or modify the behavior of some functions of a {@link TAPJob},
* you must override this function and return your own extension of {@link TAPJob}.
Expand All @@ -257,7 +257,7 @@ public UWSBackupManager createUWSBackupManager(final UWSService uws) throws TAPE
@Override
protected TAPJob createTAPJob(final HttpServletRequest request, final JobOwner owner) throws UWSException{
try{
// Extract the HTTP request ID (the job ID should be the same, if not already used by another job):
// Extract the HTTP request ID (the job ID should be the same, if not already used by another job):
String requestID = null;
if (request.getAttribute(UWS.REQ_ATTRIBUTE_ID) != null && request.getAttribute(UWS.REQ_ATTRIBUTE_ID) instanceof String)
requestID = request.getAttribute(UWS.REQ_ATTRIBUTE_ID).toString();
Expand All @@ -277,16 +277,17 @@ protected TAPJob createTAPJob(final HttpServletRequest request, final JobOwner o

/**
* <p>This implementation provides a basic {@link TAPJob} instance.</p>
*
*
* <p>
* If you need to add or modify the behavior of some functions of a {@link TAPJob},
* you must override this function and return your own extension of {@link TAPJob}.
* If you need to add or modify the behavior of some functions of a
* {@link TAPJob}, you must override this function and return your own
* extension of {@link TAPJob}.
* </p>
*/
@Override
protected TAPJob createTAPJob(final String jobId, final JobOwner owner, final TAPParameters params, final long quote, final long startTime, final long endTime, final List<Result> results, final ErrorSummary error) throws UWSException{
protected TAPJob createTAPJob(final String jobId, final long creationTime, final JobOwner owner, final TAPParameters params, final long quote, final long startTime, final long endTime, final List<Result> results, final ErrorSummary error) throws UWSException{
try{
return new TAPJob(jobId, owner, params, quote, startTime, endTime, results, error);
return new TAPJob(jobId, creationTime, owner, params, quote, startTime, endTime, results, error);
}catch(TAPException te){
if (te.getCause() != null && te.getCause() instanceof UWSException)
throw (UWSException)te.getCause();
Expand All @@ -297,7 +298,7 @@ protected TAPJob createTAPJob(final String jobId, final JobOwner owner, final TA

/**
* <p>This implementation extracts standard TAP parameters from the given request.</p>
*
*
* <p>
* Non-standard TAP parameters are added in a map inside the returned {@link TAPParameters} object
* and are accessible with {@link TAPParameters#get(String)} and {@link TAPParameters#getAdditionalParameters()}.
Expand All @@ -312,7 +313,7 @@ public TAPParameters createTAPParameters(final HttpServletRequest request) throw

/**
* <p>This implementation extracts standard TAP parameters from the given request.</p>
*
*
* <p>
* Non-standard TAP parameters are added in a map inside the returned {@link TAPParameters} object
* and are accessible with {@link TAPParameters#get(String)} and {@link TAPParameters#getAdditionalParameters()}.
Expand Down
Loading

0 comments on commit a8d98f6

Please sign in to comment.