Edit Columns of EtlTable programmatically?

Hi, Mamad,

We just enhanced OpenAPI to support edit columns of a ETL Table.
Please update to latest patch to try the enhancement.
FYI, How to update to patch.

The following sample show you how to:

  1. add a Property column, and a Custom-Property column.

  2. sort by Name column.

  3. finally, close & reopen the ETL Table diagram to show the changes.

     	IETLTableDiagramUIModel lEtlDiagram = ...; // the ETL Table Diagram.
     	IETLTableDiagram lEtlModel = lEtlDiagram.getEtlTableDiagram();
     	{
     		// add a property column: taskType
     		IETLTableDiagramColumn lColumn = lEtlModel.createETLTableDiagramColumn();
     		lEtlModel.addColumn(lColumn);
     		
     		lColumn.setColumnType(IETLTableDiagramColumn.COLUMN_TYPE_PROPERTY);
     		lColumn.setColumnValue(IBPTask.PROP_TASK_TYPE); // property-name
     	}
     	{
     		// add a custom property: startDate
     		IETLTableDiagramColumn lColumn = lEtlModel.createETLTableDiagramColumn();
     		lEtlModel.addColumn(lColumn);
     		
     		lColumn.setColumnType(IETLTableDiagramColumn.COLUMN_TYPE_TAGGED_VALUE); // custom property
     		lColumn.setColumnValue("startDate"); // property-name
     		lColumn.setName("Start Date"); // caption
     		lColumn.setColumnWidth(200); // in pixel
     		
     		// data type of the custom property: Date 
     		lColumn.setTaggedValueType(ITaggedValue.TYPE_DATE);
     	}
     	
     	{
     		// sort by name
     		IETLTableDiagramColumn lNameColumn = null;
     		for (IETLTableDiagramColumn lColumn : lEtlModel.toColumnArray()) {
     			if (
     					lColumn.getColumnType() == IETLTableDiagramColumn.COLUMN_TYPE_PROPERTY && 
     					IModelElement.PROP_NAME.equals(lColumn.getColumnValue())
     			) {
     				lNameColumn = lColumn;
     				break;
     			}
     		}
     		
     		if (lNameColumn != null) {
     			ISortColumnInfo lSortColumn = lEtlModel.createSortColumnInfo();
     			lEtlModel.addSortColumnInfoInProperty(lSortColumn);
     			
     			lSortColumn.setColumn(lNameColumn);
     			lSortColumn.setAscending(true);
     		}
     	}
     	
     	// reopen the ETL diagram to show the new columns.
     	DiagramManager lDiagramManager = ApplicationManager.instance().getDiagramManager();
     	lEtlDiagram.realCloseDiagram();
     	lDiagramManager.openDiagram(lEtlDiagram);
    

and I prepared a simple class diagram to show you a part of the model structure.


PS:
There are 2 relationships between the ETLTableDiagram & its Column (Parent/Child, and ‘columns’ Association)
So, in plugin:
i. the createETLTableDiagramColumn() function create the column in Parent/Child.
ii. the addColumn(...) function add the column in columns association.

2 Likes