use of org.talend.designer.dbmap.model.tableentry.VarTableEntry in project tdi-studio-se by Talend.
the class VarsTable method initFromExternalData.
public void initFromExternalData(ExternalDbMapTable externalMapperTable) {
super.initFromExternalData(externalMapperTable);
if (externalMapperTable != null) {
List<ExternalDbMapEntry> metadataTableEntries = externalMapperTable.getMetadataTableEntries();
if (metadataTableEntries != null) {
for (ExternalDbMapEntry externalMapperTableEntry : metadataTableEntries) {
IColumnEntry varTableEntry = new VarTableEntry(this, externalMapperTableEntry.getName(), externalMapperTableEntry.getExpression(), externalMapperTableEntry.getOperator());
// mapperManager.getProblemsManager().checkProblemsForTableEntry(varTableEntry, false);
addColumnEntry(varTableEntry);
}
}
} else {
setMinimized(true);
}
}
use of org.talend.designer.dbmap.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(DbLanguageConstants.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.column")).append(metadataColumn.getLabel());
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.key")).append(metadataColumn.isKey());
if (!MapperMain.isStandAloneMode()) {
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.type")).append(//$NON-NLS-1$
format(metadataColumn.getTalendType()));
}
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.dbType")).append(//$NON-NLS-1$
format(metadataColumn.getType()));
sb.append(DbLanguageConstants.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(DbLanguageConstants.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(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.default")).append(//$NON-NLS-1$
format(metadataColumn.getDefault()));
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(separator).append(Messages.getString("EntryContentProposal.comment")).append(//$NON-NLS-1$
format(metadataColumn.getComment()));
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(format(entry.getExpression()));
sb.append(DbLanguageConstants.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(DbLanguageConstants.CARRIAGE_RETURN);
//$NON-NLS-1$
sb.append(separator).append(Messages.getString("EntryContentProposal.expressionKey"));
sb.append(DbLanguageConstants.CARRIAGE_RETURN);
sb.append(format(entry.getExpression()));
}
return sb.toString();
}
use of org.talend.designer.dbmap.model.tableentry.VarTableEntry in project tdi-studio-se by Talend.
the class LinkManager method registerLevelForNewLink.
/**
* DOC amaumont Comment method "registerLevelForNewLink".
*
* @param link
* @param graphicalLinksFromTarget
*/
protected 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.getClass() == targetEntry.getClass();
boolean isInput = targetEntry instanceof InputColumnTableEntry;
boolean isOutput = targetEntry instanceof OutputColumnTableEntry;
if (hasSameZone) {
List<List<IMapperLink>> leveledLinks = null;
if (isInput) {
leveledLinks = getInputLinksForLevels();
}
if (isOutput) {
leveledLinks = getOutputLinksForLevels();
}
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) {
hasAlreadyInputTarget = true;
}
if (sourceTableEntry instanceof VarTableEntry && targetTableEntry instanceof VarTableEntry) {
hasAlreadyVarTarget = true;
}
if (hasAlreadyInputTarget || hasAlreadyVarTarget) {
linksFromLevelsList.add(link);
link.setLevel(indexOfLeveledLink + 1);
break;
}
}
}
}
if (isInput && !hasAlreadyInputTarget) {
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