use of org.talend.designer.mapper.model.tableentry.VarTableEntry in project tdi-studio-se by Talend.
the class EntryContentProposal method getDescription.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.fieldassist.IContentProposal#getDescription()
*/
public String getDescription() {
StringBuilder sb = new StringBuilder();
//$NON-NLS-1$
String separator = " - ";
if (entry instanceof InputColumnTableEntry) {
InputColumnTableEntry inputEntry = (InputColumnTableEntry) entry;
IMetadataColumn metadataColumn = inputEntry.getMetadataColumn();
//$NON-NLS-1$ //$NON-NLS-2$
sb.append(Messages.getString("EntryContentProposal.metadataColumn")).append(" '").append(metadataColumn.getLabel()).append(//$NON-NLS-1$
"' ");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sb.append(Messages.getString("EntryContentProposal.properties"));
sb.append(AbstractLanguage.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.column")).append(metadataColumn.getLabel());
sb.append(AbstractLanguage.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.key")).append(metadataColumn.isKey());
if (!MapperMain.isStandAloneMode()) {
sb.append(AbstractLanguage.CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.type")).append(//$NON-NLS-1$
format(metadataColumn.getTalendType()));
}
sb.append(AbstractLanguage.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(AbstractLanguage.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(AbstractLanguage.CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.default")).append(//$NON-NLS-1$
format(metadataColumn.getDefault()));
sb.append(AbstractLanguage.CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.comment")).append(//$NON-NLS-1$
format(metadataColumn.getComment()));
sb.append(AbstractLanguage.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
sb.append(AbstractLanguage.CARRIAGE_RETURN);
sb.append(format(entry.getExpression()));
sb.append(AbstractLanguage.CARRIAGE_RETURN);
} else if (entry instanceof VarTableEntry) {
//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
sb.append(Messages.getString("EntryContentProposal.variable")).append(" '").append(entry.getName()).append("' :");
sb.append(AbstractLanguage.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
sb.append(AbstractLanguage.CARRIAGE_RETURN);
sb.append(format(entry.getExpression()));
} else if (entry instanceof GlobalMapEntry) {
sb.append(AbstractLanguage.CARRIAGE_RETURN);
sb.append("GlobalMap ");
//$NON-NLS-1$
sb.append(Messages.getString("EntryContentProposal.properties"));
sb.append(AbstractLanguage.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.columnTitle.globalMapKey")).append("' :");
sb.append(entry.getName());
sb.append(AbstractLanguage.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.columnTitle.Expr")).append("' :");
sb.append(entry.getExpression());
}
return sb.toString();
}
use of org.talend.designer.mapper.model.tableentry.VarTableEntry in project tdi-studio-se by Talend.
the class ExpressionProposalProvider method getVariables.
public List<Variable> getVariables() {
List<Variable> variables = new ArrayList<Variable>();
for (IDataMapTable table : this.tables) {
List<IColumnEntry> dataMapTableEntries = table.getColumnEntries();
for (IColumnEntry entrySource : dataMapTableEntries) {
String variable = null;
if (table instanceof VarsTable) {
variable = entrySource.getExpression();
} else {
variable = LanguageProvider.getCurrentLanguage().getLocation(entrySource.getParentName(), entrySource.getName());
}
String talendType = null;
boolean nullable = true;
if (entrySource instanceof AbstractInOutTableEntry) {
talendType = ((AbstractInOutTableEntry) entrySource).getMetadataColumn().getTalendType();
nullable = ((AbstractInOutTableEntry) entrySource).getMetadataColumn().isNullable();
} else if (entrySource instanceof VarTableEntry) {
talendType = ((VarTableEntry) entrySource).getType();
nullable = ((VarTableEntry) entrySource).isNullable();
}
if (talendType != null) {
if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
boolean exist = false;
for (Variable v : variables) {
if (variable != null && v.getName() != null && v.getName().trim().equals(variable.trim())) {
exist = true;
break;
}
}
if (!exist) {
variables.add(new Variable(variable, JavaTypesManager.getDefaultValueFromJavaIdType(talendType, nullable).toString(), talendType, nullable));
}
} else {
//$NON-NLS-1$
variables.add(new Variable(variable, "", talendType, nullable));
}
}
}
}
return variables;
}
use of org.talend.designer.mapper.model.tableentry.VarTableEntry in project tdi-studio-se by Talend.
the class VarsTable method initFromExternalData.
public void initFromExternalData(ExternalMapperTable externalMapperTable) {
super.initFromExternalData(externalMapperTable);
if (externalMapperTable != null) {
List<ExternalMapperTableEntry> metadataTableEntries = externalMapperTable.getMetadataTableEntries();
if (metadataTableEntries != null) {
for (ExternalMapperTableEntry externalMapperTableEntry : metadataTableEntries) {
VarTableEntry varTableEntry = new VarTableEntry(this, externalMapperTableEntry.getName(), externalMapperTableEntry.getExpression(), externalMapperTableEntry.getType());
// mapperManager.getProblemsManager().checkProblemsForTableEntry(varTableEntry, false);
if (LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA) {
varTableEntry.setNullable(externalMapperTableEntry.isNullable());
}
addColumnEntry(varTableEntry);
}
}
} else {
setMinimized(true);
}
}
use of org.talend.designer.mapper.model.tableentry.VarTableEntry in project tdi-studio-se by Talend.
the class MapperManager method retrieveTableViewerCreator.
public TableViewerCreator retrieveTableViewerCreator(ITableEntry dataMapTableEntry) {
DataMapTableView view = retrieveDataMapTableView(dataMapTableEntry);
TableViewerCreator tableViewerCreator = null;
if (view != null) {
if (dataMapTableEntry instanceof AbstractInOutTableEntry || dataMapTableEntry instanceof VarTableEntry) {
tableViewerCreator = view.getTableViewerCreatorForColumns();
} else if (dataMapTableEntry instanceof FilterTableEntry) {
tableViewerCreator = view.getTableViewerCreatorForFilters();
}
}
return tableViewerCreator;
}
use of org.talend.designer.mapper.model.tableentry.VarTableEntry in project tdi-studio-se by Talend.
the class LinkManager method registerLevelForNewLink.
/**
* DOC amaumont Comment method "registerLevelForNewLink".
*
* @param link
* @param graphicalLinksFromTarget
*/
public void registerLevelForNewLink(IMapperLink link, Set<IMapperLink> graphicalLinksFromTarget) {
boolean hasAlreadyInputTarget = false;
boolean hasAlreadyVarTarget = false;
ITableEntry sourceEntry = link.getPointLinkDescriptor1().getTableEntry();
ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
boolean hasSameZone = sourceEntry.getParent().getClass() == targetEntry.getParent().getClass();
if (hasSameZone) {
boolean isInputTarget = targetEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry || targetEntry instanceof GlobalMapEntry && targetEntry.getParent() instanceof InputTable;
boolean isVarTarget = targetEntry instanceof VarTableEntry;
List<List<IMapperLink>> leveledLinks = null;
if (isInputTarget) {
leveledLinks = getInputLinksForLevels();
}
if (isVarTarget) {
leveledLinks = getVarLinksForLevels();
}
int lstSize = leveledLinks.size();
for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
IMapperLink linkFromLevelsList = linksFromLevelsList.get(0);
ITableEntry sourceTableEntry = linkFromLevelsList.getPointLinkDescriptor1().getTableEntry();
ITableEntry targetTableEntry = linkFromLevelsList.getPointLinkDescriptor2().getTableEntry();
if (targetEntry == targetTableEntry) {
if (sourceTableEntry instanceof InputColumnTableEntry && (targetTableEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry && targetEntry.getParent() instanceof InputTable)) {
hasAlreadyInputTarget = true;
}
if (sourceTableEntry instanceof VarTableEntry && targetTableEntry instanceof VarTableEntry) {
hasAlreadyVarTarget = true;
}
if (hasAlreadyInputTarget || hasAlreadyVarTarget) {
linksFromLevelsList.add(link);
link.setLevel(indexOfLeveledLink + 1);
break;
}
}
}
}
if (isInputTarget && !hasAlreadyInputTarget || isVarTarget && !hasAlreadyVarTarget) {
ArrayList<IMapperLink> list = new ArrayList<IMapperLink>();
int firstEmptyIndex = searchFirstEmptyIndexLeveledList(leveledLinks);
link.setLevel(firstEmptyIndex + 1);
list.add(link);
if (firstEmptyIndex < leveledLinks.size()) {
leveledLinks.set(firstEmptyIndex, list);
} else {
leveledLinks.add(list);
}
}
}
}
Aggregations