use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class ExternalDataConverter method loadInExternalData.
private void loadInExternalData(List<? extends AbstractDataMapTable> tables, List<? extends AbstractDataMapTable> intables) {
// for (int i = 0; i < tables.size(); i++) {
if (tables.size() <= 0 || intables.size() <= 0) {
return;
}
IDataMapTable outtable = tables.get(0);
IDataMapTable intable = intables.get(0);
ExternalMapperTable externalMapperTable = new ExternalMapperTable();
fillExternalTable(outtable, externalMapperTable);
ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
List<IMetadataColumn> columnList = null;
if (mapperManager != null && mapperManager.getAbstractMapComponent() != null) {
List<? extends IConnection> connList = mapperManager.getAbstractMapComponent().getOutgoingConnections();
if (connList != null && connList.size() >= 1) {
List<IMetadataTable> metaList = connList.get(0).getTarget().getMetadataList();
if (metaList != null && metaList.size() >= 1) {
columnList = metaList.get(0).getListColumns();
}
}
}
for (ITableEntry dataMapTableEntry : intable.getColumnEntries()) {
if (columnList != null) {
boolean find = false;
for (IMetadataColumn column : columnList) {
if (dataMapTableEntry.getName().equals(column.getLabel())) {
find = true;
break;
}
}
if (find) {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
externalMapperTableEntry.setName(dataMapTableEntry.getName());
externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
perTableEntries.add(externalMapperTableEntry);
}
} else {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
externalMapperTableEntry.setName(dataMapTableEntry.getName());
externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
perTableEntries.add(externalMapperTableEntry);
}
}
externalMapperTable.setMetadataTableEntries(perTableEntries);
// }
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class ShadowProcess method buildProcess.
private IProcess buildProcess() {
IProcess ps = null;
if (description.getEncoding() != null) {
currentProcessEncoding = TalendTextUtils.removeQuotes(description.getEncoding());
}
FileOutputDelimitedNode outNode = new FileOutputDelimitedNode(TalendTextUtils.addQuotes("" + PathUtils.getPortablePath(outPath.toOSString())), //$NON-NLS-1$
description.getEncoding());
switch(type) {
case FILE_DELIMITED:
case FILE_CSV:
FileInputDelimitedNode inDelimitedNode = new FileInputDelimitedNode(inPath, description.getRowSeparator(), description.getFieldSeparator(), description.getLimitRows(), description.getHeaderRow(), description.getFooterRow(), description.getEscapeCharacter(), description.getTextEnclosure(), description.getRemoveEmptyRowsToSkip(), description.isSplitRecord(), description.getEncoding(), type);
ps = new FileinToDelimitedProcess<FileInputDelimitedNode>(inDelimitedNode, outNode);
break;
case FILE_POSITIONAL:
FileInputPositionalNode inPositionalNode = new FileInputPositionalNode(inPath, description.getRowSeparator(), description.getPattern(), description.getHeaderRow(), description.getFooterRow(), description.getLimitRows(), description.getRemoveEmptyRowsToSkip(), description.getEncoding());
outNode.setColumnNumber(inPositionalNode.getColumnNumber());
ps = new FileinToDelimitedProcess<FileInputPositionalNode>(inPositionalNode, outNode);
break;
case FILE_REGEXP:
FileInputRegExpNode inRegExpNode = new FileInputRegExpNode(inPath, description.getRowSeparator(), description.getPattern(), description.getLimitRows(), description.getHeaderRow(), description.getFooterRow(), description.getRemoveEmptyRowsToSkip(), description.getEncoding());
ps = new FileinToDelimitedProcess<FileInputRegExpNode>(inRegExpNode, outNode);
break;
case FILE_XML:
List<Map<String, String>> newmappings = new ArrayList<Map<String, String>>();
List<Map<String, String>> oldmappings = description.getMapping();
for (int i = 0; i < oldmappings.size(); i++) {
Map<String, String> map = oldmappings.get(i);
//$NON-NLS-1$ //$NON-NLS-2$
map.put("SCHEMA_COLUMN", "row" + i);
newmappings.add(map);
}
FileInputXmlNode inXmlNode = new FileInputXmlNode(inPath, description.getLoopQuery(), description.getMapping(), description.getLoopLimit(), description.getEncoding());
ps = new FileinToDelimitedProcess<FileInputXmlNode>(inXmlNode, outNode);
break;
case FILE_EXCEL:
// hywang add for excel 2007
String versionCheck = "false";
String afterRemoveQuotesPath = TalendTextUtils.removeQuotes(inPath);
if (afterRemoveQuotesPath.toLowerCase().endsWith(".xlsx")) {
versionCheck = "true";
}
FileInputExcelNode excelNode = null;
ExcelSchemaBean excelBean = description.getExcelSchemaBean();
excelNode = new FileInputExcelNode(inPath, description.getSchema(), //$NON-NLS-1$
description.getEncoding() == null ? TalendTextUtils.addQuotes("ISO-8859-1") : description.getEncoding(), Integer.toString(description.getLimitRows()), Integer.toString(description.getHeaderRow()), Integer.toString(description.getFooterRow()), Boolean.toString(description.getRemoveEmptyRowsToSkip()), excelBean, versionCheck);
outNode.setMetadataList(excelNode.getMetadataList());
ps = new FileinToDelimitedProcess<FileInputExcelNode>(excelNode, outNode);
break;
case FILE_LDIF:
outNode = new FileOutputDelimitedForLDIF(TalendTextUtils.addQuotes(//$NON-NLS-1$
"" + PathUtils.getPortablePath(outPath.toOSString())), description.getEncoding());
FileInputLdifNode inLdifNode = new FileInputLdifNode(inPath, description.getSchema(), description.getEncoding());
outNode.setMetadataList(inLdifNode.getMetadataList());
ps = new FileinToDelimitedProcess<FileInputLdifNode>(inLdifNode, outNode);
break;
case LDAP_SCHEMA:
// outNode = new FileOutputDelimitedForLDIF(TalendTextUtils.addQuotes(""
// + PathUtils.getPortablePath(outPath.toOSString())), description.getEncoding());
LDAPSchemaInputNode inLDAPSchemaNode = new LDAPSchemaInputNode(TalendTextUtils.addQuotes(//$NON-NLS-1$
"" + PathUtils.getPortablePath(outPath.toOSString())), description.getSchema(), description.getEncoding(), description.getLdapSchemaBean());
List<IMetadataTable> metadataList = inLDAPSchemaNode.getMetadataList();
for (IMetadataTable metadataTable : metadataList) {
// for bug15450
List<IMetadataColumn> listColumns = metadataTable.getListColumns();
for (IMetadataColumn metadataColumn : listColumns) {
String label = metadataColumn.getLabel();
boolean validColumnName = MetadataToolHelper.isValidColumnName(label);
if (!validColumnName) {
metadataColumn.setLabel(label.replaceAll("[^a-zA-Z0-9_]", "_"));
}
}
}
outNode.setMetadataList(metadataList);
ps = new FileinToDelimitedProcess<LDAPSchemaInputNode>(inLDAPSchemaNode, outNode);
break;
case WSDL_SCHEMA:
// outNode = new FileOutputDelimitedForLDIF(TalendTextUtils.addQuotes(""
// + PathUtils.getPortablePath(outPath.toOSString())), description.getEncoding());
WSDLSchemaInputNode inWSDLSchemaNode = new WSDLSchemaInputNode(TalendTextUtils.addQuotes(//$NON-NLS-1$
"" + PathUtils.getPortablePath(outPath.toOSString())), description.getEncoding(), description.getSchema(), description.getWsdlSchemaBean(), description.getWsdlSchemaBean().getParameters());
outNode.setMetadataList(inWSDLSchemaNode.getMetadataList());
ps = new FileinToDelimitedProcess<WSDLSchemaInputNode>(inWSDLSchemaNode, outNode);
break;
case SALESFORCE_SCHEMA:
SalesforceSchemaInputNode inSalesforceNode = new SalesforceSchemaInputNode(description.getSchema(), description.getSalesforceSchemaBean());
outNode.setMetadataList(inSalesforceNode.getMetadataList());
SalesforceSchemaBean salesforceSchemaBean = description.getSalesforceSchemaBean();
boolean uesHttp = salesforceSchemaBean.isUesHttp();
salesforceSchemaBean.isUseProxy();
if (uesHttp) {
String proxyHost = salesforceSchemaBean.getProxyHost();
String proxyPort = salesforceSchemaBean.getProxyPort();
String userName = salesforceSchemaBean.getProxyUsername();
String password = salesforceSchemaBean.getProxyPassword();
final Prejob prejob = new Prejob("");
final SetProxy setProxy = new SetProxy("HTTP_PROXY", proxyHost, proxyPort, userName, password, proxyHost + "|" + proxyPort);
ps = new FileinToDelimitedProcess<SalesforceSchemaInputNode>(inSalesforceNode, outNode, prejob, setProxy);
} else {
ps = new FileinToDelimitedProcess<SalesforceSchemaInputNode>(inSalesforceNode, outNode);
}
break;
default:
break;
}
return ps;
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class FilterColumnDialog method initChecked.
private void initChecked() {
List<ConditionBean> beans = new ArrayList<ConditionBean>();
for (IMetadataColumn column : conn.getMetadataTable().getListColumns()) {
ConditionBean bean = new ConditionBean(column);
bean.setCondition(TracesConnectionUtils.getTracesColumnCondition(conn, column.getLabel()));
beans.add(bean);
}
tabView.setInput(beans);
List<String> enabledTraceColumns = TracesConnectionUtils.getEnabledTraceColumns(conn);
for (TableItem item : tabView.getTable().getItems()) {
Object data = item.getData();
if (data instanceof ConditionBean) {
ConditionBean bean = (ConditionBean) data;
if (enabledTraceColumns.contains(bean.getColumnName())) {
tabView.setChecked(bean, true);
}
}
}
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class PropertiesTableEditorModel method isButtonEnabled.
/**
*
* DOC Added for featerue TDI-7284
*
* @return
*/
public boolean isButtonEnabled() {
if (element instanceof Node && relatedParameter != null) {
Node node = (Node) element;
if (node.getMetadataList() != null && node.getMetadataList().get(0).getListColumns() != null) {
List<IMetadataColumn> columns = node.getMetadataList().get(0).getListColumns();
boolean foundNotExistColumn = false;
for (IMetadataColumn column : columns) {
if (!exist(column.getLabel())) {
foundNotExistColumn = true;
break;
}
}
if (foundNotExistColumn) {
return true;
} else {
return false;
}
}
}
return true;
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class PropertiesTableToolbarEditorView method createAddPushButton.
/*
* (non-Javadoc)
*
* @see org.talend.core.ui.extended.ExtendedToolbarView#createAddPushButton()
*/
@Override
protected AddPushButton createAddPushButton() {
final AddPushButton addPushButton = new AddPushButtonForExtendedTable(this.toolbar, getExtendedTableViewer()) {
@Override
public boolean getEnabledState() {
if (model != null && !model.getElemParameter().getElement().isReadOnly() && (model.getElemParameter().getName().equals("HADOOP_ADVANCED_PROPERTIES") || model.getElemParameter().getName().equals("HBASE_PARAMETERS") || model.getElemParameter().getName().equals("SPARK_ADVANCED_PROPERTIES")) && !model.getElemParameter().isRepositoryValueUsed()) {
return true;
}
return super.getEnabledState() && (model == null || !model.getElemParameter().isBasedOnSubjobStarts());
}
@Override
protected Object getObjectToAdd() {
PropertiesTableEditorModel tableEditorModel = (PropertiesTableEditorModel) getExtendedTableViewer().getExtendedControlModel();
if (!tableEditorModel.isButtonEnabled()) {
MessageDialog.openInformation(tableEditorModel.getTableViewer().getControl().getShell(), "Information", "All output columns have been added already");
return null;
}
Object newEntry = tableEditorModel.createNewEntry();
if (tableEditorModel.isAggregateRow() && newEntry instanceof Map) {
List<ColumnInfo> tableInputs = new ArrayList<ColumnInfo>();
String[] displayNames = tableEditorModel.getElemParameter().getListItemsDisplayName();
Object[] itemsValue = tableEditorModel.getElemParameter().getListItemsValue();
// default name //$NON-NLS-1$
String paramColumnsName = "COLUMN";
for (int i = 0; i < itemsValue.length; i++) {
if (itemsValue[i] instanceof IElementParameter) {
IElementParameter tableParameter = (IElementParameter) itemsValue[i];
if (tableParameter.getFieldType().equals(EParameterFieldType.COLUMN_LIST)) {
paramColumnsName = tableParameter.getName();
} else {
ColumnInfo row = new ColumnInfo();
row.name = displayNames[i];
row.parameter = tableParameter;
row.defaultValue = "";
tableInputs.add(row);
}
}
}
Node node = (Node) tableEditorModel.getElement();
String outputTableName = null;
if (node.getMetadataList() != null && !node.getMetadataList().isEmpty()) {
IMetadataTable metadata = node.getMetadataList().get(0);
if (metadata.getListColumns() != null) {
for (IMetadataColumn column : metadata.getListColumns()) {
if (!tableEditorModel.exist(column.getLabel())) {
outputTableName = column.getLabel();
break;
}
}
}
}
if (outputTableName != null) {
Map mapObject = (Map) newEntry;
if (mapObject.containsKey(paramColumnsName)) {
mapObject.put(paramColumnsName, outputTableName);
}
for (ColumnInfo col : tableInputs) {
Object defaultValue = col.defaultValue;
Object found = findDefaultName(outputTableName, col);
if (found != null && !"".equals(found)) {
defaultValue = found;
}
if (defaultValue != null && !"".equals(defaultValue)) {
mapObject.put(col.parameter.getName(), defaultValue);
}
}
}
}
return newEntry;
}
};
// TDI-6568, after added, fire change
addPushButton.addListener(getPropertyChangeListener(), false);
return addPushButton;
}
Aggregations