use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdq-studio-se by Talend.
the class MatchRuleTableViewer method getCellEditor.
/**
* DOC zshen Comment method "getCellEditor".
*
* @param headers
* @return
*/
@Override
protected CellEditor[] getCellEditor(List<String> headers, List<MetadataColumn> columnList) {
CellEditor[] editors = new CellEditor[headers.size()];
for (int i = 0; i < editors.length; ++i) {
switch(i) {
case // MatchAnalysisConstant.INPUT_COLUMN
1:
String[] cols = new String[columnList.size()];
int idx = 0;
for (MetadataColumn metaCol : columnList) {
cols[idx++] = metaCol.getName() == null ? "" : metaCol.getName();
}
editors[i] = new ComboBoxCellEditor(innerTable, cols, SWT.READ_ONLY);
break;
case // MatchAnalysisConstant.MATCHING_TYPE
2:
editors[i] = new ComboBoxCellEditor(innerTable, AttributeMatcherType.getAllTypes(), SWT.READ_ONLY);
break;
case // MatchAnalysisConstant.CUSTOM_MATCHER
3:
editors[i] = new jarFileCellEditor(innerTable, SWT.READ_ONLY);
break;
case // MatchAnalysisConstant.TOKENIZATION_TYPE
4:
editors[i] = new ComboBoxCellEditor(innerTable, TokenizedResolutionMethod.getAllTypes(), SWT.READ_ONLY);
break;
case // MatchAnalysisConstant.HANDLE_NULL
6:
editors[i] = new ComboBoxCellEditor(innerTable, HandleNullEnum.getAllTypes(), SWT.READ_ONLY);
break;
default:
// MatchAnalysisConstant.MATCH_KEY_NAME and MatchAnalysisConstant.CONFIDENCE_WEIGHT
editors[i] = new TextCellEditor(innerTable);
}
}
return editors;
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdq-studio-se by Talend.
the class ParticularDefaultSurvivorShipCellModifier method modify.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
*/
@Override
public void modify(Object element, String property, Object value) {
if (element instanceof TableItem) {
ParticularDefaultSurvivorshipDefinitions pdskd = (ParticularDefaultSurvivorshipDefinitions) ((TableItem) element).getData();
String newValue = String.valueOf(value);
if (MatchAnalysisConstant.PRECOLUMN.equalsIgnoreCase(property)) {
if (Integer.parseInt(newValue) == -1) {
return;
}
MetadataColumn metadataColumn = columnList.get(Integer.parseInt(newValue));
String columnName = metadataColumn.getName();
if (StringUtils.equals(pdskd.getColumn(), columnName)) {
return;
}
pdskd.setColumn(columnName);
pdskd.setDataType(metadataColumn.getTalendType());
if (isFunctionInvalid(pdskd, metadataColumn.getTalendType())) {
resetFunction(pdskd);
}
} else if (MatchAnalysisConstant.FUNCTION.equalsIgnoreCase(property)) {
SurvivorShipAlgorithmEnum valueByIndex = SurvivorShipAlgorithmEnum.getTypeByIndex(Integer.valueOf(newValue).intValue());
if (StringUtils.equals(pdskd.getFunction().getAlgorithmType(), valueByIndex.getComponentValueName())) {
return;
}
setFunction(pdskd, valueByIndex);
} else if (MatchAnalysisConstant.PARAMETER.equalsIgnoreCase(property)) {
pdskd.getFunction().setAlgorithmParameters(newValue);
} else {
return;
}
tableViewer.update(pdskd, null);
}
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdq-studio-se by Talend.
the class AbstractMatchAnaysisTableSection method setColumnValueIfMatch.
/**
* When import:1) use key's name & key's column to compare, 2) set it empty when no match. If the key's column =
* some column name, keep it; when key's name and key's column both no match, set it empty
*
* @param keyDefinition
*/
protected void setColumnValueIfMatch(KeyDefinition keyDefinition) {
String columnName = StringUtils.EMPTY;
if (this.columnMap != null) {
for (MetadataColumn column : columnMap.keySet()) {
if (StringUtils.equalsIgnoreCase(getColumnName(column), getMappingName(keyDefinition))) {
columnName = column.getLabel();
break;
}
}
}
keyDefinition.setColumn(columnName);
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdq-studio-se by Talend.
the class CreateDateAnalysisAction method isTimeType.
// Added yyin2012-05-14 TDQ-5241
private boolean isTimeType() {
for (IRepositoryNode repositoryNode : getColumns()) {
MetadataColumn column = ((MetadataColumnRepositoryObject) repositoryNode.getObject()).getTdColumn();
int javaSQLType = ((TdColumn) column).getSqlDataType().getJavaDataType();
if (Java2SqlType.isTimeSQL(javaSQLType)) {
return true;
}
}
return false;
}
use of org.talend.core.model.metadata.builder.connection.MetadataColumn in project tdq-studio-se by Talend.
the class SemanticDiscoveryActionProvider method fillContextMenu.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
public void fillContextMenu(IMenuManager menu) {
// MOD mzhao user readonly role on svn repository mode.
if (!isShowMenu()) {
return;
}
TreeSelection currentSelection = ((TreeSelection) this.getContext().getSelection());
Object firstElement = currentSelection.getFirstElement();
boolean selectedMoreThanOne = currentSelection.size() > 1;
// keep all of columns belong to same one table and create SemanticDiscoveryAction.
if (selectedMoreThanOne || firstElement instanceof ColumnRepNode) {
Set<String> currentTableSet = new HashSet<String>();
MetadataTable createTable = ConnectionFactory.eINSTANCE.createMetadataTable();
List<String> filterNames = new ArrayList<String>();
Iterator<Object> columnIterator = currentSelection.iterator();
while (columnIterator.hasNext()) {
Object columnNode = columnIterator.next();
MetadataColumn metadataColumn = null;
if (DBColumnRepNode.class.isInstance(columnNode)) {
metadataColumn = ((DBColumnRepNode) columnNode).getTdColumn();
createTable = ColumnHelper.getColumnOwnerAsMetadataTable(metadataColumn);
} else if (DFColumnRepNode.class.isInstance(columnNode)) {
metadataColumn = ((DFColumnRepNode) columnNode).getMetadataColumn();
createTable = ColumnHelper.getColumnOwnerAsMetadataTable(metadataColumn);
} else {
// If not all of elements which be selected is columns
return;
}
currentTableSet.add(ResourceHelper.getUUID(createTable));
// all of columns should come from same table
if (currentTableSet.size() > 1) {
return;
}
filterNames.add(metadataColumn.getName());
}
MetadataTable metadataTableWithFilter = new MetadataTableWithFilter(filterNames, createTable);
semanticDiscoveryAction = new SemanticDiscoveryAction(metadataTableWithFilter);
} else {
// otherwise the selection is valid, only two possible status: only one columnset is select.
if (firstElement instanceof DBTableRepNode) {
DBTableRepNode node = (DBTableRepNode) firstElement;
semanticDiscoveryAction = new SemanticDiscoveryAction(node.getTdTable());
} else if (firstElement instanceof DBViewRepNode) {
DBViewRepNode node = (DBViewRepNode) firstElement;
semanticDiscoveryAction = new SemanticDiscoveryAction(node.getTdView());
} else if (firstElement instanceof DFTableRepNode) {
DFTableRepNode node = (DFTableRepNode) firstElement;
semanticDiscoveryAction = new SemanticDiscoveryAction(node.getMetadataTable());
}
}
menu.add(semanticDiscoveryAction);
}
Aggregations