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;
}
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);
}
}
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);
}
}
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());
}
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);
}
}
Aggregations