use of org.pentaho.metadata.model.LogicalColumn in project pentaho-kettle by pentaho.
the class ConceptUtilTest method testFindFirstKeyColumn.
@Test
public void testFindFirstKeyColumn() throws Exception {
final LogicalTable logicalTable = mock(LogicalTable.class);
assertNull(ConceptUtil.findFirstKeyColumn(logicalTable));
final LogicalColumn logicalColumn = mock(LogicalColumn.class);
final LogicalColumn logicalColumnKey1 = mock(LogicalColumn.class);
final LogicalColumn logicalColumnKey2 = mock(LogicalColumn.class);
when(logicalColumnKey1.getFieldType()).thenReturn(FieldType.KEY);
when(logicalColumnKey2.getFieldType()).thenReturn(FieldType.KEY);
when(logicalTable.getLogicalColumns()).thenReturn(new LinkedList<LogicalColumn>() {
{
add(logicalColumn);
add(logicalColumnKey1);
add(logicalColumnKey2);
}
});
final LogicalColumn firstKeyColumn = ConceptUtil.findFirstKeyColumn(logicalTable);
assertEquals(logicalColumnKey1, firstKeyColumn);
}
use of org.pentaho.metadata.model.LogicalColumn in project pentaho-kettle by pentaho.
the class ConceptUtilTest method testFindLogicalColumns.
@Test
public void testFindLogicalColumns() throws Exception {
final LogicalTable logicalTable = mock(LogicalTable.class);
final AttributeType attribute = AttributeType.ATTRIBUTE;
final LogicalColumn logicalColumn1 = mock(LogicalColumn.class);
when(logicalColumn1.getProperty(DefaultIDs.LOGICAL_COLUMN_ATTRIBUTE_TYPE)).thenReturn(attribute.name());
final LogicalColumn logicalColumn2 = mock(LogicalColumn.class);
when(logicalColumn2.getProperty(DefaultIDs.LOGICAL_COLUMN_ATTRIBUTE_TYPE)).thenReturn(attribute.name());
when(logicalTable.getLogicalColumns()).thenReturn(new LinkedList<LogicalColumn>() {
{
add(logicalColumn1);
add(logicalColumn2);
}
});
assertTrue(ConceptUtil.findLogicalColumns(logicalTable, AttributeType.ATTRIBUTE_HISTORICAL).isEmpty());
final List<LogicalColumn> logicalColumns = ConceptUtil.findLogicalColumns(logicalTable, attribute);
assertEquals(2, logicalColumns.size());
assertEquals(logicalColumn1, logicalColumns.get(0));
assertEquals(logicalColumn2, logicalColumns.get(1));
}
use of org.pentaho.metadata.model.LogicalColumn in project pentaho-kettle by pentaho.
the class ConceptUtilTest method testGetAttributeType.
@Test
public void testGetAttributeType() throws Exception {
final LogicalColumn logicalColumn = mock(LogicalColumn.class);
final AttributeType attribute = AttributeType.ATTRIBUTE;
when(logicalColumn.getProperty(DefaultIDs.LOGICAL_COLUMN_ATTRIBUTE_TYPE)).thenReturn(attribute.name());
final AttributeType attributeType = ConceptUtil.getAttributeType(logicalColumn);
assertEquals(attribute, attributeType);
}
use of org.pentaho.metadata.model.LogicalColumn in project pentaho-kettle by pentaho.
the class DimensionTableDialog method refreshAttributesList.
protected void refreshAttributesList() {
wAttributes.clearAll();
for (LogicalColumn column : logicalTable.getLogicalColumns()) {
addLogicalColumnToAttributesList(column);
}
wAttributes.removeEmptyRows();
wAttributes.setRowNums();
wAttributes.optWidth(true);
}
use of org.pentaho.metadata.model.LogicalColumn in project pentaho-kettle by pentaho.
the class DimensionTableDialog method addAttribute.
private void addAttribute(String name, String description, String phName, AttributeType attributeType, DataType dataType, int length, int precision, String comment) {
LogicalColumn column = new LogicalColumn();
column.setLogicalTable(logicalTable);
column.setName(new LocalizedString(locale, name));
column.setDescription(new LocalizedString(locale, description));
column.setDataType(dataType);
column.setProperty(DefaultIDs.LOGICAL_COLUMN_ATTRIBUTE_TYPE, attributeType.name());
column.setProperty(DefaultIDs.LOGICAL_COLUMN_PHYSICAL_COLUMN_NAME, phName);
if (length >= 0)
column.setProperty(DefaultIDs.LOGICAL_COLUMN_LENGTH, Integer.toString(length));
if (precision >= 0)
column.setProperty(DefaultIDs.LOGICAL_COLUMN_PRECISION, Integer.toString(precision));
column.setProperty(DefaultIDs.LOGICAL_COLUMN_CONVERSION_REMARKS, comment);
addLogicalColumnToAttributesList(column);
}
Aggregations