Skip to content

Commit

Permalink
ttools: taplint now checks for the correct ObsCore ID URI
Browse files Browse the repository at this point in the history
The taplint OBS (ObsCore) validation stage checks whether the capabilities
reports implementation of the ObsCore DM before attempting ObsCore-specific
tests.  The old check unfortunately tested for the wrong string:
"ivo://ivoa.net/std/ObsCore-1.0" instead of
"ivo://ivoa.net/std/ObsCore/v1.0".
This error was propagated from example text in the TAPRegExt 1.0 standard
document.

Now, it checks for both strings, and reports a warning if it finds the
wrong one, though it takes either, or in fact anything with the
(case-insensitive) string "obscore" in it, as license to do the ObsCore
tests.

It also now tests the ObsCore ID case-insensitively, since Markus points
out that IVOA Identifiers 1.12 says all IVO IDs are to be considered
as case-insensitive.
  • Loading branch information
mbtaylor committed Dec 10, 2013
1 parent f3365dc commit 907f453
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ttools/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<!-- Define the package name and current versions -->
<property name="Name" value="TTOOLS"/>
<property name="name" value="ttools"/>
<property name="version" value="2.5-1"/>
<property name="version" value="2.5-1+"/>

<!-- The Java package name -->
<property name="package.name" value="uk.ac.starlink.ttools"/>
Expand Down
3 changes: 3 additions & 0 deletions ttools/src/docs/sun256.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8503,6 +8503,9 @@ eds. C. Gabriel et al., ASP Conf. Ser. 351, p. 666 (2006)
That has been broken since mid-2010.</li>
<li>Add new command <code>tloop</code> for generating single-column
tables from a numeric loop variable.</li>
<li><code>taplint</code> now checks for the right ObsCore ID,
though still recognises the wrong one (got from TAPRegExt),
and warns if found.</li>
</ul>
</p></dd>

Expand Down
67 changes: 63 additions & 4 deletions ttools/src/main/uk/ac/starlink/ttools/taplint/ObsTapStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public class ObsTapStage implements Stage {
private final CapabilityHolder capHolder_;
private final MetadataHolder metaHolder_;

private static final String OBSCORE_ID = "ivo://ivoa.net/std/ObsCore-1.0";
private static final String OBSCORE_ID = "ivo://ivoa.net/std/ObsCore/v1.0";
private static final String OBSCORE_ID_WRONG =
"ivo://ivoa.net/std/ObsCore-1.0";
private static final String OBSCORE_TNAME = "ivoa.ObsCore";

private static Map<String,ObsCol> mandatoryColumnMap_;
Expand Down Expand Up @@ -60,9 +62,7 @@ public void run( Reporter reporter, URL serviceUrl ) {
/* Check prerequisites. */
TapCapability tcap = capHolder_.getCapability();
if ( tcap != null ) {
String[] dms = tcap.getDataModels();
if ( dms == null ||
! Arrays.asList( dms ).contains( OBSCORE_ID ) ) {
if ( ! hasObscoreDm( reporter, tcap ) ) {
reporter.report( ReportType.FAILURE, "NODM",
"Table capabilities lists no DataModel "
+ OBSCORE_ID );
Expand Down Expand Up @@ -95,6 +95,65 @@ public void run( Reporter reporter, URL serviceUrl ) {
new ObsTapRunner( reporter, serviceUrl, obsMeta, tapRunner_ ).run();
}

/**
* Determines whether a table capability reports conformance to the
* ObsCore data model. If not, an appropriate report is made.
*
* @param reporter reporter
* @param tcap tap capability object
* @param true iff it looks like ObsCore is indicated
*/
private boolean hasObscoreDm( Reporter reporter, TapCapability tcap ) {
String[] dms = tcap.getDataModels();
List<String> dmList = new ArrayList<String>();

/* Matching for IDs is case-insensitive - see document
* IVOA Identifiers v1.12, section 2. */
if ( dms != null ) {
for ( int i = 0; i < dms.length; i++ ) {
dmList.add( dms[ i ].toLowerCase() );
}
}

/* Check for OBSCORE_ID, which is the identifier taken from the
* ObsCore 1.0 document. */
if ( dmList.contains( OBSCORE_ID.toLowerCase() ) ) {
return true;
}

/* Failing that, check for OBSCORE_ID_WRONG, which is a string
* erroneously used in examples in TAPRegExt 1.0. This confusion
* reported on {dal,dm}@ivoa.net mailing lists on 4 Dec 2013. */
else if ( dmList.contains( OBSCORE_ID_WRONG.toLowerCase() ) ) {
String msg = new StringBuffer()
.append( "Wrong ObsCore identifier " )
.append( OBSCORE_ID_WRONG )
.append( " reported, should be " )
.append( OBSCORE_ID )
.append( " (known error in TAPRegExt 1.0 document)" )
.toString();
reporter.report( ReportType.WARNING, "WODM", msg );
return true;
}

/* Failing that, if it says ObsCore, that's probably what it means. */
else {
for ( String dm : dmList ) {
if ( dm.toLowerCase().indexOf( "obscore" ) >= 0 ) {
String msg = new StringBuffer()
.append( "Mis-spelt ObsCore identifier? " )
.append( dm )
.append( " reported, should be " )
.append( OBSCORE_ID )
.toString();
reporter.report( ReportType.WARNING, "IODM", msg );
return true;
}
}
return false;
}
}

/**
* Does the work for running tests on ObsCore table.
*/
Expand Down

0 comments on commit 907f453

Please sign in to comment.