Search in sources :

Example 1 with LogicalColumn

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);
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn) LogicalTable(org.pentaho.metadata.model.LogicalTable) Test(org.junit.Test)

Example 2 with LogicalColumn

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));
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn) LogicalTable(org.pentaho.metadata.model.LogicalTable) Test(org.junit.Test)

Example 3 with LogicalColumn

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);
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn) Test(org.junit.Test)

Example 4 with LogicalColumn

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);
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn)

Example 5 with LogicalColumn

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);
}
Also used : LogicalColumn(org.pentaho.metadata.model.LogicalColumn) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Aggregations

LogicalColumn (org.pentaho.metadata.model.LogicalColumn)30 LocalizedString (org.pentaho.metadata.model.concept.types.LocalizedString)16 LogicalTable (org.pentaho.metadata.model.LogicalTable)12 ArrayList (java.util.ArrayList)10 LogicalModel (org.pentaho.metadata.model.LogicalModel)9 Domain (org.pentaho.metadata.model.Domain)8 Category (org.pentaho.metadata.model.Category)7 Test (org.junit.Test)5 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)4 SqlDataSource (org.pentaho.metadata.model.SqlDataSource)4 SqlPhysicalColumn (org.pentaho.metadata.model.SqlPhysicalColumn)4 SqlPhysicalModel (org.pentaho.metadata.model.SqlPhysicalModel)4 SqlPhysicalTable (org.pentaho.metadata.model.SqlPhysicalTable)4 AggregationType (org.pentaho.metadata.model.concept.types.AggregationType)4 Point (org.pentaho.di.core.gui.Point)3 StepMeta (org.pentaho.di.trans.step.StepMeta)3 List (java.util.List)2 Document (org.dom4j.Document)2 Element (org.dom4j.Element)2 TableItem (org.eclipse.swt.widgets.TableItem)2