Search in sources :

Example 71 with ReturnCode

use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.

the class Application method start.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
     */
@Override
public Object start(IApplicationContext context) {
    Display display = PlatformUI.createDisplay();
    Shell shell = new Shell(display, SWT.ON_TOP);
    // TDQ-12221: do check before use to make sure can popup the "Connect to TalendForge"
    checkBrowserSupport();
    try {
        boolean accept = openLicenseAndRegister(shell);
        if (!accept) {
            return IApplication.EXIT_OK;
        }
    } catch (BusinessException e) {
        log.error(e.getMessage());
    }
    try {
        if (!CorePlugin.getDefault().isRepositoryInitialized()) {
            ReturnCode rc = CorePlugin.getDefault().initProxyRepository();
            if (!rc.isOk()) {
                // $NON-NLS-1$
                MessageDialog.openError(shell, DefaultMessagesImpl.getString("Application.warring"), rc.getMessage());
                return IApplication.EXIT_OK;
            }
        }
        // Tweaklets.setDefault(WorkbenchImplementation.KEY, new Workbench3xImplementation4CoolBar());
        int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
        if (returnCode == PlatformUI.RETURN_RESTART) {
            return IApplication.EXIT_RESTART;
        }
        return IApplication.EXIT_OK;
    } finally {
        display.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) BusinessException(org.talend.commons.exception.BusinessException) ReturnCode(org.talend.utils.sugars.ReturnCode) Display(org.eclipse.swt.widgets.Display)

Example 72 with ReturnCode

use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.

the class DataThresholdsForm method checkDateFilds.

protected ReturnCode checkDateFilds(String min, String max) {
    ReturnCode rc = new ReturnCode(true);
    String statusLabelText = PluginConstant.EMPTY_STRING;
    if ((!CheckValueUtils.isDateValue(min) && !CheckValueUtils.isEmpty(min)) || (!CheckValueUtils.isDateValue(max) && !CheckValueUtils.isEmpty(max))) {
        rc.setOk(false);
        // $NON-NLS-1$
        statusLabelText += MSG_ONLY_DATE + System.getProperty("line.separator");
    }
    if (CheckValueUtils.isAoverB(min, max)) {
        rc.setOk(false);
        // $NON-NLS-1$
        statusLabelText += UIMessages.MSG_LOWER_LESS_HIGHER + System.getProperty("line.separator");
    }
    rc.setMessage(statusLabelText);
    return rc;
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode)

Example 73 with ReturnCode

use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.

the class IndicatorThresholdsForm method checkFields.

/**
 * yyi 2009-10-29 validate lowerText higherText pLowerText pHigherText. feature:9340: Set indicator thresholds.
 */
protected boolean checkFields() {
    ReturnCode rc0 = checkIndicatorFields();
    ReturnCode rc1 = checkIndicatorInPrecentFields();
    if (rc0.isOk() && rc1.isOk()) {
        updateStatus(IStatus.OK, MSG_OK);
        return true;
    } else {
        updateStatus(IStatus.ERROR, rc0.getMessage() + rc1.getMessage());
        return false;
    }
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode)

Example 74 with ReturnCode

use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.

the class IndicatorThresholdsForm method checkIndicatorInPrecentFields.

/**
 * DOC yyi Comment method "checkIndicatorInPrecentFields".
 *
 * @return
 */
protected ReturnCode checkIndicatorInPrecentFields() {
    // $NON-NLS-1$
    String pmin = null != pLowerText ? pLowerText.getText().trim() : "";
    // $NON-NLS-1$
    String pmax = null != pHigherText ? pHigherText.getText().trim() : "";
    ReturnCode rc = new ReturnCode(true);
    // $NON-NLS-1$
    String statusLabelText = "";
    if ((!CheckValueUtils.isEmpty(pmin) && !CheckValueUtils.isRealNumberValue(pmin)) || (!CheckValueUtils.isEmpty(pmax) && !CheckValueUtils.isRealNumberValue(pmax))) {
        rc.setOk(false);
        // $NON-NLS-1$
        statusLabelText += MSG_ONLY_REAL_NUMBER + System.getProperty("line.separator");
    }
    if (CheckValueUtils.isOutRange(MIN, MAX, pmin) || CheckValueUtils.isOutRange(MIN, MAX, pmax)) {
        rc.setOk(false);
        // $NON-NLS-1$
        statusLabelText += UIMessages.MSG_INDICATOR_VALUE_OUT_OF_RANGE + System.getProperty("line.separator");
    }
    if (CheckValueUtils.isAoverB(pmin, pmax)) {
        rc.setOk(false);
        // $NON-NLS-1$
        statusLabelText += UIMessages.MSG_LOWER_LESS_HIGHER + System.getProperty("line.separator");
    }
    rc.setMessage(statusLabelText);
    return rc;
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode)

Example 75 with ReturnCode

use of org.talend.utils.sugars.ReturnCode in project tdq-studio-se by Talend.

the class TOPRepositoryService method reloadDatabase.

/**
 * Comment method "reloadDatabase".
 *
 * @param connectionItem
 * @deprecated instead of it by TDQCompareService.reloadDatabase
 */
@Deprecated
public ReturnCode reloadDatabase(ConnectionItem connectionItem) {
    ReturnCode retCode = new ReturnCode(Boolean.TRUE);
    Connection conn = connectionItem.getConnection();
    try {
        if (conn instanceof DatabaseConnection) {
            List<ModelElement> dependencyClients = EObjectHelper.getDependencyClients(conn);
            if (!(dependencyClients == null || dependencyClients.isEmpty())) {
                int isOk = DeleteModelElementConfirmDialog.showElementImpactConfirmDialog(null, new ModelElement[] { conn }, // $NON-NLS-1$
                DefaultMessagesImpl.getString("TOPRepositoryService.dependcyTile"), DefaultMessagesImpl.getString("TOPRepositoryService.dependcyMessage", // $NON-NLS-1$
                conn.getLabel()));
                if (isOk != Dialog.OK) {
                    retCode.setOk(Boolean.FALSE);
                    // $NON-NLS-1$
                    retCode.setMessage("The user canceled the operation!");
                    return retCode;
                }
            }
            final IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(conn);
            Connection newConnection = creatComparisonLevel.reloadCurrentLevelElement();
            // update the sql explore.
            Property property = PropertyHelper.getProperty(newConnection);
            if (property != null) {
                Item newItem = property.getItem();
                if (newItem != null) {
                    CWMPlugin.getDefault().updateConnetionAliasByName(newConnection, newConnection.getLabel());
                // notifySQLExplorer(newItem);
                }
            }
            // update the related analyses.
            WorkbenchUtils.impactExistingAnalyses(newConnection);
        }
    } catch (ReloadCompareException e) {
        log.error(e, e);
        retCode.setOk(Boolean.FALSE);
        retCode.setMessage(e.getMessage());
    } catch (PartInitException e) {
        log.error(e, e);
        retCode.setOk(Boolean.FALSE);
        retCode.setMessage(e.getMessage());
    }
    return retCode;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) MDMConnection(org.talend.core.model.metadata.builder.connection.MDMConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property) IComparisonLevel(org.talend.cwm.compare.factory.IComparisonLevel)

Aggregations

ReturnCode (org.talend.utils.sugars.ReturnCode)175 ArrayList (java.util.ArrayList)42 TypedReturnCode (org.talend.utils.sugars.TypedReturnCode)42 Test (org.junit.Test)29 File (java.io.File)26 Connection (org.talend.core.model.metadata.builder.connection.Connection)26 Indicator (org.talend.dataquality.indicators.Indicator)25 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)20 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)18 Analysis (org.talend.dataquality.analysis.Analysis)18 Property (org.talend.core.model.properties.Property)17 IFile (org.eclipse.core.resources.IFile)16 IRepositoryNode (org.talend.repository.model.IRepositoryNode)16 IFolder (org.eclipse.core.resources.IFolder)15 SQLException (java.sql.SQLException)14 PersistenceException (org.talend.commons.exception.PersistenceException)11 TdColumn (org.talend.cwm.relational.TdColumn)11 IOException (java.io.IOException)10 EObject (org.eclipse.emf.ecore.EObject)10 IMetadataConnection (org.talend.core.model.metadata.IMetadataConnection)10