use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class ColumnSetAnalysisDetailsPage method recomputeIndicators.
public void recomputeIndicators() {
columnSetAnalysisHandler = new ColumnSetAnalysisHandler();
columnSetAnalysisHandler.setAnalysis(getCurrentModelElement());
stringDataFilter = columnSetAnalysisHandler.getStringDataFilter();
analyzedColumns = columnSetAnalysisHandler.getAnalyzedColumns();
if (columnSetAnalysisHandler.getSimpleStatIndicator() == null || columnSetAnalysisHandler.getSimpleStatIndicator().eIsProxy()) {
ColumnsetFactory columnsetFactory = ColumnsetFactory.eINSTANCE;
simpleStatIndicator = columnsetFactory.createSimpleStatIndicator();
simpleStatIndicator.setRowCountIndicator(IndicatorsFactory.eINSTANCE.createRowCountIndicator());
simpleStatIndicator.setDistinctCountIndicator(IndicatorsFactory.eINSTANCE.createDistinctCountIndicator());
simpleStatIndicator.setDuplicateCountIndicator(IndicatorsFactory.eINSTANCE.createDuplicateCountIndicator());
simpleStatIndicator.setUniqueCountIndicator(IndicatorsFactory.eINSTANCE.createUniqueCountIndicator());
} else {
simpleStatIndicator = (SimpleStatIndicator) columnSetAnalysisHandler.getSimpleStatIndicator();
}
if (columnSetAnalysisHandler.getAllmatchIndicator() == null) {
ColumnsetFactory columnsetFactory = ColumnsetFactory.eINSTANCE;
allMatchIndicator = columnsetFactory.createAllMatchIndicator();
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(allMatchIndicator);
} else {
allMatchIndicator = (AllMatchIndicator) columnSetAnalysisHandler.getAllmatchIndicator();
}
initializeIndicator(simpleStatIndicator);
List<ModelElementIndicator> meIndicatorList = new ArrayList<ModelElementIndicator>();
ModelElementIndicator currentIndicator = null;
for (ModelElement element : analyzedColumns) {
// MOD yyi 2011-02-16 17871:delimitefile
MetadataColumn mdColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(element);
TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
if (tdColumn == null && mdColumn == null) {
continue;
}
if (tdColumn == null && mdColumn != null) {
currentIndicator = ModelElementIndicatorHelper.createDFColumnIndicator(RepositoryNodeHelper.recursiveFind(mdColumn));
} else if (tdColumn != null) {
RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(tdColumn);
if (recursiveFind == null) {
recursiveFind = RepositoryNodeHelper.createRepositoryNode(tdColumn);
}
currentIndicator = ModelElementIndicatorHelper.createModelElementIndicator(recursiveFind);
}
DataminingType dataminingType = MetadataHelper.getDataminingType(element);
MetadataHelper.setDataminingType(dataminingType == null ? DataminingType.NOMINAL : dataminingType, element);
Collection<Indicator> indicatorList = columnSetAnalysisHandler.getRegexMathingIndicators(element);
if (null != currentIndicator) {
currentIndicator.setIndicators(indicatorList.toArray(new Indicator[indicatorList.size()]));
meIndicatorList.add(currentIndicator);
}
}
currentModelElementIndicators = meIndicatorList.toArray(new ModelElementIndicator[meIndicatorList.size()]);
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class ColumnSetAnalysisDetailsPage method canSave.
@Override
public ReturnCode canSave() {
// MOD by gdbu 2011-3-21 bug 19179
ReturnCode canModRetCode = super.canSave();
if (!canModRetCode.isOk()) {
return canModRetCode;
}
// ~19179
String message = null;
List<IRepositoryNode> columnSetMultiValueList = this.treeViewer.getColumnSetMultiValueList();
// MOD yyi 2011-02-16 17871:delimitefile
List<ModelElement> columnList = new ArrayList<ModelElement>();
// MOD klliu 2001-03-28 19464 filter column from same table
Set<EObject> nodeTypeName = new HashSet<EObject>();
for (IRepositoryNode rd : columnSetMultiValueList) {
ModelElement modelElementFromRepositoryNode = RepositoryNodeHelper.getModelElementFromRepositoryNode(rd);
EObject eContainer = modelElementFromRepositoryNode.eContainer();
nodeTypeName.add(eContainer);
columnList.add(RepositoryNodeHelper.getModelElementFromRepositoryNode(rd));
}
if (nodeTypeName.size() > 1) {
// $NON-NLS-1$
return new ReturnCode(DefaultMessagesImpl.getString("ColumnSetMasterPage.CannotCreateAnalysis"), false);
}
if (!columnSetMultiValueList.isEmpty()) {
// MOD klliu bug 19464,file delimit connection does not need to check from one table.
if (columnList.get(0) instanceof TdColumn) {
if (!ModelElementHelper.isFromSameTable(columnList)) {
// $NON-NLS-1$
message = DefaultMessagesImpl.getString("ColumnSetMasterPage.CannotCreateAnalysis");
}
} else if (columnList.get(0) instanceof MetadataColumn) {
if (!isFromSameTableByDFColumn(columnSetMultiValueList)) {
// $NON-NLS-1$
message = DefaultMessagesImpl.getString("ColumnSetMasterPage.CannotCreateAnalysis");
}
}
}
if (message == null) {
resetResultPageData();
return new ReturnCode(true);
}
return new ReturnCode(message, false);
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class AbstractAnalysisMetadataPage method createExecuteEngineSection.
/**
* Extracted from the column and column set master page, to create the execution language selection section
*
* @param form1
* @param anasisDataComp
* @param analyzedColumns
* @param anaParameters
* @return
*/
protected Composite createExecuteEngineSection(final ScrolledForm form1, Composite anasisDataComp, EList<ModelElement> analyzedColumns, AnalysisParameters anaParameters) {
analysisParamSection = createSection(form1, anasisDataComp, DefaultMessagesImpl.getString("ColumnMasterDetailsPage.AnalysisParameter"), // $NON-NLS-1$
null);
Composite sectionClient = toolkit.createComposite(analysisParamSection);
sectionClient.setLayout(new GridLayout(1, false));
Composite comp1 = new Composite(sectionClient, SWT.NONE);
this.createAnalysisLimitComposite(comp1);
Composite comp2 = new Composite(sectionClient, SWT.NONE);
comp2.setLayout(new GridLayout(2, false));
GridDataFactory.fillDefaults().grab(true, true).applyTo(comp2);
// $NON-NLS-1$
toolkit.createLabel(comp2, DefaultMessagesImpl.getString("ColumnMasterDetailsPage.ExecutionEngine"));
// MOD zshen:need to use the component with finish indicator Selection.
execCombo = new CCombo(comp2, SWT.BORDER);
// ~
execCombo.setEditable(false);
// run with sample data mode only used by java engin
if (this.isRunWithSampleData) {
execCombo.setEnabled(false);
}
for (ExecutionLanguage language : ExecutionLanguage.VALUES) {
String temp = language.getLiteral();
execCombo.add(temp);
}
// MOD qiongli 2011-3-17 set DataFilterText disabled except TdColumn.
if (analyzedColumns != null && !analyzedColumns.isEmpty()) {
ModelElement mod = analyzedColumns.get(0);
TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(mod);
dataFilterComp.getDataFilterText().setEnabled((tdColumn != null) ? true : false);
if (tdColumn == null) {
dataFilterComp.getDataFilterText().setEnabled(false);
changeExecuteLanguageToJava(true);
}
}
ExecutionLanguage executionLanguage = getCurrentModelElement().getParameters().getExecutionLanguage();
execLang = executionLanguage.getLiteral();
execCombo.setText(execLang);
// ADD xqliu 2009-08-24 bug 8776
setLanguageToTreeViewer(ExecutionLanguage.get(execLang));
// ~
// MOD msjian TDQ-9467: this part is only for column analysis
createDrillDownPart(anaParameters, comp2, executionLanguage);
analysisParamSection.setClient(sectionClient);
return comp2;
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class MultiColAnalysisCreationTest method getColumns.
/**
* DOC scorreia Comment method "getColumn".
*
* @param dataManager
* @return
* @throws Exception
*/
private List<TdColumn> getColumns(Connection dataManager) throws Exception {
List<Catalog> tdCatalogs = CatalogHelper.getCatalogs(dataManager.getDataPackage());
Catalog catalog = null;
for (Catalog tdCatalog : tdCatalogs) {
if (CATALOG.equals(tdCatalog.getName())) {
catalog = tdCatalog;
break;
}
}
Assert.assertNotNull(catalog);
Assert.assertFalse(tdCatalogs.isEmpty());
// $NON-NLS-1$
System.out.println("analysed Catalog: " + catalog.getName());
List<TdTable> tables = DqRepositoryViewService.getTables(dataManager, catalog, TABLE, true, false);
// store tables in catalog
CatalogHelper.addTables(tables, catalog);
Assert.assertFalse(tables.isEmpty());
TdTable tdTable = tables.get(0);
// $NON-NLS-1$
System.out.println("analyzed Table: " + tdTable.getName());
List<TdColumn> columns;
columns = DqRepositoryViewService.getColumns(dataManager, tdTable, null, true);
// MOD scorreia 2009-01-29 columns are stored in the table
// TableHelper.addColumns(tdTable, columns);
Assert.assertFalse(columns.isEmpty());
List<TdColumn> usedCols = new ArrayList<TdColumn>();
for (TdColumn tdColumn : columns) {
for (String c : COLUMNS) {
if (tdColumn.getName().equals(c)) {
usedCols.add(tdColumn);
}
}
}
// set DM type for each used column
for (TdColumn tdColumn : usedCols) {
final int javaType = tdColumn.getJavaType();
if (Java2SqlType.isNumbericInSQL(javaType)) {
MetadataHelper.setDataminingType(DataminingType.INTERVAL, tdColumn);
} else if (Java2SqlType.isTextInSQL(javaType)) {
MetadataHelper.setDataminingType(DataminingType.NOMINAL, tdColumn);
}
}
return usedCols;
}
use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.
the class ColumnFolderNode method loadChildren.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.model.nodes.AbstractFolderNode#loadChildren()
*/
@Override
public void loadChildren() {
// MOD xqliu 2009-04-27 bug 6507
// get columns from either tables or views.
ColumnSet columnSet = SwitchHelpers.COLUMN_SET_SWITCH.doSwitch((EObject) getParent());
if (columnSet != null) {
List<TdColumn> columnList = null;
if (FILTER_FLAG) {
String columnFilter = ColumnHelper.getColumnFilter(columnSet);
columnList = filterColumns(ColumnSetHelper.getColumns(columnSet), columnFilter);
} else {
columnList = ColumnSetHelper.getColumns(columnSet);
}
if (columnList.size() > 0) {
if (columnList.size() > COLUMN_MAX) {
this.setChildren(null);
// $NON-NLS-1$
MessageUI.openWarning(DefaultMessagesImpl.getString("ColumnFolderNode.warnMsg", COLUMN_MAX));
} else {
this.setChildren(columnList.toArray());
}
return;
} else {
if (FILTER_FLAG) {
this.setChildren(null);
if (ColumnSetHelper.getColumns(columnSet).size() > 0) {
return;
}
}
}
if (columnSet.eIsProxy()) {
// resolve the proxy object.
columnSet = (ColumnSet) EObjectHelper.resolveObject(columnSet);
}
Package parentCatalogOrSchema = ColumnSetHelper.getParentCatalogOrSchema(columnSet);
if (parentCatalogOrSchema == null) {
return;
}
Connection conn = ConnectionHelper.getTdDataProvider(parentCatalogOrSchema);
if (conn == null) {
return;
}
try {
columnList = DqRepositoryViewService.getColumns(conn, columnSet, null, true);
if (columnList.size() > COLUMN_MAX) {
this.setChildren(null);
// $NON-NLS-1$
MessageUI.openWarning(DefaultMessagesImpl.getString("ColumnFolderNode.warnMsg", COLUMN_MAX));
return;
}
} catch (Exception e) {
MessageBoxExceptionHandler.process(e);
}
// store tables in catalog
// MOD scorreia 2009-01-29 columns are stored in the table
// ColumnSetHelper.addColumns(columnSet, columnList);
this.setChildren(columnList.toArray());
ElementWriterFactory.getInstance().createDataProviderWriter().save(conn);
}
super.loadChildren();
// ~
}
Aggregations