use of org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry in project tdi-studio-se by Talend.
the class MapperManager method addNewColumnEntry.
/**
* This method is called when "addMetadataTableEditorEntry" is called (event on list of MetadataEditor) , so if you
* want keep synchronisation between inputs/outputs DataMaps and MetadataEditors don't call this method.
*
* @param dataMapTableView
* @param metadataColumn, can be null if added in VarsTable
* @param index
*/
public IColumnEntry addNewColumnEntry(DataMapTableView dataMapTableView, IMetadataColumn metadataColumn, Integer index) {
IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
IColumnEntry dataMapTableEntry = null;
if (dataMapTableView.getZone() == Zone.INPUTS) {
dataMapTableEntry = new InputColumnTableEntry(abstractDataMapTable, metadataColumn);
} else if (dataMapTableView.getZone() == Zone.OUTPUTS) {
dataMapTableEntry = new OutputColumnTableEntry(abstractDataMapTable, metadataColumn);
} else {
//$NON-NLS-1$
throw new IllegalArgumentException(Messages.getString("MapperManager.exceptionMessage.useOtherSignature"));
}
tableEntriesManager.addTableEntry(dataMapTableEntry, index);
return dataMapTableEntry;
}
use of org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry in project tdi-studio-se by Talend.
the class LinkManager method unregisterLevelForRemovedLink.
/**
* DOC amaumont Comment method "unregisterLevelForRemovedLink".
*
* @param link
* @param sourceGraphicalLinks
*/
protected void unregisterLevelForRemovedLink(IMapperLink link, Set<IMapperLink> sourceGraphicalLinks) {
ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
boolean hasSameZone = link.getPointLinkDescriptor1().getTableEntry().getClass() == targetEntry.getClass();
if (hasSameZone) {
boolean isInput = targetEntry instanceof InputColumnTableEntry;
boolean isOutput = targetEntry instanceof OutputColumnTableEntry;
List<List<IMapperLink>> leveledLinks = null;
if (isInput) {
leveledLinks = getInputLinksForLevels();
}
if (isOutput) {
leveledLinks = getOutputLinksForLevels();
}
boolean breakAll = false;
int lstSize = leveledLinks.size();
for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
int lstSizeInternal = linksFromLevelsList.size();
for (int i = 0; i < lstSizeInternal; i++) {
IMapperLink currentLink = linksFromLevelsList.get(i);
if (currentLink == link) {
linksFromLevelsList.remove(i);
if (linksFromLevelsList.size() == 0) {
leveledLinks.set(indexOfLeveledLink, null);
}
breakAll = true;
break;
}
}
// for (int i = 0; i < lstSizeInternal; i++) {
if (breakAll) {
break;
}
}
}
// for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
}
}
use of org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry in project tdi-studio-se by Talend.
the class ProblemsManager method checkProblemsForTableEntry.
public void checkProblemsForTableEntry(ITableEntry tableEntry, boolean forceRefreshData) {
// if (forceRefreshData) {
// mapperManager.getComponent().refreshMapperConnectorData();
// checkProblems();
// }
List<Problem> problems = new ArrayList<Problem>(0);
String expression = tableEntry.getExpression();
if (tableEntry instanceof InputColumnTableEntry) {
InputColumnTableEntry inputEntry = (InputColumnTableEntry) tableEntry;
IDbOperatorManager operatorsManager = mapperManager.getCurrentLanguage().getOperatorsManager();
IDbOperator dbOperator = operatorsManager.getOperatorFromValue(inputEntry.getOperator());
boolean operatorIsSet = dbOperator != null;
boolean expressionIsSet = expression != null && expression.trim().length() > 0;
Problem problem = null;
String errorMessage = null;
String key = null;
if (!operatorIsSet && expressionIsSet) {
errorMessage = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"ProblemsManager.operatorNotSet", new Object[] { inputEntry.getName() });
key = KEY_OPERATOR_EMPTY;
problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
problem.setKey(key);
problems.add(problem);
}
if (operatorIsSet && !expressionIsSet && !dbOperator.isMonoOperand()) {
errorMessage = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"ProblemsManager.inputExpressionEmpty", new Object[] { inputEntry.getParentName(), inputEntry.getName() });
key = KEY_INPUT_EXPRESSION_EMPTY;
problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
problem.setKey(key);
problems.add(problem);
}
Problem warningProblem = null;
if (inputEntry.isUnmatchingEntry()) {
InputTable inputTable = (InputTable) inputEntry.getParent();
String message = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"ProblemsManager.entryDoesntMatch", new Object[] { inputEntry.getParentName(), inputEntry.getName(), inputTable.getTableName() });
warningProblem = new Problem(null, message, ProblemStatus.WARNING);
warningProblem.setKey(KEY_NO_MATCHING);
problems.add(warningProblem);
}
} else if (tableEntry instanceof OutputColumnTableEntry) {
String errorMessage = null;
Problem problem = null;
if (expression == null || EMPTY_STRING.equals(expression.trim())) {
errorMessage = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"ProblemsManager.outputExpressionEmpty", new Object[] { tableEntry.getParentName(), tableEntry.getName() });
}
if (errorMessage != null) {
problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
problem.setKey(KEY_OUTPUT_EXPRESSION_EMPTY);
problems.add(problem);
}
}
tableEntry.setProblems(problems.size() > 0 ? problems : null);
}
use of org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry in project tdi-studio-se by Talend.
the class OutputDataMapTableView method initColumnsOfTableColumns.
@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
//$NON-NLS-1$
column.setTitle(Messages.getString("OutputDataMapTableView.columnTitle.expression"));
column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {
@Override
public String get(OutputColumnTableEntry bean) {
return bean.getExpression();
}
@Override
public void set(OutputColumnTableEntry bean, String value) {
bean.setExpression(value);
mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
tableViewerCreatorForColumns.getTableViewer().refresh(bean);
}
});
column.setModifiable(true);
//$NON-NLS-1$
column.setDefaultInternalValue("");
createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS, Zone.OUTPUTS }, false);
column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
column.setTitle(DataMapTableView.COLUMN_NAME);
column.setId(DataMapTableView.ID_NAME_COLUMN);
column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {
@Override
public String get(OutputColumnTableEntry bean) {
return bean.getMetadataColumn().getLabel();
}
@Override
public void set(OutputColumnTableEntry bean, String value) {
bean.getMetadataColumn().setLabel(value);
}
});
column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
}
use of org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry 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