use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.
the class FunctionalDependencyAnalysisDetailsPage method validator.
private ReturnCode validator(List<RepositoryNode> columnASet, List<RepositoryNode> columnBSet) {
// MOD by gdbu 2011-3-21 bug 19179
ReturnCode canModRetCode = super.canSave();
if (!canModRetCode.isOk()) {
return canModRetCode;
}
if (columnASet.isEmpty() || columnBSet.isEmpty()) {
// $NON-NLS-1$
return new ReturnCode(DefaultMessagesImpl.getString("ColumnDependencyMasterDetailsPage.columnsBlankMessag"), false);
}
if (columnASet.size() != columnBSet.size()) {
// $NON-NLS-1$
return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.columnsSameMessage"), false);
}
for (int i = 0; i < columnASet.size(); i++) {
RepositoryNode columnANode = columnASet.get(i);
RepositoryNode columnBNode = columnBSet.get(i);
TdColumn tdColumnA = ((DBColumnRepNode) columnANode).getTdColumn();
TdColumn tdColumnB = ((DBColumnRepNode) columnBNode).getTdColumn();
ColumnSet ownerA = ColumnHelper.getColumnOwnerAsColumnSet(tdColumnA);
ColumnSet ownerB = ColumnHelper.getColumnOwnerAsColumnSet(tdColumnB);
String uuidA = ResourceHelper.getUUID(ownerA);
String uuidB = ResourceHelper.getUUID(ownerB);
if (!uuidA.equals(uuidB)) {
// $NON-NLS-1$
return new ReturnCode(DefaultMessagesImpl.getString("ColumnDependencyMasterDetailsPage.tableMessage"), false);
}
}
return new ReturnCode(true);
}
use of org.talend.utils.sugars.ReturnCode 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.utils.sugars.ReturnCode in project tdq-studio-se by Talend.
the class MatchAnalysisDetailsPage method canSave.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#canSave()
*/
@Override
public ReturnCode canSave() {
if (this.isDirty) {
ReturnCode checkResultStatus = blockingKeySection.checkResultStatus();
if (checkResultStatus.isOk()) {
if (selectAlgorithmSection.isVSRMode()) {
checkResultStatus = matchingKeySection.checkResultStatus();
} else {
checkResultStatus = matchAndSurvivorKeySection.checkResultStatus();
if (checkResultStatus.isOk()) {
checkResultStatus = this.defaultSurvivorshipDefinitionSection.checkResultStatus();
}
}
}
if (checkResultStatus.isOk() && !selectAlgorithmSection.isVSRMode()) {
checkResultStatus = this.particularDefaultSurvivorshipSection.checkResultStatus();
}
if (checkResultStatus.isOk()) {
if (TaggedValueHelper.getValueBoolean(SQLExecutor.STORE_ON_DISK_KEY, getCurrentModelElement())) {
if (StringUtils.isBlank(TaggedValueHelper.getValueString(SQLExecutor.TEMP_DATA_DIR, getCurrentModelElement()))) {
checkResultStatus.setOk(false);
// $NON-NLS-1$
checkResultStatus.setMessage(DefaultMessagesImpl.getString("MatchMasterDetailsPage.invalidTempFolder"));
}
}
}
if (!checkResultStatus.isOk()) {
return checkResultStatus;
}
}
return super.canSave();
}
use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.
the class MatchAnalysisDetailsPage method saveAnalysis.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#saveAnalysis()
*/
@Override
protected void saveAnalysis() throws DataprofilerCoreException {
// save the default loaded row count
if (this.isValidateRowCount()) {
analysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
} else {
// $NON-NLS-1$
MessageDialog.openWarning(// $NON-NLS-1$
null, // $NON-NLS-1$
DefaultMessagesImpl.getString("MatchMasterDetailsPage.NotValidate"), // $NON-NLS-1$
DefaultMessagesImpl.getString("MatchMasterDetailsPage.LoadedRowCountError"));
return;
}
analysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
analysisHandler.saveSelectedAnalyzedElements();
TDQAnalysisItem analysisItem = (TDQAnalysisItem) getCurrentRepNode().getObject().getProperty().getItem();
analysisHandler.updateAnaConnRelationship(analysisItem);
this.nameText.setText(analysisHandler.getName());
ReturnCode saved = ElementWriterFactory.getInstance().createAnalysisWrite().save(analysisItem, true);
logSaved(saved);
}
use of org.talend.utils.sugars.ReturnCode 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);
}
Aggregations