use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class FunctionalDependencyAnalysisDetailsPage method saveAnalysis.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#saveAnalysis()
*/
@Override
protected void saveAnalysis() throws DataprofilerCoreException {
analysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
analysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
domain.setName(getCurrentModelElement().getName());
}
IRepositoryViewObject reposObject = null;
getAnalysisHandler().clearAnalysis();
List<RepositoryNode> columnListAANode = anaColumnCompareViewer.getColumnListA();
List<RepositoryNode> columnListBBNode = anaColumnCompareViewer.getColumnListB();
AnalysisBuilder anaBuilder = new AnalysisBuilder();
anaBuilder.setAnalysis(getCurrentModelElement());
Connection tdDataProvider = null;
for (int i = 0; i < columnListAANode.size(); i++) {
if (columnListBBNode.size() > i) {
ColumnDependencyIndicator indicator = ColumnsetFactory.eINSTANCE.createColumnDependencyIndicator();
TdColumn columnA = (TdColumn) ((MetadataColumnRepositoryObject) columnListAANode.get(i).getObject()).getTdColumn();
TdColumn columnB = (TdColumn) ((MetadataColumnRepositoryObject) columnListBBNode.get(i).getObject()).getTdColumn();
indicator.setColumnA(columnA);
indicator.setColumnB(columnB);
indicator.setIndicatorDefinition(DefinitionHandler.getInstance().getFDRuleDefaultIndicatorDefinition());
getCurrentModelElement().getResults().getIndicators().add(indicator);
anaBuilder.addElementToAnalyze(columnA, indicator);
// ADD this line qiongli 2010-6-8
anaBuilder.addElementToAnalyze(columnB, indicator);
}
}
if (columnListAANode.size() > 0) {
reposObject = columnListAANode.get(0).getObject();
tdDataProvider = ((ConnectionItem) reposObject.getProperty().getItem()).getConnection();
// MOD qiongli bug 14437:Add dependency
getCurrentModelElement().getContext().setConnection(tdDataProvider);
TypedReturnCode<Dependency> rc = DependenciesHandler.getInstance().setDependencyOn(getCurrentModelElement(), tdDataProvider);
if (!rc.isOk()) {
// $NON-NLS-1$
log.info("fail to save dependency analysis:" + getCurrentModelElement().getFileName());
}
} else {
getCurrentModelElement().getContext().setConnection(null);
}
// save the number of connections per analysis
this.saveNumberOfConnectionsPerAnalysis();
// 2011.1.12 MOD by zhsne to unify anlysis and connection id when saving.
this.nameText.setText(getCurrentModelElement().getName());
// MOD yyi 2012-02-08 TDQ-4621:Explicitly set true for updating dependencies.
ReturnCode saved = ElementWriterFactory.getInstance().createAnalysisWrite().save(getCurrentRepNode().getObject().getProperty().getItem(), true);
// MOD yyi 2012-02-03 TDQ-3602:Avoid to rewriting all analyzes after saving, no reason to update all analyzes
// which is depended in the referred connection.
// Extract saving log function.
// @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#logSaved(ReturnCode)
logSaved(saved);
anaColumnCompareViewer.setDirty(false);
dataFilterComp.setDirty(false);
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class FunctionalDependencyAnalysisDetailsPage method getSelectedColumns.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#getSelectedColumns()
*/
@Override
protected ModelElement[] getSelectedColumns() {
ColumnSet previewDataColumnOwner = anaColumnCompareViewer.getPreviewDataColumnOwner();
if (previewDataColumnOwner == null) {
return null;
}
List<TdColumn> columns = ColumnSetHelper.getColumns(previewDataColumnOwner);
return columns.toArray(new TdColumn[columns.size()]);
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class MatchAnalysisDetailsPage method createDataTableComposite.
/**
* create DataTable Composite.
*
* @param dataparent
*/
private void createDataTableComposite(Composite dataparent) {
dataTableComp = toolkit.createComposite(dataparent);
GridLayout dataTableLayout = new GridLayout(1, Boolean.TRUE);
dataTableComp.setLayout(dataTableLayout);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.heightHint = 250;
dataTableComp.setLayoutData(gridData);
sampleTable = new DataSampleTable();
// use handler to save selected columns
ModelElement[] selectedColumns = getSelectedColumnsFromHandler();
if (selectedColumns != null && selectedColumns.length > 0) {
// use ModelElement instead of node to get the data source type directly.
if (selectedColumns[0] instanceof MetadataColumn && !(selectedColumns[0] instanceof TdColumn)) {
isDelimitedFile = true;
}
createNatTable(new ArrayList<Object[]>());
}
sampleTable.addPropertyChangeListener(this);
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class RedundancyAnalysisDetailsPage method canSave.
@Override
public ReturnCode canSave() {
// MOD by gdbu 2011-3-21 bug 19179
ReturnCode canModRetCode = super.canSave();
if (!canModRetCode.isOk()) {
return canModRetCode;
}
if (anaColumnCompareViewer.getColumnListA().size() != anaColumnCompareViewer.getColumnListB().size()) {
// $NON-NLS-1$
return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.columnsSameMessage"), false);
}
List<TdColumn> columnAList = new ArrayList<TdColumn>();
List<TdColumn> columnBList = new ArrayList<TdColumn>();
for (RepositoryNode rd : anaColumnCompareViewer.getColumnListA()) {
columnAList.add((TdColumn) ((MetadataColumnRepositoryObject) rd.getObject()).getTdColumn());
}
for (RepositoryNode rd : anaColumnCompareViewer.getColumnListB()) {
columnBList.add((TdColumn) ((MetadataColumnRepositoryObject) rd.getObject()).getTdColumn());
}
if (anaColumnCompareViewer.getColumnListA().size() > 0) {
if (!ColumnHelper.isFromSameTable(columnAList) || !ColumnHelper.isFromSameTable(columnBList)) {
return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.notSameElementMessage"), // $NON-NLS-1$
false);
}
for (int i = 0; i < anaColumnCompareViewer.getColumnListA().size(); i++) {
TdColumn columnA = columnAList.get(i);
TdColumn columnB = columnBList.get(i);
ColumnSet ownerA = ColumnHelper.getColumnOwnerAsColumnSet(columnA);
ColumnSet ownerB = ColumnHelper.getColumnOwnerAsColumnSet(columnB);
int typeA = columnA.getSqlDataType().getJavaDataType();
int typeB = columnB.getSqlDataType().getJavaDataType();
if (!Java2SqlType.isGenericSameType(typeA, typeB)) {
return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.notSameColumnType"), // $NON-NLS-1$
false);
}
if (!ColumnSetHelper.isFromSamePackage(ownerA, ownerB)) {
return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.schemaSameMessage"), // $NON-NLS-1$
false);
}
}
List<TdColumn> allColumns = new ArrayList<TdColumn>();
allColumns.addAll(columnAList);
allColumns.addAll(columnBList);
// MOD scorreia 2009-05-25 allow to compare elements from the same
// table
// if (ColumnHelper.isFromSameTable(allColumns)) {
// return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.TwoSideColumns"), false); //$NON-NLS-1$
// }
}
return new ReturnCode(true);
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class RedundancyAnalysisResultPage method createAnalyzedColumnSetsSection.
private void createAnalyzedColumnSetsSection(Composite parent) {
columnSetSection = createSection(form, parent, DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.analyzedColumnSets"), // $NON-NLS-1$
null);
Composite sectionClient = toolkit.createComposite(columnSetSection);
sectionClient.setLayout(new GridLayout());
sectionClient.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
TableViewer elementsTableViewer = new TableViewer(sectionClient, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
Table table = elementsTableViewer.getTable();
GridDataFactory.fillDefaults().applyTo(table);
((GridData) table.getLayoutData()).heightHint = 240;
((GridData) table.getLayoutData()).widthHint = 600;
table.setHeaderVisible(true);
table.setLinesVisible(true);
table.setDragDetect(true);
// $NON-NLS-1$
table.setToolTipText(DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.dragAndDropToolTip"));
final TableColumn columnHeader1 = new TableColumn(table, SWT.LEAD);
columnHeader1.setWidth(300);
final TableColumn columnHeader2 = new TableColumn(table, SWT.LEAD);
columnHeader2.setWidth(300);
Analysis analysis = this.masterPage.getAnalysisHandler().getAnalysis();
isHasDeactivatedIndicator = analysis.getParameters().getDeactivatedIndicators().size() != 0;
EList<Indicator> indicators = analysis.getResults().getIndicators();
if (indicators.size() != 0) {
rowMatchingIndicatorA = (RowMatchingIndicator) indicators.get(0);
rowMatchingIndicatorB = (RowMatchingIndicator) indicators.get(1);
TdColumn columnA = null;
if (rowMatchingIndicatorA.getColumnSetA().size() > 0) {
columnA = rowMatchingIndicatorA.getColumnSetA().get(0);
if (columnA.eIsProxy()) {
columnA = (TdColumn) EObjectHelper.resolveObject(columnA);
}
}
String columnName = rowMatchingIndicatorA.getColumnSetA().size() > 0 ? ColumnHelper.getColumnOwnerAsColumnSet(columnA).getName() : PluginConstant.EMPTY_STRING;
columnHeader1.setText(columnName.equals(PluginConstant.EMPTY_STRING) ? columnName : DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.elementsFrom", // $NON-NLS-1$
columnName));
TdColumn columnB = null;
if (rowMatchingIndicatorA.getColumnSetB().size() > 0) {
columnB = rowMatchingIndicatorA.getColumnSetB().get(0);
if (columnB.eIsProxy()) {
columnB = (TdColumn) EObjectHelper.resolveObject(columnB);
}
}
columnName = rowMatchingIndicatorA.getColumnSetA().size() > 0 ? ColumnHelper.getColumnOwnerAsColumnSet(columnB).getName() : PluginConstant.EMPTY_STRING;
columnHeader2.setText(columnName.equals(PluginConstant.EMPTY_STRING) ? columnName : DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.elementsFrom", // $NON-NLS-1$
columnName));
}
ColumnPairsViewerProvider provider = new ColumnPairsViewerProvider();
elementsTableViewer.setContentProvider(provider);
elementsTableViewer.setLabelProvider(provider);
elementsTableViewer.setInput(rowMatchingIndicatorA);
columnSetSection.setClient(sectionClient);
}
Aggregations