use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class RowGeneratorComponent method convert.
/**
* Coverts <code>MetadataColumn</code> to <code>MetadataColumnExt</code>
*
* @param metadataTable
* @return
*/
private void convert(IMetadataTable metadataTable) {
List<IMetadataColumn> exts = new ArrayList<IMetadataColumn>();
for (int j = 0; j < metadataTable.getListColumns().size(); j++) {
IMetadataColumn column = metadataTable.getListColumns().get(j);
if (column instanceof MetadataColumn) {
MetadataColumnExt ext = new MetadataColumnExt((MetadataColumn) column);
String columnValue = this.getColumnValue(ext, j);
if (columnValue != null && columnValue.length() > 0) {
//$NON-NLS-1$ //$NON-NLS-2$
columnValue = columnValue.replaceAll("\"", "");
//$NON-NLS-1$
columnValue = columnValue.substring(columnValue.lastIndexOf(".") + 1);
Function function = new Function();
function.setName(columnValue);
ext.setFunction(function);
}
exts.add(ext);
}
}
metadataTable.setListColumns(exts);
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class TabFolderEditors method addListenersToOutputButtons.
/**
* DOC amaumont Comment method "addListenersToInputButtons".
*/
private void addListenersToOutputButtons() {
MetadataToolbarEditorView toolBar = outputMetaEditor.getToolBar();
outputToolBarButtons = toolBar.getButtons();
beforeCommandListenerForOutputButtons = new IExtendedButtonListener() {
public void handleEvent(ExtendedButtonEvent event) {
TableViewerCreator tableViewerCreator = mapperManager.getUiManager().getCurrentSelectedOutputTableView().getTableViewerCreatorForColumns();
if (tableViewerCreator != null) {
tableViewerCreator.applyActivatedCellEditor();
}
}
};
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
extendedPushButton.addListener(beforeCommandListenerForOutputButtons, true);
if (extendedPushButton instanceof RemovePushButton && !mapperManager.componentIsReadOnly()) {
removeButton = (RemovePushButtonForExtendedTable) extendedPushButton;
}
}
if (removeButton != null) {
final TableViewerCreator tableViewerCreator = removeButton.getExtendedTableViewer().getTableViewerCreator();
tableViewerCreator.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() {
public void handle(LineSelectionEvent e) {
for (TableItem item : tableViewerCreator.getTable().getSelection()) {
if (item.getData() instanceof MetadataColumn) {
MetadataColumn column = (MetadataColumn) item.getData();
removeButton.getButton().setEnabled(!column.isCustom());
break;
}
}
}
});
}
this.addDisposeListener(new DisposeListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
*/
public void widgetDisposed(DisposeEvent e) {
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
extendedPushButton.removeListener(beforeCommandListenerForOutputButtons, true);
}
}
});
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class ChangeValuesFromRepositoryTest method createSimpleMetadata.
private IMetadataTable createSimpleMetadata() {
IMetadataTable table = new org.talend.core.model.metadata.MetadataTable();
IMetadataColumn column1 = new MetadataColumn();
//$NON-NLS-1$
column1.setLabel("C1");
//$NON-NLS-1$
column1.setTalendType("id_String");
table.getListColumns().add(column1);
IMetadataColumn column2 = new MetadataColumn();
//$NON-NLS-1$
column2.setLabel("C2");
//$NON-NLS-1$
column2.setTalendType("id_String");
table.getListColumns().add(column2);
IMetadataColumn column3 = new MetadataColumn();
//$NON-NLS-1$
column3.setLabel("C3");
//$NON-NLS-1$
column3.setTalendType("id_Integer");
table.getListColumns().add(column3);
return table;
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class RepositoryChangeMetadataCommandTest method testComponentSchemaUpdated.
@Test
public void testComponentSchemaUpdated() {
IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceInput", "DI");
Node node = new Node(component, new Process(new FakePropertyImpl()));
IMetadataTable table = node.getMetadataList().get(0);
IMetadataColumn column = new MetadataColumn();
column.setLabel("C1");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
column.setLabel("C2");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
column.setLabel("C3");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
IMetadataTable newTable = table.clone(true);
newTable.getListColumns().remove(0);
IElementParameter schemaParam = null;
for (IElementParameter param : node.getElementParameters()) {
if (EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType())) {
schemaParam = param;
break;
}
}
assertNotNull(schemaParam);
//$NON-NLS-1$
String fullParamName = SCHEMA_PARAM_NAME + ":REPOSITORY_SCHEMA_TYPE";
//$NON-NLS-1$ //$NON-NLS-2$
String propValue = "testconnid" + " - " + newTable.getTableName();
RepositoryChangeMetadataCommand changeMetadataCommand = new RepositoryChangeMetadataCommand(node, fullParamName, propValue, newTable, null, null);
changeMetadataCommand.execute();
newTable = node.getMetadataList().get(0);
String avroSchemaStr = ((SchemaProperties) node.getComponentProperties().getProperties("module.main")).schema.getStringValue();
assertNotNull(avroSchemaStr);
Schema avroSchema = new Schema.Parser().parse(avroSchemaStr);
assertEquals(2, avroSchema.getFields().size());
//$NON-NLS-1$
assertNull(avroSchema.getField("C1"));
assertEquals(avroSchemaStr, schemaParam.getValue().toString());
}
use of org.talend.core.model.metadata.MetadataColumn in project tdi-studio-se by Talend.
the class ChangeMetadataCommandTest method testComponentSchemaUpdated.
@Test
public void testComponentSchemaUpdated() {
IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceInput", "DI");
Node node = new Node(component, new Process(new FakePropertyImpl()));
IMetadataTable table = node.getMetadataList().get(0);
IMetadataColumn column = new MetadataColumn();
column.setLabel("C1");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
column.setLabel("C2");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
column = new MetadataColumn();
column.setLabel("C3");
column.setTalendType(JavaTypesManager.STRING.getId());
table.getListColumns().add(column);
IMetadataTable newTable = table.clone(true);
newTable.getListColumns().remove(0);
IElementParameter schemaParam = null;
for (IElementParameter param : node.getElementParameters()) {
if (EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType())) {
schemaParam = param;
break;
}
}
assertNotNull(schemaParam);
ChangeMetadataCommand changeMetadataCommand = new ChangeMetadataCommand(node, schemaParam, null, null, null, table, newTable);
changeMetadataCommand.execute();
String avroSchemaStr = ((SchemaProperties) node.getComponentProperties().getProperties("module.main")).schema.getStringValue();
assertNotNull(avroSchemaStr);
Schema avroSchema = new Schema.Parser().parse(avroSchemaStr);
assertEquals(2, avroSchema.getFields().size());
//$NON-NLS-1$
assertNull(avroSchema.getField("C1"));
assertEquals(avroSchemaStr, schemaParam.getValue().toString());
}
Aggregations