use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.
the class ColumnAnalysisDetailsPage method canSave.
@Override
public ReturnCode canSave() {
// MOD by gdbu 2011-3-21 bug 19179
ReturnCode canModRetCode = super.canSave();
if (!canModRetCode.isOk()) {
return canModRetCode;
}
// ~19179
List<ModelElement> analyzedElement = new ArrayList<ModelElement>();
for (ModelElementIndicator modelElementIndicator : treeViewer.getModelElementIndicator()) {
IRepositoryViewObject modelElementRepositoryObj = modelElementIndicator.getModelElementRepositoryNode().getObject();
if (modelElementRepositoryObj instanceof MetadataColumnRepositoryObject) {
analyzedElement.add(((MetadataColumnRepositoryObject) modelElementRepositoryObj).getTdColumn());
}
}
if (!analyzedElement.isEmpty()) {
if (!ModelElementHelper.isFromSameTable(analyzedElement) && !"".equals(dataFilterComp.getDataFilterString())) {
// $NON-NLS-1$
return new ReturnCode(DefaultMessagesImpl.getString("ColumnMasterDetailsPage.CannotCreatAnalysis"), false);
}
}
if (!this.isValidateRowCount()) {
// $NON-NLS-1$
return new ReturnCode(DefaultMessagesImpl.getString("MatchMasterDetailsPage.LoadedRowCountError"), false);
}
return new ReturnCode(true);
}
use of org.talend.utils.sugars.ReturnCode 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.utils.sugars.ReturnCode in project tdq-studio-se by Talend.
the class AbstractAnalysisMetadataPage method doSave.
@Override
public void doSave(IProgressMonitor monitor) {
ReturnCode rc = canSave();
if (!rc.isOk()) {
// MOD yyi 2012-02-29 TDQ-3605 Pop an error if rc is not ok.
MessageDialogWithToggle.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("AbstractAnalysisMetadataPage.SaveAnalysis"), // $NON-NLS-1$
rc.getMessage());
return;
} else if (!checkWhithspace()) {
MessageDialogWithToggle.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("AbstractAnalysisMetadataPage.SaveAnalysis"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("AbstractMetadataFormPage.whitespace"));
} else {
super.doSave(monitor);
try {
// SaveContext
saveContext();
saveAnalysis();
this.isDirty = false;
// MOD qiongli bug 0012766,2010-5-31:After change to another connection
// which has same columns with before,the editor should not
// dirty.
((AnalysisEditor) this.getEditor()).firePropertyChange(IEditorPart.PROP_DIRTY);
this.updateAnalysisConnectionVersionInfo();
} catch (DataprofilerCoreException e) {
MessageDialogWithToggle.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("AbstractAnalysisMetadataPage.SaveAnalysis"), // $NON-NLS-1$
e.getMessage());
ExceptionHandler.process(e, Level.ERROR);
}
}
}
use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.
the class AbstractMetadataFormPage method canModifyName.
/**
* check if the nameText is a dupilcate name.
*
* @return
*/
protected ReturnCode canModifyName(ERepositoryObjectType objectType) {
String elementName = this.nameText.getText();
Property oldProperty = null;
oldProperty = getProperty();
ReturnCode ret = new ReturnCode();
if (oldProperty == null || objectType == null) {
return ret;
}
if (PluginConstant.EMPTY_STRING.equals(elementName.trim())) {
this.nameText.setText(oldProperty.getDisplayName());
// $NON-NLS-1$
String NAMECONNOTBEEMPTY = DefaultMessagesImpl.getString("AbstractMetadataFormPage.nameCannotBeEmpty");
ret.setReturnCode(NAMECONNOTBEEMPTY, false);
return ret;
}
// MOD qiongli 2012-2-14 TDQ-4539.compare the name with all items of the specified type.
boolean exist = PropertyHelper.existDuplicateName(elementName, oldProperty.getDisplayName(), objectType);
if (exist) {
Property duplicateObject = PropertyHelper.getDuplicateObject(elementName, objectType);
IPath path = PropertyHelper.getItemPath(duplicateObject);
if (duplicateObject.getItem().getState().isDeleted()) {
// "/S/TDQ_Data Profiling/Reports/s_0.1.rep" to "/S/Recycle Bin/s_0.1.rep"
// $NON-NLS-1$
path = new Path(path.segment(0)).append(new Path("Recycle Bin")).append(path.lastSegment());
}
ret.setReturnCode(DefaultMessagesImpl.getString("UIMessages.ItemExistsErrorWithParameter", elementName, path.toOSString()), // $NON-NLS-1$
false);
return ret;
}
return ret;
}
use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.
the class AbstractFilterMetadataPage method saveAnalysis.
@Override
public void saveAnalysis() throws DataprofilerCoreException {
// ADD xqliu 2010-01-04 bug 10190
if (isConnectionAnalysis()) {
// MOD zshen 2010-03-19 bug 12041
AnalysisHelper.setReloadDatabases(getCurrentModelElement(), reloadDatabasesBtn.getSelection());
}
// ~
EList<Domain> dataFilters = getCurrentModelElement().getParameters().getDataFilter();
if (!this.tableFilterText.getText().equals(DomainHelper.getTablePattern(dataFilters))) {
DomainHelper.setDataFilterTablePattern(dataFilters, tableFilterText.getText());
latestTableFilterValue = this.tableFilterText.getText();
}
if (!this.viewFilterText.getText().equals(DomainHelper.getViewPattern(dataFilters))) {
DomainHelper.setDataFilterViewPattern(dataFilters, viewFilterText.getText());
latestViewFilterValue = this.viewFilterText.getText();
}
// 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);
}
Aggregations