Skip to content

lookupSchema

Chuck May edited this page Apr 14, 2015 · 9 revisions
public List<StagingSchema> lookupSchema(SchemaLookup lookup)

Description

Look up a schema based on site, histology and an optional set of discriminators.

Examples

Staging staging = Staging.getInstance(CsDataProvider.getInstance(CsVersion.v020550));

// test bad values
List<StagingSchema> lookup = staging.lookupSchema(new SchemaLookup());
Assert.assertEquals(0, lookup.size());

lookup = staging.lookupSchema(new CsSchemaLookup("XXX", "YYY"));
Assert.assertEquals(0, lookup.size());

// valid combinations that do not require a discriminator
lookup = staging.lookupSchema(new CsSchemaLookup("C629", "9231", ""));
Assert.assertEquals(1, lookup.size());
Assert.assertEquals("testis", lookup.get(0).getId());
Assert.assertEquals(Integer.valueOf(122), lookup.get(0).getSchemaNum());
lookup = staging.lookupSchema(new CsSchemaLookup("C629", "9231", null));
Assert.assertEquals(1, lookup.size());
Assert.assertEquals("testis", lookup.get(0).getId());
Assert.assertEquals(Integer.valueOf(122), lookup.get(0).getSchemaNum());

// valid combination that requires a discriminator but is not supplied one
lookup = staging.lookupSchema(new CsSchemaLookup("C111", "8200"));
Assert.assertEquals(2, lookup.size());
for (StagingSchema schema : lookup)
    Assert.assertEquals(Sets.newHashSet("ssf25"), schema.getSchemaDiscriminators());

// valid combination that requires discriminator and a good discriminator is 
// supplied
lookup = staging.lookupSchema(new CsSchemaLookup("C111", "8200", "010"));
Assert.assertEquals(1, lookup.size());
for (StagingSchema schema : lookup)
    Assert.assertEquals(Sets.newHashSet("ssf25"), schema.getSchemaDiscriminators());
Assert.assertEquals("nasopharynx", lookup.get(0).getId());
Assert.assertEquals(Integer.valueOf(34), lookup.get(0).getSchemaNum());

// valid combination that requires a discriminator but is supplied a bad
// disciminator value
lookup = staging.lookupSchema(new CsSchemaLookup("C111", "8200", "999"));
Assert.assertEquals(0, lookup.size());

// test searching on only site
lookup = staging.lookupSchema(new CsSchemaLookup("C401", null, null));
Assert.assertEquals(5, lookup.size());

// test searching on only hist
lookup = staging.lookupSchema(new CsSchemaLookup(null, "9702", null));
Assert.assertEquals(2, lookup.size());
Clone this wiki locally