Search in sources :

Example 51 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.

the class JobScriptsExportWizardPage method finish.

// protected String getDestinationValueSU() {
//        return this.suDestinationFilePath != null ? this.suDestinationFilePath : ""; //$NON-NLS-1$
//
// }
/**
     * The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
     * is returned then the wizard will not close.
     * 
     * @returns boolean
     */
@Override
public boolean finish() {
    // TODO
    if (treeViewer != null) {
        treeViewer.removeCheckStateListener(checkStateListener);
    }
    saveWidgetValues();
    if (manager == null) {
        manager = createJobScriptsManager();
    }
    if (!ensureTargetIsValid()) {
        return false;
    }
    if (ensureLog4jSettingIsValid()) {
        MessageDialog dialog = new MessageDialog(getShell(), "Question", null, Messages.getString("Log4jSettingPage.IlleagalBuild"), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        dialog.open();
        int result = dialog.getReturnCode();
        if (result != MessageDialog.OK) {
            return false;
        }
    }
    JobExportType jobExportType = getCurrentExportType1();
    if (JobExportType.POJO.equals(jobExportType)) {
        IRunnableWithProgress worker = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                buildJobWithMaven(JobExportType.POJO, monitor);
            }
        };
        try {
            getContainer().run(false, true, worker);
        } catch (InvocationTargetException e) {
            MessageBoxExceptionHandler.process(e.getCause(), getShell());
            return false;
        } catch (InterruptedException e) {
            return false;
        }
    } else {
        List<ContextParameterType> contextEditableResultValuesList = null;
        if (manager != null) {
            contextEditableResultValuesList = manager.getContextEditableResultValuesList();
        }
        if (nodes.length == 1) {
            RepositoryNode node = nodes[0];
            if (node.getType() == ENodeType.SYSTEM_FOLDER) {
                manager.setTopFolderName(ProjectManager.getInstance().getCurrentProject().getLabel());
            } else {
                manager.setTopFolderName(getDefaultFileNameWithType());
            }
        } else {
            manager.setTopFolderName(getDefaultFileNameWithType());
        }
        // for feature:11976, recover back the old default manager value with ContextParameters
        if (contextEditableResultValuesList == null) {
            manager.setContextEditableResultValuesList(new ArrayList<ContextParameterType>());
        } else {
            manager.setContextEditableResultValuesList(contextEditableResultValuesList);
        }
        manager.setMultiNodes(isMultiNodes());
        // achen modify to fix bug 0006222
        IRunnableWithProgress worker = new JobExportAction(Arrays.asList(getCheckNodes()), getSelectedJobVersion(), manager, originalRootFolderName, getProcessType());
        try {
            getContainer().run(false, true, worker);
        } catch (InvocationTargetException e) {
            MessageBoxExceptionHandler.process(e.getCause(), getShell());
            return false;
        } catch (InterruptedException e) {
            return false;
        }
    }
    // see bug 7181
    if (zipOption != null && zipOption.equals("true")) {
        // unzip
        try {
            String zipFile;
            if (manager != null) {
                zipFile = manager.getDestinationPath();
            } else {
                zipFile = getDestinationValue();
                int separatorIndex = zipFile.lastIndexOf(File.separator);
                if (separatorIndex == -1) {
                    //$NON-NLS-1$
                    String userDir = System.getProperty("user.dir");
                    zipFile = userDir + File.separator + zipFile;
                }
            }
            // Added by Marvin Wang on Feb.1, 2012 for bug TDI-18824
            File file = new File(zipFile);
            if (file.exists()) {
                ZipToFile.unZipFile(zipFile, file.getParentFile().getAbsolutePath());
            }
        } catch (Exception e) {
            MessageBoxExceptionHandler.process(e, getShell());
            return false;
        }
    }
    if (treeViewer != null) {
        treeViewer.dispose();
    }
    // end
    return true;
}
Also used : JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Point(org.eclipse.swt.graphics.Point) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JobExportType(org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWSWizardPage.JobExportType) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) ZipToFile(org.talend.repository.ui.utils.ZipToFile) File(java.io.File) ContextParameterType(org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType)

Example 52 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.

the class JobScriptsExportWizardPage method collectNodes.

private void collectNodes(Map<String, Item> items, Object[] objects) {
    for (Object object : objects) {
        RepositoryNode repositoryNode = (RepositoryNode) object;
        collectNodes(items, repositoryNode);
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 53 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.

the class OracleExplainPlanAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.sqlbuilder.actions.AbstractEditorAction#run()
     */
//$NON-NLS-1$
@SuppressWarnings("unchecked")
@Override
public void run() {
    RepositoryNode node = editor.getRepositoryNode();
    SessionTreeNodeManager nodeManager = new SessionTreeNodeManager();
    SessionTreeNode runNode = null;
    try {
        runNode = nodeManager.getSessionTreeNode(node, editor.getDialog().getSelectedContext());
    } catch (Exception e) {
        //$NON-NLS-1$
        MessageDialog.openError(null, Messages.getString("AbstractSQLExecution.Executing.Error"), e.getMessage());
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage1"), e);
        return;
    }
    Preferences prefs = SqlBuilderPlugin.getDefault().getPluginPreferences();
    String queryDelimiter = prefs.getString(IConstants.QUERY_DELIMITER);
    String alternateDelimiter = prefs.getString(IConstants.ALTERNATE_DELIMITER);
    String commentDelimiter = prefs.getString(IConstants.COMMENT_DELIMITER);
    QueryTokenizer qt = new QueryTokenizer(getSQLToBeExecuted(), queryDelimiter, alternateDelimiter, commentDelimiter);
    List queryStrings = new ArrayList();
    while (qt.hasQuery()) {
        final String querySql = qt.nextQuery();
        // ignore commented lines.
        if (!querySql.startsWith("--")) {
            //$NON-NLS-1$
            queryStrings.add(querySql);
        }
    }
    // check if we can run explain plans
    try {
        Statement st = runNode.getInteractiveConnection().createStatement();
        boolean createPlanTable = false;
        boolean notFoundTable = true;
        try {
            //$NON-NLS-1$
            ResultSet rs = st.executeQuery("select statement_id from plan_table");
            notFoundTable = false;
            rs.close();
        } catch (Throwable e) {
            createPlanTable = MessageDialog.openQuestion(null, //$NON-NLS-1$
            Messages.getString("oracle.editor.actions.explain.notFound.Title"), //$NON-NLS-1$
            Messages.getString("oracle.editor.actions.explain.notFound"));
        } finally {
            try {
                st.close();
            } catch (Throwable e) {
                //$NON-NLS-1$
                SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage2"), e);
            }
        }
        if (notFoundTable && !createPlanTable) {
            return;
        }
        if (notFoundTable && createPlanTable) {
            SQLConnection conn = runNode.getInteractiveConnection();
            st = conn.createStatement();
            try {
                st.execute(createPlanTableScript);
                if (!conn.getAutoCommit()) {
                    conn.commit();
                }
            } catch (Throwable e) {
                //$NON-NLS-1$
                SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage2"), e);
                //$NON-NLS-1$
                MessageDialog.openError(//$NON-NLS-1$
                null, //$NON-NLS-1$
                Messages.getString("oracle.editor.actions.explain.createError.Title"), //$NON-NLS-1$
                Messages.getString("oracle.editor.actions.explain.createError"));
                try {
                    st.close();
                } catch (Throwable e1) {
                    //$NON-NLS-1$
                    SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage3"), e1);
                }
                return;
            }
            try {
                st.close();
            } catch (Throwable e) {
                //$NON-NLS-1$
                SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage3"), e);
            }
        }
    } catch (Exception e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage4"), e);
    }
    try {
        while (!queryStrings.isEmpty()) {
            String querySql = (String) queryStrings.remove(0);
            if (querySql != null) {
                resultDisplayer.addSQLExecution(new OracleExplainPlanExecution(querySql, runNode));
            }
        }
    } catch (Exception e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("OracleExplainPlanAction.logMessage5"), e);
    }
}
Also used : Statement(java.sql.Statement) SessionTreeNode(org.talend.sqlbuilder.sessiontree.model.SessionTreeNode) SQLConnection(net.sourceforge.squirrel_sql.fw.sql.SQLConnection) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) QueryTokenizer(org.talend.sqlbuilder.util.QueryTokenizer) SessionTreeNodeManager(org.talend.sqlbuilder.dbstructure.SessionTreeNodeManager) ResultSet(java.sql.ResultSet) ArrayList(java.util.ArrayList) List(java.util.List) Preferences(org.eclipse.core.runtime.Preferences)

Example 54 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.

the class DeleteQueryAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    RepositoryNode node = (RepositoryNode) getStructuredSelection().getFirstElement();
    QueryRepositoryObject object = (QueryRepositoryObject) node.getObject();
    Query query = object.getQuery();
    // Finds the root
    node = SQLBuilderRepositoryNodeManager.getRoot(node);
    List<Query> queries = new ArrayList<Query>();
    queries.add(query);
    repositoryNodeManager.deleteQueries(node, queries);
    dialog.refreshNode(node);
    dialog.notifySQLBuilder(node.getObject());
}
Also used : QueryRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.QueryRepositoryObject) Query(org.talend.core.model.metadata.builder.connection.Query) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 55 with RepositoryNode

use of org.talend.repository.model.RepositoryNode in project tdi-studio-se by Talend.

the class ExecSQLAction method run.

/**
     * DOC qianbing Comment method "run". Processes the database operation.
     * 
     * @param maxRows
     */
protected void run(int maxRows) {
    RepositoryNode node = editor.getRepositoryNode();
    SessionTreeNodeManager nodeManager = new SessionTreeNodeManager();
    SessionTreeNode runNode = null;
    try {
        ConnectionContextHelper.setSqlBuilderDialogShell(editor.getDialog().getShell());
        runNode = nodeManager.getSessionTreeNode(node, editor.getDialog().getSelectedContext());
    } catch (Exception e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
        //$NON-NLS-1$
        MessageDialog.openError(null, Messages.getString("AbstractSQLExecution.Executing.Error"), e.getMessage());
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("ExecSQLAction.logMessageGetSessionTreeNodeFail"), e);
        return;
    }
    QueryTokenizer qt = new QueryTokenizer(getSQLToBeExecuted(), queryDelimiter, alternateDelimiter, commentDelimiter);
    List<String> queryStrings = new ArrayList<String>();
    while (qt.hasQuery()) {
        String querySql = qt.nextQuery();
        // ignore commented lines.
        if (!querySql.startsWith("--")) {
            //$NON-NLS-1$
            queryStrings.add(querySql);
        }
    }
    try {
        // Diaplay data in sqlResult Composites
        while (!queryStrings.isEmpty()) {
            String querySql = queryStrings.remove(0);
            if (querySql != null) {
                SQLExecution sqlExe = new SQLExecution(querySql, maxRows, runNode);
                resultViewer.addSQLExecution(sqlExe);
            // editor.setSQLRunTime(sqlExe.getSQLResult().getExecutionTimeMillis());
            }
        }
    } catch (Exception e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("ExecSQLAction.logMessageErrorCreatingSqlTab"), e);
    }
}
Also used : QueryTokenizer(org.talend.sqlbuilder.util.QueryTokenizer) SessionTreeNodeManager(org.talend.sqlbuilder.dbstructure.SessionTreeNodeManager) SessionTreeNode(org.talend.sqlbuilder.sessiontree.model.SessionTreeNode) SQLExecution(org.talend.sqlbuilder.sqlcontrol.SQLExecution) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode)

Aggregations

RepositoryNode (org.talend.repository.model.RepositoryNode)250 IRepositoryNode (org.talend.repository.model.IRepositoryNode)94 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)74 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)44 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)44 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)42 Item (org.talend.core.model.properties.Item)38 ArrayList (java.util.ArrayList)33 PersistenceException (org.talend.commons.exception.PersistenceException)27 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)27 ProcessItem (org.talend.core.model.properties.ProcessItem)23 RepositoryObject (org.talend.core.model.repository.RepositoryObject)22 ISelection (org.eclipse.jface.viewers.ISelection)20 ConnectionItem (org.talend.core.model.properties.ConnectionItem)20 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)20 List (java.util.List)18 Property (org.talend.core.model.properties.Property)18 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)17 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)16 WizardDialog (org.eclipse.jface.wizard.WizardDialog)13