pmdDataFactory.initialize(new DesignTimeDataFactoryContext());
try
{
pmdDataFactory.setQuery("default", QUERY, null, null);
final CloseableTableModel tableModel = (CloseableTableModel) pmdDataFactory.queryData("default", new ParameterDataRow());
try
{
final DefaultDataSchemaDefinition def = new DefaultDataSchemaDefinition();
final DataSchemaCompiler compiler = new DataSchemaCompiler(def, new DefaultDataAttributeContext());
final DataSchema dataSchema = compiler.compile(tableModel);
final String[] names = dataSchema.getNames();
assertEquals(4, names.length);
assertEquals("BC_EMPLOYEES_FIRSTNAME", names[0]);
assertEquals("BC_EMPLOYEES_LASTNAME", names[1]);
assertEquals("BC_EMPLOYEES_EMPLOYEENUMBER", names[2]);
assertEquals("BC_EMPLOYEES_EMAIL", names[3]);
final DataAttributes attributes = dataSchema.getAttributes(names[2]);
// assert that formatting-label is not a default mapper
final ConceptQueryMapper mapper = attributes.getMetaAttributeMapper(MetaAttributeNames.Formatting.NAMESPACE,
MetaAttributeNames.Formatting.LABEL);
if (mapper instanceof DefaultConceptQueryMapper)
{
fail("Formatting::label should be a LocalizedString instead of a default-mapper");
}
final Object value = attributes.getMetaAttribute(MetaAttributeNames.Formatting.NAMESPACE,
MetaAttributeNames.Formatting.LABEL, null, new DefaultDataAttributeContext());
if (value instanceof LocalizedString == false)
{
fail("Formatting::label should be a LocalizedString");
}
final Object label = attributes.getMetaAttribute(MetaAttributeNames.Formatting.NAMESPACE,
MetaAttributeNames.Formatting.LABEL, String.class, new DefaultDataAttributeContext(Locale.US));
if (label instanceof String == false)
{
fail("Formatting::label should be a String");
}
final Object elementAlignment = attributes.getMetaAttribute(MetaAttributeNames.Style.NAMESPACE,
MetaAttributeNames.Style.HORIZONTAL_ALIGNMENT, null, new DefaultDataAttributeContext(Locale.US));
if ("right".equals(elementAlignment) == false)
{
fail("Style::horizontal-alignment should be a String of value 'right'");
}
final DataAttributes attributes2 = dataSchema.getAttributes(names[0]);
final Object elementAlignment2 = attributes2.getMetaAttribute(MetaAttributeNames.Style.NAMESPACE,
MetaAttributeNames.Style.HORIZONTAL_ALIGNMENT, null, new DefaultDataAttributeContext(Locale.US));
if ("left".equals(elementAlignment2) == false)
{
fail("Style::horizontal-alignment should be a String of value 'right'");
}
}
finally
{
tableModel.close();
}
}
finally
{