use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class RowGeneratorComponent method getComponentDocumentation.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.process.IExternalNode#getComponentDocumentation(java.lang.String, java.lang.String)
*/
@Override
public IComponentDocumentation getComponentDocumentation(String componentName, String tempFolderPath) {
RowGeneratorComponentDocumentation componentDocumentation = new RowGeneratorComponentDocumentation();
componentDocumentation.setComponentName(componentName);
componentDocumentation.setTempFolderPath(tempFolderPath);
componentDocumentation.setPreviewPicPath(HTMLDocUtils.getPreviewPicPath(this));
componentDocumentation.setExternalNode(getExternalNode());
// Added parameters, preview and functions value.
for (IMetadataTable table : this.metadataListOut) {
try {
this.convert(table);
} catch (Exception e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
}
componentDocumentation.setMetadataListOut(this.metadataListOut);
return componentDocumentation;
}
use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class ScdManager method createOutputSchema.
/**
* DOC chuang Comment method "createOutputSchema".
*
* @param unusedFields
*/
public void createOutputSchema() {
// adding the surrogate Keys column
Map<String, IMetadataColumn> surrogateKeysColumnMap = new HashMap<String, IMetadataColumn>();
List<IMetadataColumn> outputColumnsAll = getOutputColumns(component);
for (IMetadataColumn column : outputColumnsAll) {
if (column.isKey()) {
surrogateKeysColumnMap.put(column.getLabel(), column);
break;
}
}
// the unused columns must not be present in the output schema and also
// remove all generated column from
// output schema
Map<String, IMetadataColumn> outputColumns = removeUnusedAndGeneratedColumns(component.getMetadataList(), unusedFields);
IMetadataTable schema = component.getMetadataList().get(0);
// adding all used columns to output schema
Map<String, IMetadataColumn> inputColumnsMap = new HashMap<String, IMetadataColumn>();
List<IMetadataColumn> inputColumns = getInputColumns(component);
for (IMetadataColumn column : inputColumns) {
inputColumnsMap.put(column.getLabel(), column);
if (!unusedFields.contains(column.getLabel()) && outputColumns.get(column.getLabel()) == null) {
schema.getListColumns().add(cloneColumn(column, column.getLabel()));
}
}
// "current value" column
if (type3Table != null) {
for (Type3Field type3 : type3Table) {
if (outputColumns.get(type3.getPreviousValue()) != null || StringUtils.isEmpty(type3.getPreviousValue())) {
continue;
}
IMetadataColumn column = inputColumnsMap.get(type3.getCurrentValue());
IMetadataColumn previous = cloneColumn(column, type3.getPreviousValue());
outputColumns.put(previous.getLabel(), previous);
schema.getListColumns().add(previous);
}
}
// removeVersionFieldsFromOutput(outputColumns, schema, new String[] {
// versionData.getStartName(),
// versionData.getEndName(),
// versionData.getVersionName(), versionData.getActiveName() });
// for versionning columns {start, end} are datetime data type, version
// is an integer, active is a
// boolean
ECodeLanguage lang = LanguageManager.getCurrentLanguage();
if (type2Table != null && !type2Table.isEmpty()) {
// start date
IMetadataColumn startColumn = createMetadataColumn(outputColumns, schema, versionData.getStartName(), Date.class, lang);
if (startColumn != null) {
startColumn.setCustomId(1);
startColumn.setCustom(true);
}
// end date
IMetadataColumn endColumn = createMetadataColumn(outputColumns, schema, versionData.getEndName(), Date.class, lang);
if (endColumn != null) {
endColumn.setNullable(true);
endColumn.setCustomId(2);
endColumn.setCustom(true);
}
if (versionData.isVersionChecked()) {
IMetadataColumn versionColumn = createMetadataColumn(outputColumns, schema, versionData.getVersionName(), Integer.class, lang);
if (versionColumn != null) {
versionColumn.setCustomId(3);
versionColumn.setCustom(true);
}
}
if (versionData.isActiveChecked()) {
IMetadataColumn activeColumn = createMetadataColumn(outputColumns, schema, versionData.getActiveName(), Boolean.class, lang);
if (activeColumn != null) {
activeColumn.setCustomId(4);
activeColumn.setCustom(true);
}
}
}
fixKeyColumnsInOutputSchema(schema, inputColumnsMap, surrogateKeysColumnMap, lang);
// removed by TDI-30934
// sort column by name
// Collections.sort(schema.getListColumns(), new Comparator<IMetadataColumn>() {
//
// public int compare(IMetadataColumn o1, IMetadataColumn o2) {
//
// return o1.getLabel().compareTo(o2.getLabel());
// }
//
// });
}
use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class ScdManager method getInputColumns.
public List<IMetadataColumn> getInputColumns(INode node) {
List<IMetadataColumn> inputSchema = Collections.emptyList();
List<? extends IConnection> incomingConnections = node.getIncomingConnections();
if (incomingConnections != null && incomingConnections.size() > 0) {
for (IConnection incomingConnection : incomingConnections) {
if (incomingConnection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
IMetadataTable schemaTable = incomingConnection.getMetadataTable();
if (schemaTable != null) {
inputSchema = schemaTable.getListColumns();
}
}
}
}
return inputSchema;
}
use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class EntryContentProposal method getDescription.
@Override
public String getDescription() {
StringBuilder sb = new StringBuilder();
//$NON-NLS-1$
String separator = " - ";
if (entry instanceof TreeNode) {
TreeNode inputEntry = (TreeNode) entry;
IMetadataColumn metadataColumn = null;
if (inputEntry.eContainer() instanceof InputXmlTree) {
InputXmlTree tree = (InputXmlTree) inputEntry.eContainer();
List<IODataComponent> inputs = mapperManager.getMapperComponent().getIODataComponents().getInputs();
IMetadataTable table = null;
for (int i = 0; i < inputs.size(); i++) {
IODataComponent ioDataComponent = inputs.get(i);
if (tree.getName() != null && tree.getName().equals(ioDataComponent.getConnection().getName())) {
table = ioDataComponent.getTable();
break;
}
}
if (table != null && table.getListColumns() != null) {
for (IMetadataColumn column : table.getListColumns()) {
if (inputEntry.getName().equals(column.getLabel())) {
metadataColumn = column;
}
}
}
}
//$NON-NLS-1$ //$NON-NLS-2$
sb.append(Messages.getString("EntryContentProposal.metadataColumn")).append(" '").append(inputEntry.getName()).append(//$NON-NLS-1$
"' ");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sb.append(Messages.getString("EntryContentProposal.properties"));
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.column")).append(inputEntry.getName());
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.key")).append(inputEntry.isKey());
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.type")).append(format(inputEntry.getType()));
if (metadataColumn != null) {
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.length"));
if (metadataColumn.getLength() != null && metadataColumn.getLength() > 0) {
sb.append(format(metadataColumn.getLength()));
}
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.precision"));
if (metadataColumn.getPrecision() != null && metadataColumn.getPrecision() > 0) {
sb.append(format(metadataColumn.getPrecision()));
}
sb.append(CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.default")).append(//$NON-NLS-1$
format(metadataColumn.getDefault()));
sb.append(CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.comment")).append(//$NON-NLS-1$
format(metadataColumn.getComment()));
}
sb.append(CARRIAGE_RETURN);
if (inputEntry.eContainer() instanceof TreeNode) {
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.xPath")).append(inputEntry.getXpath());
sb.append(CARRIAGE_RETURN);
}
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
sb.append(CARRIAGE_RETURN);
sb.append(format(entry.getExpression()));
sb.append(CARRIAGE_RETURN);
} else if (entry instanceof VarNode) {
//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
sb.append(Messages.getString("EntryContentProposal.variable")).append(" '").append(entry.getName()).append("' :");
sb.append(CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
sb.append(CARRIAGE_RETURN);
sb.append(format(entry.getExpression()));
}
return sb.toString();
}
use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class GenericUpdateManager method getDeletedOrReselectTablesMap.
@Override
public Map<String, EUpdateResult> getDeletedOrReselectTablesMap() {
Map<String, EUpdateResult> drMap = new HashMap<>();
List<IMetadataTable> newTables = getConversionMetadataTables(connectionItem.getConnection());
for (IMetadataTable oldTable : oldMetadataTable) {
String prefix = connectionItem.getProperty().getId() + UpdatesConstants.SEGMENT_LINE;
boolean isDeleted = true;
String oldtableLabel = oldTable.getLabel();
String oldtableId = oldTable.getId();
for (IMetadataTable newTable : newTables) {
String tableLabel = newTable.getLabel();
String tableId = newTable.getId();
if (tableLabel.equals(oldtableLabel)) {
isDeleted = false;
/* if table name is same but tableId is not same,means table has been deselect and reselect */
if (!tableId.equals(oldtableId)) {
// don't handle reload for generic
// drMap.put(prefix + tableLabel, EUpdateResult.RELOAD);
}
}
}
/* if can't find the name when looping the new tables,means the table has been removed */
if (isDeleted) {
drMap.put(prefix + oldtableLabel, EUpdateResult.DELETE);
}
}
return drMap;
}
Aggregations