Compare commits

..

1 Commits

Author SHA1 Message Date
Sébastien Gandon
efa93e6395 Merge release/5.4.1/tis_shared and release/5.4.1/tos for release/5.4.1. 2014-06-22 14:17:13 +02:00
10509 changed files with 10159 additions and 176195 deletions

5
.gitignore vendored
View File

@@ -1,5 +0,0 @@
*.class
bin/
target/
class/
classes/

View File

@@ -1,47 +0,0 @@
# Talend Common Repository
http://www.talend.com
![alt text](http://www.talend.com/sites/default/files/logo-talend.jpg "Talend")
> Contents
This repository contains the source files that are common across all Talend Open Studio products. These files must be used together with one or more of the following: [tdi-studio-se](https://github.com/Talend/tdi-studio-se), [tdq-studio-se](https://github.com/Talend/tdq-studio-se), [tmdm-studio-se](https://github.com/Talend/tmdm-studio-se), [tesb-studio-se](https://github.com/Talend/tesb-studio-se) or [tbd-studio-se](https://github.com/Talend/tbd-studio-se).
## Repository Structure
All Talend Studio repositories follow the same file structure:
```
|_ main Main Eclipse plugins and features
|_ features
|_ plugins
|_ test Eclipse plugins and features for unit tests.
|_ features
|_ plugins
|_ i18n Internationalization plugins and features.
|_ features
|_ plugins
```
## Support
You can ask for help on our [Forum](http://www.talend.com/services/global-technical-support).
## Contributing
We welcome contributions of all kinds from anyone.
Using the bug tracker [Talend bugtracker](http://jira.talendforge.org/) is the best channel for bug reports, feature requests and submitting pull requests.
Feel free to share your Talend components on [Talend Exchange](http://www.talendforge.org/exchange).
## License
Copyright (c) 2006-2014 Talend
Licensed under the LPGLv3 License

View File

@@ -1,14 +0,0 @@
source.. = src/main/java/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin_en.properties,\
plugin_fr.properties,\
plugin_it.properties,\
plugin_de.properties,\
plugin_swtbot.properties,\
plugin_el.properties,\
plugin_es.properties,\
plugin_ja.properties,\
plugin_ru.properties,\
plugin_zh_CN.properties

View File

@@ -1,2 +0,0 @@
preferencespage.main=Bibliothèques
providerName=www.example.org

View File

@@ -1,6 +0,0 @@
source.. = src/main/java/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin_en.properties,\
plugin_fr.properties

View File

@@ -1,62 +0,0 @@
ModulesInstaller_text=L'opération courante requiert les modules tiers suivants
ModulesInstaller_title=Liste des modules non installés pour l'opération courante
ModulesNeededProvider.Module.Exception=Module {0} introuvable.
ModulesViewComposite.hint.notInstalled=Non installé
CheckModulesAction.CheckRefrshBtn.Text=Rafraîchir
ExternalModulesInstallDialog_AvailableOnTalendForge=Action
ExternalModulesInstallDialog_ColumnJarName=Jar
ExternalModulesInstallDialog_ColumnLicense=Licence
ExternalModulesInstallDialog_ColumnModuleName=Module
ExternalModulesInstallDialog_ColumnRequired=Requis
ExternalModulesInstallDialog_ColumnRequiredBy=Requis par composant
ExternalModulesInstallDialog_ColumnUrl=Plus d'informations
ExternalModulesInstallDialog_Download=Télécharger et installer
ExternalModulesInstallDialog_DownloadFailed=Echec de l'installation des modules suivants :
ExternalModulesInstallDialog_DownloadSuccess=\ Les modules ont bien été installés. \n
ExternalModulesInstallDialog_InstallAll=Télécharger et installer tous les modules disponibles.
ExternalModulesInstallDialog_MoreInfor=<a>Cliquez ici pour obtenir plus d'informations concernant les modules externes.
ExternalModulesInstallDialog_NoExternalModules=Aucun module externe disponible
ExternalModulesInstallDialog_Download_Ok={0} installé avec succès.
ExternalModulesInstallDialog_Download_Fialed=Echec de l'installation de {0}.
ExternalModulesInstallDialog_Title_Missing_jars_for_plugin=Bibliothèques tierces manquantes
ExternalModulesInstallDialog_description_jars_to_be_installed_in=Le Studio requiert l'installation de bibliothèques tierces.\nVeuillez installer les Jar suivants avant de fermer cette fenêtre.
ExternalModulesInstallDialog_NoAvailabeModulesMessages=Le(s) Jar {0} ne sont pas disponibles.
ExternalModulesInstallDialog_NoAvailabeModulesTitle=Modules indisponibles
ComponentExternalModulesDialog.doNotShow=Ne plus afficher
ExternalModulesInstallDialog.MessageDialog.Infor=Informations
ExternalModulesInstallDialog.openInBrowser=Ouvrir dans le navigateur
ExternalModulesInstallDialog.downloading1=Téléchargement...
ExternalModulesInstallDialog.downloading2=Téléchargement
ModuleLicenseDialog.license.accept=Accepter
ModuleLicenseDialog.license.notFound=Vous devez accepter la licence de {0} pour continuer
RemoteModulesHelper.job.task=Téléchargement en cours...
RemoteModulesHelper.fetch.module.info=Récupération des informations sur les modules manquants
RemoteModulesHelper.readJsonFromUrl.error=Impossible de se connecter au serveur
ModulesViewComposite.hint.installed=Installé
ModulesViewComposite.hint.unknown=Inconnu
ModulesViewComposite.Status.TitleText=Statut
ModulesViewComposite.Component.TitleText=Contexte
ModulesViewComposite.Required.TitleText=Description
MainPreferencesPage.externalLibPath=Chemin des bibliothèques externes
MainPreferencesPage.externalLibPathJava=Chemin des bibliothèques Java externes
MainPreferencesPage.externalLibPathPerl=Chemin des bibliothèques Perl externes
MainPreferencesPage.folderSelectionMode=Mode de sélection du dossier
MainPreferencesPage.sameRootFolder=Même dossier racine
MainPreferencesPage.separateRootFolder=Un dossier racine pour chaque langue
InstallPerlModulesAction.InstallBtn.Text=Installer les modules
ImportExternalJarAction.title=Importer des Jar externes
Module.view.download.external.modules.action.text=Télécharger des modules externes
download.external.dialog.title=Les modules suivants ne sont pas installés. Téléchargez et installez tous les modules requis.
download.external.dialog.desciption=Liste des modules à télécharger automatiquement ou à importer manuellement.
download.external.dialog.help.url=https://help.talend.com/display/KB/How+to+install+external+modules+in+the+Talend+products
AcceptModuleLicensesWizardDialog.button.acceptAll=Tout accepter
AcceptModuleLicensesWizardDialog.cancelConfirmation.title=Confirmation
AcceptModuleLicensesWizardDialog.cancelConfirmation.msg=Etes-vous sûr de vouloir arrêter le téléchargement ?
AcceptModuleLicensesWizardPage.title=Lire les licences
AcceptModuleLicensesWizardPage.desc=Les licences listées n'ont pas été acceptées. Seuls les Jars sous les licences acceptées seront téléchargés.
AcceptModuleLicensesWizardPage.licensesList.label=Licences :
AcceptModuleLicensesWizardPage.licenseContent.button.accept=J'accepte les termes de la licence sélectionnée
AcceptModuleLicensesWizardPage.licenseContent.button.decline=Je n'accepte pas les termes de la licence sélectionnée
AcceptModuleLicensesWizardPage.licenseContent.label=Texte de licence :
AcceptModuleLicensesWizardPage.licenseContent.defaultDesc=La licence doit être lue et acceptée avant que les modules puissent être installés.
AcceptModuleLicensesWizardPage.retrieveLicenses=Récupération des licences...

View File

@@ -1 +0,0 @@
AcceptModuleLicensesWizardDialog.cancelConfirmation.title=\u78BA\u8A8D

View File

@@ -1 +0,0 @@
ModulesViewComposite.Status.TitleText=Status

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="class"/>
</classpath>

View File

@@ -1 +0,0 @@
demo.description=Démos Intégration de données

View File

@@ -1 +0,0 @@
demo.description=\u30C7\u30FC\u30BF\u7D71\u5408\u30C7\u30E2

Binary file not shown.

Before

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 541 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 B

View File

@@ -1,67 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.commons.utils;
/**
* created by talend2 on 2014-4-11 Detailled comment
*
*/
public class Hex {
private static final char[] DIGITS_LOWER = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
public static String encodeHexString(byte[] data) {
return new String(encodeHex(data));
}
private static char[] encodeHex(byte[] data) {
int l = data.length;
char[] out = new char[l << 1];
// two characters form the hex value.
for (int i = 0, j = 0; i < l; i++) {
out[j++] = DIGITS_LOWER[(0xF0 & data[i]) >>> 4];
out[j++] = DIGITS_LOWER[0x0F & data[i]];
}
return out;
}
public static byte[] decodeHex(char[] data) {
int len = data.length;
if ((len & 0x01) != 0) {
throw new RuntimeException("Odd number of characters.");
}
byte[] out = new byte[len >> 1];
// two characters form the hex value.
for (int i = 0, j = 0; j < len; i++) {
int f = toDigit(data[j], j) << 4;
j++;
f = f | toDigit(data[j], j);
j++;
out[i] = (byte) (f & 0xFF);
}
return out;
}
private static int toDigit(char ch, int index) {
int digit = Character.digit(ch, 16);
if (digit == -1) {
throw new RuntimeException("Illegal hexadecimal character " + ch + " at index " + index);
}
return digit;
}
}

View File

@@ -1,229 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.commons.utils.database;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
/**
* created by zshen on Apr 12, 2013 Detailled comment
*
*/
public class AS400DatabaseMetaData extends PackageFakeDatabaseMetadata {
// private static final String[] TABLE_META = {
// "ID", "TABLE_SCHEM", "TABLE_NAME", "TABLE_TYPE", "REMARKS", "TABLE_NAME", "SYSTEM_TABLE_NAME", "TABLE_SCHEMA", "SYSTEM_TABLE_SCHEMA" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
private static final String[] TABLE_META = {
"TABLE_TYPE", "TABLE_NAME", "SYSTEM_TABLE_NAME", "TABLE_SCHEMA", "SYSTEM_TABLE_SCHEMA" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
private String T = "T";//$NON-NLS-1$
private String V = "V";//$NON-NLS-1$
private String S = "S";//$NON-NLS-1$
private String A = "A";//$NON-NLS-1$
private String TABLE = "TABLE"; //$NON-NLS-1$
private String VIEW = "VIEW"; //$NON-NLS-1$
private String SYNONYM = "SYNONYM"; //$NON-NLS-1$
private String ALIAS = "ALIAS"; //$NON-NLS-1$
public AS400DatabaseMetaData(Connection conn) throws SQLException {
super(conn);
}
/*
* (non-Javadoc)
*
* @see org.talend.fakejdbc.FakeDatabaseMetaData#getCatalogs()
*/
@Override
public ResultSet getCatalogs() throws SQLException {
// TODO Auto-generated method stub
return super.getCatalogs();
}
/*
* (non-Javadoc)
*
* @see org.talend.fakejdbc.FakeDatabaseMetaData#getColumns(java.lang.String, java.lang.String, java.lang.String,
* java.lang.String)
*/
@Override
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
throws SQLException {
// TODO Auto-generated method stub
return super.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern);
}
/*
* (non-Javadoc)
*
* @see org.talend.fakejdbc.FakeDatabaseMetaData#getConnection()
*/
@Override
public Connection getConnection() {
// TODO Auto-generated method stub
return super.getConnection();
}
/*
* (non-Javadoc)
*
* @see org.talend.fakejdbc.FakeDatabaseMetaData#getTables(java.lang.String, java.lang.String, java.lang.String,
* java.lang.String[])
*/
@Override
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
String sql;
String and;
if (schemaPattern != null) {
sql = "SELECT TYPE,TABLE_NAME, SYSTEM_TABLE_NAME, TABLE_SCHEMA , SYSTEM_TABLE_SCHEMA FROM QSYS2.SYSTABLES WHERE TABLE_SCHEMA = '"
+ schemaPattern + "'";
and = " and ";
} else {
sql = "SELECT TYPE,TABLE_NAME, SYSTEM_TABLE_NAME, TABLE_SCHEMA , SYSTEM_TABLE_SCHEMA FROM QSYS2.SYSTABLES";
and = " where ";
}
sql = addTypesToSql(sql, types, and);
if (!StringUtils.isEmpty(tableNamePattern)) {
sql = sql + " and NAME like ?";//$NON-NLS-1$
}
ResultSet rs = null;
PreparedStatement stmt = null;
List<String[]> list = new ArrayList<String[]>();
Set<String> tablesRetrieved = new HashSet<String>();
try {
stmt = connection.prepareStatement(sql);
if (!StringUtils.isEmpty(tableNamePattern)) {
stmt.setString(1, tableNamePattern);
}// ~
rs = stmt.executeQuery();
while (rs.next()) {
String type = rs.getString("TYPE"); //$NON-NLS-1$
String table_name = rs.getString("TABLE_NAME"); //$NON-NLS-1$
String system_table_name = rs.getString("SYSTEM_TABLE_NAME"); //$NON-NLS-1$
tablesRetrieved.add(system_table_name);
String table_schema = rs.getString("TABLE_SCHEMA"); //$NON-NLS-1$
String system_table_schema = rs.getString("SYSTEM_TABLE_SCHEMA");
String[] r = new String[] { type, table_name, system_table_name, table_schema, system_table_schema };
list.add(r);
}
} catch (SQLException e) {
throw new RuntimeException(e);
} finally {
try {
rs.close();
stmt.close();
} catch (Exception e) {
}
}
ResultSet jdbcRset = super.getTables(catalog, schemaPattern, tableNamePattern, types);
while (jdbcRset.next()) {
String table_name = jdbcRset.getString("TABLE_NAME"); //$NON-NLS-1$
if (tablesRetrieved.contains(table_name)) {
continue;
}
String type = jdbcRset.getString("TABLE_TYPE"); //$NON-NLS-1$
String table_schema = jdbcRset.getString("TABLE_SCHEM"); //$NON-NLS-1$
String[] r = new String[] { type, table_name, table_name, table_schema, table_schema };
list.add(r);
}
AS400ResultSet tableResultSet = new AS400ResultSet();
tableResultSet.setMetadata(TABLE_META);
tableResultSet.setData(list);
return tableResultSet;
}
private String getTypeNameType(String typeName) {
String result = typeName;
if (T.equals(typeName)) {
result = TABLE;
} else if (V.equals(typeName)) {
result = VIEW;
} else if (S.equals(typeName)) {
result = SYNONYM;
} else if (A.equals(typeName)) {
result = ALIAS;
}
return result;
}
private String addTypesToSql(String sql, String[] types, String and) {
String result = sql;
if (types != null && types.length > 0) {
String typeClause = " type in("; //$NON-NLS-1$
int len = types.length;
for (int i = 0; i < len; ++i) {
String comma = ""; //$NON-NLS-1$
if (i > 0) {
comma = " , "; //$NON-NLS-1$
}
typeClause = typeClause + comma + "'" + getTypeName(types[i]) + "'";//$NON-NLS-1$ //$NON-NLS-2$
}
typeClause = typeClause + ")"; //$NON-NLS-1$
result = sql + and + typeClause;
}
return result;
}
private String getTypeName(String typeName) {
String result = typeName;
if (TABLE.equals(typeName)) {
result = T;
} else if (VIEW.equals(typeName)) {
result = V;
} else if (SYNONYM.equals(typeName)) {
result = S;
} else if (ALIAS.equals(typeName)) {
result = A;
}
return result;
}
/*
* (non-Javadoc)
*
* @see org.talend.fakejdbc.FakeDatabaseMetaData#getSchemas(java.lang.String, java.lang.String)
*/
@Override
public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
ResultSet resultSet = null;
try {
resultSet = this.metaData.getSchemas(catalog, schemaPattern);
} catch (SQLException e) {
// get resultSet of schema by sql mode
resultSet = this.metaData.getTables(catalog, schemaPattern, null, null);
}
return resultSet;
}
}

View File

@@ -1,128 +0,0 @@
package org.talend.commons.utils.database;
import java.sql.SQLException;
import java.util.List;
import org.talend.commons.i18n.internal.Messages;
import org.talend.commons.utils.TalendDBUtils;
import org.talend.fakejdbc.FakeResultSet;
/**
* DOC zwzhao class global comment. Detailled comment
*/
public class AS400ResultSet extends FakeResultSet {
private String[] tableMeta = null;
private List<String[]> data;
int index = -1;
/*
* (non-Javadoc)
*
* @see org.talend.commons.utils.database.FakeResultSet#next()
*/
@Override
public boolean next() throws SQLException {
if (data == null || data.size() == 0 || index >= data.size() - 1) {
return false;
}
index++;
return true;
}
public static int indexOf(String string, String[] search) {
for (int i = 0; i < search.length; i++) {
if (search[i].equals(string)) {
return i;
}
}
return -1;
}
/*
* (non-Javadoc)
*
* @see org.talend.commons.utils.database.FakeResultSet#getString(java.lang.String)
*/
@Override
public String getString(String columnLabel) throws SQLException {
int columnIndex = indexOf(columnLabel, tableMeta);
if (columnIndex == -1) {
throw new SQLException(Messages.getString("AS400ResultSet.unknowCloumn") + columnLabel); //$NON-NLS-1$
}
return getString(columnIndex + 1);
}
/*
* (non-Javadoc)
*
* @see org.talend.commons.utils.database.FakeResultSet#getInt(java.lang.String)
*/
@Override
public int getInt(String columnLabel) throws SQLException {
String str = getString(columnLabel);
if (columnLabel.equals("TYPE_NAME")) {
int index = TalendDBUtils.convertToJDBCType(str);
return index;
} else if (columnLabel.equals("IS_NULLABLE")) {
if (str.equals("N")) {
return 1;
} else {
return 0;
}
} else {
return Integer.parseInt(str);
}
}
/*
* (non-Javadoc)
*
* @see org.talend.commons.utils.database.FakeResultSet#getBoolean(java.lang.String)
*/
@Override
public boolean getBoolean(String columnLabel) throws SQLException {
String str = getString(columnLabel);
return Boolean.parseBoolean(str);
}
/*
* (non-Javadoc)
*
* @see org.talend.commons.utils.database.FakeResultSet#getString(int)
*/
@Override
public String getString(int columnIndex) throws SQLException {
String[] row = data.get(index);
columnIndex--;
if (columnIndex < 0 || columnIndex > row.length) {
throw new SQLException(
Messages.getString("AS400ResultSet.parameterIndex") + columnIndex + Messages.getString("AS400ResultSet.outofRange")); //$NON-NLS-1$ //$NON-NLS-2$
}
return row[columnIndex];
}
/**
* DOC bqian Comment method "setMetadata".
*
* @param table_meta
*/
public void setMetadata(String[] tableMeta) {
this.tableMeta = tableMeta;
}
/**
* DOC bqian Comment method "setData".
*
* @param tables
*/
public void setData(List<String[]> data) {
this.data = data;
}
}

View File

@@ -1 +0,0 @@
talend.version=5.4.3

View File

@@ -1,214 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.commons.ui.swt.dialogs;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.talend.commons.ui.runtime.i18n.Messages;
public class SSLDialog extends Dialog {
private Text keyStoreText;
private Text trustStoreText;
private Text passwordText;
private Button okButton;
private Button browseKeyStoreButton;
private Button browseTrustStoreButton;
private String keyStorePath;
private String trustStorePath;
private String password;
/**
* DOC Administrator FetchDialog constructor comment.
*
* @param parentShell
*/
public SSLDialog(Shell parentShell) {
super(parentShell);
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText("SSL parameters"); //$NON-NLS-1$
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
this.okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout());
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
applyDialogFont(composite);
Group group = new Group(composite, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
group.setLayout(layout);
group.setLayoutData(new GridData(GridData.FILL_BOTH));
group.setText("Please provide your SSL information"); //$NON-NLS-1$
new Label(group, SWT.NONE).setText("KeyStore File"); //$NON-NLS-1$
keyStoreText = new Text(group, SWT.BORDER);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = 250;
keyStoreText.setLayoutData(data);
if (keyStorePath != null) {
keyStoreText.setText(keyStorePath);
}
browseKeyStoreButton = new Button(group, SWT.PUSH);
browseKeyStoreButton.setText("Browse");
setButtonLayoutData(browseKeyStoreButton);
browseKeyStoreButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleKeyStoreDirectoryButtonPressed();
}
});
new Label(group, SWT.NONE).setText("TrustStore File"); //$NON-NLS-1$
trustStoreText = new Text(group, SWT.BORDER);
GridData data1 = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = 250;
trustStoreText.setLayoutData(data1);
if (trustStorePath != null) {
trustStoreText.setText(trustStorePath);
}
browseTrustStoreButton = new Button(group, SWT.PUSH);
browseTrustStoreButton.setText("Browse");
setButtonLayoutData(browseTrustStoreButton);
browseTrustStoreButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handleTrustDirectoryButtonPressed();
}
});
new Label(group, SWT.NONE).setText("SSL Password"); //$NON-NLS-1$
passwordText = new Text(group, SWT.BORDER);
passwordText.setEchoChar('*');
passwordText.setLayoutData(data);
if (password != null) {
passwordText.setText(password);
}
return composite;
}
@Override
protected void cancelPressed() {
keyStorePath = keyStoreText.getText();
trustStorePath = trustStoreText.getText();
password = passwordText.getText();
super.cancelPressed();
}
@Override
protected void okPressed() {
if (keyStoreText.getText().equals("")) {
MessageDialog.openError(new Shell(), getShell().getText(), Messages.getString("SSLConfirmDialog.KeyStore")); //$NON-NLS-1$
return;
}
if (passwordText.getText().equals("")) {
MessageDialog.openError(new Shell(), getShell().getText(), Messages.getString("SSLConfirmDialog.TrustStore")); //$NON-NLS-1$
return;
}
if (trustStoreText.getText().equals("")) {
MessageDialog.openError(new Shell(), getShell().getText(), Messages.getString("SSLConfirmDialog.Password")); //$NON-NLS-1$
return;
}
keyStorePath = keyStoreText.getText();
password = passwordText.getText();
trustStorePath = trustStoreText.getText().trim();
super.okPressed();
}
public String getKeyStorePath() {
return keyStorePath;
}
public void setKeyStorePath(String keyStorePath) {
this.keyStorePath = keyStorePath;
}
public String getTrustStorePath() {
return trustStorePath;
}
public void setTrustStorePath(String trustStorePath) {
this.trustStorePath = trustStorePath;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
private void handleKeyStoreDirectoryButtonPressed() {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setFilterPath("");
dialog.setText("select keyStore");
dialog.setFileName("");
dialog.setFilterExtensions(new String[] { "*.jks" });// 设置文件扩展名
String fileName = dialog.open();//
if (fileName != null) {
keyStoreText.setText(fileName);
}
}
private void handleTrustDirectoryButtonPressed() {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
dialog.setFilterPath("");
dialog.setText("select trustStore");
dialog.setFileName("");
dialog.setFilterExtensions(new String[] { "*.jks" });// 设置文件扩展名
String fileName = dialog.open();//
if (fileName != null) {
trustStoreText.setText(fileName);
}
}
}

View File

@@ -1,36 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.repository;
import org.talend.repository.ui.actions.AContextualAction;
/**
* created by wchen on 2014-4-1 Detailled comment
*
*/
public abstract class SvnCommitHook extends AContextualAction {
private static boolean activeAutoCommit = false;
public static boolean isActiveAutoCommit() {
return activeAutoCommit;
}
public static void activeAutoCommit() {
activeAutoCommit = true;
}
public static void desactAutoCommit() {
activeAutoCommit = false;
}
}

View File

@@ -1,212 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.repository.model;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.commons.collections.map.MultiKeyMap;
import org.eclipse.emf.common.util.EList;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.model.general.Project;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.INode;
import org.talend.core.model.process.IProcess2;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Property;
import org.talend.core.model.relationship.Relation;
import org.talend.core.model.relationship.RelationshipItemBuilder;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.repository.ICheckDeleteItemReference;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.repository.ProjectManager;
import org.talend.repository.model.ERepositoryStatus;
import org.talend.repository.model.IProxyRepositoryFactory;
import org.talend.repository.model.ItemReferenceBean;
import org.talend.repository.ui.actions.DeleteActionCache;
/**
*
* DOC hcyi class global comment. Detailled comment
*/
public class CheckJobDeleteReference extends AbstractCheckDeleteItemReference implements ICheckDeleteItemReference {
private static final String PROCESS_TYPE_PROCESS = "PROCESS_TYPE_PROCESS"; //$NON-NLS-1$
private static final String USE_DYNAMIC_JOB = "USE_DYNAMIC_JOB"; //$NON-NLS-1$
// almost move from the method checkRepositoryNodeFromProcess of DeleteAction class.
@Override
public Set<ItemReferenceBean> checkItemReferenceBeans(IProxyRepositoryFactory factory, DeleteActionCache deleteActionCache,
IRepositoryViewObject object) {
Item nodeItem = object.getProperty().getItem();
boolean needCheckJobIfUsedInProcess = false;
if (nodeItem instanceof ProcessItem) {
needCheckJobIfUsedInProcess = true;
}
Set<ItemReferenceBean> list = new HashSet<ItemReferenceBean>();
if (needCheckJobIfUsedInProcess) {
Property property = object.getProperty();
if (property != null) {
String label = property.getLabel();
String version = property.getVersion();
ERepositoryObjectType type = object.getRepositoryObjectType();
boolean isItemDeleted = factory.getStatus(object) == ERepositoryStatus.DELETED;
Item item = property.getItem();
if (!(item instanceof ProcessItem)) {
return list;
}
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(property.getId());
if (relations.isEmpty()) {
return list;
}
Set<Project> refParentProjects = new HashSet<Project>();
try {
refParentProjects.add(ProjectManager.getInstance().getCurrentProject());
refParentProjects.addAll(ProjectManager.getInstance().getReferencedProjects());
for (Project refP : refParentProjects) {
List<IRepositoryViewObject> processes = factory.getAll(refP, ERepositoryObjectType.PROCESS, true);
deleteActionCache.setProcessList(processes);
for (IRepositoryViewObject process : deleteActionCache.getProcessList()) {
Property property2 = process.getProperty();
if (isOpenedItem(property2, deleteActionCache.getOpenProcessMap())) {
// will be checked in the opened item list.
continue;
}
Relation current = new Relation();
current.setId(property2.getId());
current.setType(RelationshipItemBuilder.JOB_RELATION);
current.setVersion(property2.getVersion());
if (!relations.contains(current)) {
continue;
}
boolean isDelete = factory.getStatus(process) == ERepositoryStatus.DELETED;
Item item2 = property2.getItem();
if (item == item2) {
continue;
}
String path = item2.getState().getPath();
boolean found = false;
ItemReferenceBean bean = new ItemReferenceBean();
bean.setItemName(label);
bean.setItemVersion(version);
bean.setItemType(type);
bean.setItemDeleted(isItemDeleted);
bean.setReferenceItemName(property2.getLabel());
bean.setReferenceItemVersion(property2.getVersion());
bean.setReferenceItemType(process.getRepositoryObjectType());
bean.setReferenceItemPath(path);
bean.setReferenceProjectName(refP.getLabel());
bean.setReferenceItemDeleted(isDelete);
for (ItemReferenceBean b : list) {
if (b.equals(bean)) {
found = true;
b.addNodeNum();
break;
}
}
if (!found) {
list.add(bean);
}
}
}
for (IProcess2 openedProcess : deleteActionCache.getOpenedProcessList()) {
for (INode node : openedProcess.getGraphicalNodes()) {
boolean equals = false;
IElementParameter processTypeParam = node.getElementParameter(PROCESS_TYPE_PROCESS);
if (processTypeParam != null) {
IElementParameter isUseDynamicJob = node.getElementParameter(USE_DYNAMIC_JOB); //$NON-NLS-1$
if (isUseDynamicJob != null && (Boolean) isUseDynamicJob.getValue()) {
String[] jobsID = ((String) processTypeParam.getValue()).split(";"); //$NON-NLS-1$
for (String jobID : jobsID) {
if (property.getId().equals(jobID)) {
equals = true;
break;
}
}
} else if (property.getId().equals(processTypeParam.getValue())) {
equals = true;
}
}
boolean isDelete = factory.getStatus(openedProcess) == ERepositoryStatus.DELETED;
Property property2 = openedProcess.getProperty();
Item item2 = property2.getItem();
String path = item2.getState().getPath();
if (equals) {
boolean found = false;
ItemReferenceBean bean = new ItemReferenceBean();
bean.setItemName(label);
bean.setItemVersion(version);
bean.setItemType(type);
bean.setItemDeleted(isItemDeleted);
bean.setReferenceItemName(property2.getLabel());
bean.setReferenceItemVersion(property2.getVersion());
bean.setReferenceItemType(ERepositoryObjectType.getItemType(item2));
bean.setReferenceItemPath(path);
bean.setReferenceProjectName(ProjectManager.getInstance().getProject(property2).getLabel());
bean.setReferenceItemDeleted(isDelete);
for (ItemReferenceBean b : list) {
if (b.equals(bean)) {
found = true;
b.addNodeNum();
break;
}
}
if (!found) {
list.add(bean);
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
/*
* If the reference job or joblet is in the recycle bin but the joblet is not then no need to check; If both the
* joblet and the reference job or joblet are all in the recycle bin and they are all in the delete list then no
* need to check them; If both the joblet and the reference job or joblet are all not in the recycle bin and
* they are all in the delete list then no need to check them too.
*/
Iterator<ItemReferenceBean> it = list.iterator();
while (it.hasNext()) {
ItemReferenceBean bean = it.next();
if ((!bean.isItemDeleted() && bean.isReferenceItemDeleted())
|| (bean.isItemDeleted() && bean.isReferenceItemDeleted() && isItemInDeleteList(bean, true))
|| (!bean.isItemDeleted() && !bean.isReferenceItemDeleted() && isItemInDeleteList(bean, true))) {
it.remove();
}
}
return list;
}
private boolean isOpenedItem(Property property, MultiKeyMap openProcessMap) {
if (property == null) {
return false;
}
return (openProcessMap.get(property.getId(), property.getLabel(), property.getVersion()) != null);
}
}

View File

@@ -1,100 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.repository.ui.views;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swt.graphics.Color;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.core.model.metadata.builder.connection.ValidationRulesConnection;
import org.talend.core.model.process.IElement;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ValidationRulesConnectionItem;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.repository.model.IProxyRepositoryFactory;
import org.talend.repository.model.RepositoryNode;
/**
* DOC hcyi class global comment. Detailled comment
*/
public class ValidationRulesLabelProvider extends RepositoryLabelProvider {
public static final Color MERGED_REFERENCED_ITEMS_COLOR = new Color(null, 120, 120, 120);
private IElement elem;
/**
* DOC wf ValidationRulesLabelProvider constructor comment.
*
* @param view
*/
public ValidationRulesLabelProvider(IRepositoryView view, IElement elem) {
super(view);
this.elem = elem;
}
@Override
public Color getForeground(Object element) {
RepositoryNode node = (RepositoryNode) element;
List<IRepositoryViewObject> objs = getRelatedValidationRuleObjs(elem);
if (node.getObjectType() == ERepositoryObjectType.METADATA_VALIDATION_RULES) {
for (IRepositoryViewObject object : objs) {
if (node.getObject().getId().equals(object.getId())) {
return super.getForeground(element);
}
}
}
return MERGED_REFERENCED_ITEMS_COLOR;
}
public static List<IRepositoryViewObject> getRelatedValidationRuleObjs(IElement element) {
String repId = (String) element.getPropertyValue("REPOSITORY_SCHEMA_TYPE");
return getRelatedValidationRuleObjs(repId);
}
public static List<IRepositoryViewObject> getRelatedValidationRuleObjs(String schemaId) {
List<IRepositoryViewObject> rulesObjs = new ArrayList<IRepositoryViewObject>();
if (schemaId != null) {
try {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<IRepositoryViewObject> members = factory.getAll(ERepositoryObjectType.METADATA_VALIDATION_RULES);
if (members != null && members.size() > 0) {
for (IRepositoryViewObject member : members) {
if (member != null && member.getProperty() != null) {
Item item = member.getProperty().getItem();
if (item != null && item instanceof ValidationRulesConnectionItem) {
ValidationRulesConnectionItem validItem = (ValidationRulesConnectionItem) item;
ValidationRulesConnection connection = (ValidationRulesConnection) validItem.getConnection();
// if (connection != null && schemaId.equals(connection.getBaseSchema())
// && !rulesObjs.contains(member)) {
if (connection != null && !rulesObjs.contains(member)
&& schemaId.equals(connection.getBaseSchema())) {
rulesObjs.add(member);
}
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return rulesObjs;
}
}

View File

@@ -1,265 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.talend.core.runtime" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.talend.core.runtime" id="updateManager_provider" name="Update Manager "/>
</appinfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence minOccurs="0" maxOccurs="unbounded">
<element ref="UpdateItemType" minOccurs="0" maxOccurs="unbounded"/>
<element ref="ProcessUpdateManagerProvider" minOccurs="0" maxOccurs="unbounded"/>
<element ref="RepositoryUpdateManagerProvider" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="UpdateItemType">
<annotation>
<documentation>
Enable to define a item type for IUpdateItemType.
</documentation>
</annotation>
<complexType>
<attribute name="name" type="string" use="required">
<annotation>
<documentation>
the name of update type should be unique.
</documentation>
</annotation>
</attribute>
<attribute name="description" type="string">
<annotation>
<documentation>
Description of type.
</documentation>
</annotation>
</attribute>
<attribute name="displayLabel" type="string">
<annotation>
<documentation>
Mostly, it work for the UpdateDetectionDialog for display label for type.
If not set, will re-use name.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="ProcessUpdateManagerProvider">
<annotation>
<documentation>
Mostly work for Process object(job/joblet/route/MR Job...) to check the relationship of repository types, like PropertyType, SchemaType, QueryType, ProcessType, etc.
</documentation>
</annotation>
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
Must be unique id for provider.
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
Name of provider.
</documentation>
</annotation>
</attribute>
<attribute name="description" type="string">
<annotation>
<documentation>
description of provider.
</documentation>
</annotation>
</attribute>
<attribute name="priority" use="required">
<annotation>
<documentation>
the higher level provider will be executed before others.
</documentation>
<appinfo>
<meta.attribute kind="identifier"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="NORMAL">
</enumeration>
<enumeration value="HIGHEST">
</enumeration>
<enumeration value="HIGH">
</enumeration>
<enumeration value="LOW">
</enumeration>
<enumeration value="LOWEST">
</enumeration>
</restriction>
</simpleType>
</attribute>
<attribute name="provider" type="string" use="required">
<annotation>
<documentation>
Must implement the interface IProcessUpdateManagerProvider.
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.talend.core.model.update.extension.IProcessUpdateManagerProvider"/>
</appinfo>
</annotation>
</attribute>
<attribute name="override" type="string">
<annotation>
<documentation>
The value is the id of Update manager provider to be overrided.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="RepositoryUpdateManagerProvider">
<annotation>
<documentation>
Work with repository nodes for DetecteViewImpactAction.
</documentation>
</annotation>
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
Must be unique id for provider.
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
Name of provider.
</documentation>
</annotation>
</attribute>
<attribute name="description" type="string">
<annotation>
<documentation>
description of provider.
</documentation>
</annotation>
</attribute>
<attribute name="priority" use="required">
<annotation>
<documentation>
the higher level provider will be executed before others.
</documentation>
<appinfo>
<meta.attribute kind="identifier"/>
</appinfo>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="NORMAL">
</enumeration>
<enumeration value="HIGHEST">
</enumeration>
<enumeration value="HIGH">
</enumeration>
<enumeration value="LOW">
</enumeration>
<enumeration value="LOWEST">
</enumeration>
</restriction>
</simpleType>
</attribute>
<attribute name="provider" type="string" use="required">
<annotation>
<documentation>
Must implement the interface IItemUpdateManagerProvider.
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.talend.core.model.update.extension.IRepositoryUpdateManagerProvider"/>
</appinfo>
</annotation>
</attribute>
<attribute name="override" type="string">
<annotation>
<documentation>
The value is the id of Update manager provider to be overrided.
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>

View File

@@ -1,51 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.hadoop;
/**
* created by ycbai on 2014-5-28 Detailled comment
*
*/
public enum EHadoopConfigurationJars {
HDFS(
new String[] { "hadoop-conf.jar" }, new String[] { "hadoop-conf-kerberos.jar", "jetty-util-6.1.26.jar", "jersey-core-1.8.jar", "commons-io-2.4.jar" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
HCATALOG(new String[] { "hadoop-conf.jar" }, new String[] { "hadoop-conf-kerberos.jar" }), //$NON-NLS-1$ //$NON-NLS-2$
HIVE(new String[] { "hadoop-conf.jar" }, new String[] { "hadoop-conf-kerberos.jar" }), //$NON-NLS-1$ //$NON-NLS-2$
;
private String[] disableSecurityJars;
private String[] enableSecurityJars;
EHadoopConfigurationJars(String[] disableSecurityJars, String[] enableSecurityJars) {
this.disableSecurityJars = disableSecurityJars;
this.enableSecurityJars = enableSecurityJars;
}
public String getName() {
return name();
}
public String[] getDisableSecurityJars() {
return this.disableSecurityJars;
}
public String[] getEnableSecurityJars() {
return this.enableSecurityJars;
}
}

View File

@@ -1,22 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.metadata;
/**
* created by ldong on Jan 13, 2015 Detailled comment
*
*/
public interface IDatabaseConstant {
public static final String REDSHIFT = "DATABASE:REDSHIFT";
}

View File

@@ -1,54 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.process;
import java.util.LinkedHashMap;
/**
* created by wchen on 2014-1-7 Detailled comment TraceDataBean for UI
*/
public class TraceData {
private static final long serialVersionUID = -4580437449518099406L;
private String connectionId;
private int nbLine;
private LinkedHashMap<String, String> data = new LinkedHashMap<String, String>();
public String getConnectionId() {
return this.connectionId;
}
public void setConnectionId(String connectionId) {
this.connectionId = connectionId;
}
public int getNbLine() {
return this.nbLine;
}
public void setNbLine(int nbLine) {
this.nbLine = nbLine;
}
public LinkedHashMap<String, String> getData() {
return this.data;
}
public void setData(LinkedHashMap<String, String> data) {
this.data = data;
}
}

View File

@@ -1,79 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.relationship;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
/**
* DOC ggu class global comment. Detailled comment
*/
public abstract class AbstractJobParameterInRepositoryRelationshipHandler extends AbstractJobParameterRelationshipHandler {
public static final String IN_REPOSITORY = "REPOSITORY"; //$NON-NLS-1$
/*
* (non-Javadoc)
*
* @see org.talend.core.model.relationship.AbstractParameterRelationshipHandler#collect(java.util.Map,
* java.util.Map)
*/
@Override
protected Set<Relation> collect(Map<String, ElementParameterType> parametersMap, Map<?, ?> options) {
Set<Relation> relationSet = new HashSet<Relation>();
for (ElementParameterType paramType : parametersMap.values()) {
if (paramType.getName().endsWith(":" + getRepositoryTypeName())) { //$NON-NLS-1$
String name = paramType.getName().split(":")[0]; //$NON-NLS-1$
ElementParameterType repositoryTypeParam = parametersMap.get(name + ":" //$NON-NLS-1$
+ getRepositoryTypeName());
if (repositoryTypeParam != null && IN_REPOSITORY.equals(repositoryTypeParam.getValue())) {
ElementParameterType repositoryTypeValueParam = parametersMap.get(name + ":" //$NON-NLS-1$
+ getRepositoryTypeValueName());
if (repositoryTypeValueParam != null) {
String repositoryIdOrValue = repositoryTypeValueParam.getValue();
if (StringUtils.isNotEmpty(repositoryIdOrValue)) {
Relation addedRelation = new Relation();
addedRelation.setId(repositoryIdOrValue);
addedRelation.setType(getRepositoryRelationType());
addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
relationSet.add(addedRelation);
}
}
}
}
}
return relationSet;
}
/**
* Something like PROPERTY_TYPE
*/
protected abstract String getRepositoryTypeName();
/**
* Something like REPOSITORY_PROPERTY_TYPE
*/
protected abstract String getRepositoryTypeValueName();
/**
* get the type of relation type
*/
protected abstract String getRepositoryRelationType();
}

View File

@@ -1,98 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.repository;
import java.util.Date;
import org.eclipse.core.runtime.IPath;
import org.talend.core.context.Context;
import org.talend.core.context.RepositoryContext;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ItemState;
import org.talend.core.model.properties.PropertiesFactory;
import org.talend.core.model.properties.impl.ItemImpl;
import org.talend.core.model.properties.impl.PropertyImpl;
import org.talend.core.runtime.CoreRuntimePlugin;
/**
* created by wchen on 2014-3-11 Detailled comment
*
*/
public class FakePropertyImpl extends PropertyImpl {
private IPath itemPath;
/**
* DOC FakePropertyImpl constructor comment.
*
* @param id
*/
public FakePropertyImpl() {
Context ctx = CoreRuntimePlugin.getInstance().getContext();
RepositoryContext repoContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
this.setAuthor(repoContext.getUser());
setVersion(""); //$NON-NLS-1$
setCreationDate(new Date());
}
@Override
public void setItem(Item newItem) {
super.setItem(newItem);
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
getItem().setState(itemState);
getItem().setProperty(this);
}
/*
* (non-Javadoc)
*
* @see org.talend.core.model.properties.impl.PropertyImpl#setId(java.lang.String)
*/
@Override
public void setId(String newId) {
// TODO Auto-generated method stub
super.setId(newId);
}
public class FakeItemImpl extends ItemImpl {
/**
* DOC TransformFakeItemImpl constructor comment.
*/
public FakeItemImpl() {
super();
}
}
/**
* Sets the itemPath.
*
* @param itemPath the itemPath to set
*/
public void setItemPath(IPath itemPath) {
this.itemPath = itemPath;
}
/**
* Getter for itemPath.
*
* @return the itemPath
*/
public IPath getItemPath() {
return this.itemPath;
}
}

View File

@@ -1,74 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.repository;
import java.util.List;
import org.eclipse.core.resources.IResource;
import org.talend.core.model.properties.Property;
/**
* created by wchen on 2013-8-22 Detailled comment
*
*/
public interface IExtendedRepositoryNodeHandler {
/**
*
* DOC wchen Comment method "getProperty".
*
* @param repository nodeObject
* @return property of this repository object
*/
public Property getProperty(Object nodeObject);
public Object getParent(Object repositoryNode);
/**
*
* DOC get ERepositoryObjectType for repository selection
*
* @param repository selected object
* @return
*/
public ERepositoryObjectType getObjectType(Object repositoryNode);
/**
*
* DOC get root ERepositoryObjectType for repository selection
*
* @param repository selected object
* @return
*/
public ERepositoryObjectType getRootType(Object repositoryNode);
/**
*
* DOC collect all Hierarchical Mapper related resources,includes mapper repositoryObject resouece and other related
* structures,namespace... resoueces
*
* @param mapper repositoryObject
* @return
*/
public List<IResource> getRepositoryNodeAndDependencies(IRepositoryViewObject repositoryObject);
/**
*
* DOC collect mapper referenced RepositoryObject
*
* @param mapper repositoryObject
* @return
*/
public List<IRepositoryViewObject> getRepositoryObjectDependencies(IRepositoryViewObject repositoryObject);
}

View File

@@ -1,23 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update;
/**
* DOC ggu class global comment. Detailled comment
*/
public interface IUpdateItemType {
String getDisplayLabel();
String getName();
}

View File

@@ -1,322 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.apache.commons.collections.map.MultiKeyMap;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.core.model.process.IProcess;
import org.talend.core.model.process.IProcess2;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.JobletProcessItem;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Property;
import org.talend.core.model.relationship.Relation;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.repository.RepositoryObject;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.runtime.i18n.Messages;
import org.talend.designer.core.IDesignerCoreService;
import org.talend.repository.model.ERepositoryStatus;
import org.talend.repository.model.IProxyRepositoryFactory;
/**
* created by ggu on Mar 28, 2014 Detailled comment
*
*/
public class RepositoryUpdateManagerHelper {
protected boolean enableCheckItem() {
return false; // by default, no items
}
protected List<Relation> getRelations() {
return null;
}
protected List<UpdateResult> getOtherUpdateResults(IProgressMonitor parentMonitor, List<IProcess2> openedProcessList,
final Set<IUpdateItemType> types) {
return Collections.emptyList(); // no, default
}
protected void checkAndSetParameters(IProcess2 process2) {
}
// ------------------------------------------------------------------------------
public List<UpdateResult> checkJobItemsForUpdate(IProgressMonitor parentMonitor, final Set<IUpdateItemType> types) {
if (types == null || types.isEmpty()) {
return null;
}
List<IProcess2> openedProcessList = CoreRuntimePlugin.getInstance().getDesignerCoreService()
.getOpenedProcess(RepositoryUpdateManager.getEditors());
try {
List<UpdateResult> resultList = new ArrayList<UpdateResult>();
if (enableCheckItem()) {
// closed job
resultList.addAll(checkJobItems(parentMonitor, types, openedProcessList));
}
// opened job
for (IProcess2 process : openedProcessList) {
checkMonitorCanceled(parentMonitor);
parentMonitor.subTask(RepositoryUpdateManager.getUpdateJobInfor(process.getProperty()));
List<UpdateResult> resultFromProcess = getResultFromProcess(process, types);
if (resultFromProcess != null) {
resultList.addAll(resultFromProcess);
}
parentMonitor.worked(1);
}
List<UpdateResult> otherUpdateResults = getOtherUpdateResults(parentMonitor, openedProcessList, types);
if (otherUpdateResults != null) {
resultList.addAll(otherUpdateResults);
}
parentMonitor.done();
return resultList;
} catch (PersistenceException e) {
//
}
return null;
}
private boolean isOpenedItem(Item openedItem, MultiKeyMap openProcessMap) {
if (openedItem == null) {
return false;
}
Property property = openedItem.getProperty();
return (openProcessMap.get(property.getId(), property.getLabel(), property.getVersion()) != null);
}
private List<UpdateResult> checkJobItems(IProgressMonitor monitor, final Set<IUpdateItemType> types,
List<IProcess2> openedProcessList) throws PersistenceException {
List<Relation> relations = getRelations();
if (relations == null) {
return Collections.emptyList();
}
List<UpdateResult> resultList = new ArrayList<UpdateResult>();
MultiKeyMap openProcessMap = createOpenProcessMap(openedProcessList);
int size = openedProcessList.size();
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
size = size + relations.size();
monitor.beginTask(Messages.getString("RepositoryUpdateManager.Check"), size); //$NON-NLS-1$
monitor.setTaskName(Messages.getString("RepositoryUpdateManager.ItemsToUpdate")); //$NON-NLS-1$
for (int i = 0; i < relations.size(); i++) {
Relation relation = relations.get(i);
IRepositoryViewObject relatedObj = factory.getLastVersion(relation.getId());
if (relatedObj == null) {
continue;
}
List<IRepositoryViewObject> allVersionList = new ArrayList<IRepositoryViewObject>();
//
// must match TalendDesignerPrefConstants.CHECK_ONLY_LAST_VERSION
boolean checkOnlyLastVersion = Boolean.parseBoolean(CoreRuntimePlugin.getInstance().getDesignerCoreService()
.getPreferenceStore("checkOnlyLastVersion")); //$NON-NLS-1$
// get all version
allVersionList = new ArrayList<IRepositoryViewObject>();
if (!checkOnlyLastVersion) {
List<IRepositoryViewObject> allVersion = factory.getAllVersion(relatedObj.getId());
for (IRepositoryViewObject object : allVersion) {
if (factory.getStatus(object) != ERepositoryStatus.LOCK_BY_OTHER) {
allVersionList.add(object);
}
}
} else {
// assume that repositoryObj is the last version, otherwise we should call
// factory.getLastVersion(repositoryObj.getId());
IRepositoryViewObject lastVersion = relatedObj; // factory.getLastVersion(repositoryObj.getId());
ERepositoryStatus status = factory.getStatus(lastVersion);
if (status != ERepositoryStatus.LOCK_BY_OTHER) {
allVersionList.add(lastVersion);
}
}
//
checkMonitorCanceled(monitor);
for (IRepositoryViewObject repositoryObj : allVersionList) {
checkMonitorCanceled(monitor);
Item item = repositoryObj.getProperty().getItem();
// avoid the opened job
if (isOpenedItem(item, openProcessMap)) {
continue;
}
monitor.subTask(RepositoryUpdateManager.getUpdateJobInfor(repositoryObj.getProperty()));
List<UpdateResult> updatesNeededFromItems = getUpdatesNeededFromItems(monitor, item, types);
if (updatesNeededFromItems != null && !updatesNeededFromItems.isEmpty()) {
resultList.addAll(updatesNeededFromItems);
}
if (!ERepositoryStatus.LOCK_BY_USER.equals(factory.getStatus(item))) {
if (repositoryObj instanceof RepositoryObject) {
((RepositoryObject) repositoryObj).unload();
}
}
}
monitor.worked(1);
}
return resultList;
}
protected List<UpdateResult> getUpdatesNeededFromItems(IProgressMonitor parentMonitor, Item item,
final Set<IUpdateItemType> types) {
if (item == null || types == null) {
return null;
}
IDesignerCoreService designerCoreService = CoreRuntimePlugin.getInstance().getDesignerCoreService();
if (designerCoreService == null) {
return null;
}
//
IProcess process = null;
if (item instanceof ProcessItem) {
process = designerCoreService.getProcessFromProcessItem((ProcessItem) item);
} else if (item instanceof JobletProcessItem) {
process = designerCoreService.getProcessFromJobletProcessItem((JobletProcessItem) item);
}
//
if (process != null && process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
// for save item
List<UpdateResult> resultFromProcess = getResultFromProcess(process2, types);
for (UpdateResult result : resultFromProcess) {
result.setFromItem(true);
if (result.getJob() != null) {
result.setJob(null);
}
result.setObjectId(item.getProperty().getId());
}
process2.dispose();
return resultFromProcess;
}
return null;
}
protected List<UpdateResult> getResultFromProcess(IProcess process, final Set<IUpdateItemType> types) {
if (process == null || types == null) {
return null;
}
List<UpdateResult> resultList = new ArrayList<UpdateResult>();
if (process instanceof IProcess2) {
IProcess2 process2 = (IProcess2) process;
IUpdateManager updateManager = process2.getUpdateManager();
checkAndSetParameters(process2);
//
for (IUpdateItemType type : types) {
List<UpdateResult> updatesNeeded = updateManager.getUpdatesNeeded(type, false);
if (updatesNeeded != null) {
resultList.addAll(updatesNeeded);
}
}
if (updateManager instanceof AbstractUpdateManager) {
AbstractUpdateManager manager = (AbstractUpdateManager) updateManager;
manager.setFromRepository(false);
}
}
return resultList;
}
protected List<UpdateResult> updateAllProcess(IProgressMonitor parentMonitor, List<UpdateResult> resultList,
List<IProcess2> openedProcessList, final Set<IUpdateItemType> types, final boolean onlySimpleShow) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
if (factory == null) {
return resultList;
}
IDesignerCoreService designerCoreService = CoreRuntimePlugin.getInstance().getDesignerCoreService();
if (designerCoreService == null) {
return resultList;
}
List<IRepositoryViewObject> processRep = new ArrayList<IRepositoryViewObject>();
try {
ERepositoryObjectType jobType = ERepositoryObjectType.PROCESS;
if (jobType != null) {
processRep.addAll(factory.getAll(jobType, true));
}
ERepositoryObjectType jobletType = ERepositoryObjectType.JOBLET;
if (jobletType != null) {
processRep.addAll(factory.getAll(jobletType, true));
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// all the jobs
for (IRepositoryViewObject process : processRep) {
Item item = process.getProperty().getItem();
boolean found = false;
for (IProcess2 open : openedProcessList) {
if (open.getId().equals(item.getProperty().getId())) {
found = true;
}
}
if (found) {
continue;
}
checkMonitorCanceled(parentMonitor);
parentMonitor.subTask(RepositoryUpdateManager.getUpdateJobInfor(item.getProperty()));
// List<UpdateResult> resultFromProcess = getResultFromProcess(process, types, onlySimpleShow);
List<UpdateResult> resultFromProcess = getUpdatesNeededFromItems(parentMonitor, item, types);
if (resultFromProcess != null) {
resultList.addAll(resultFromProcess);
}
parentMonitor.worked(1);
}
return resultList;
}
/**
* Create a hashmap for fash lookup of the specified IProcess.
*
* @param openedProcessList
* @return
*/
private MultiKeyMap createOpenProcessMap(List<IProcess2> openedProcessList) {
MultiKeyMap map = new MultiKeyMap();
if (openedProcessList != null) {
for (IProcess2 process : openedProcessList) {
map.put(process.getId(), process.getName(), process.getVersion(), process);
}
}
return map;
}
private void checkMonitorCanceled(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
throw new OperationCanceledException(UpdatesConstants.MONITOR_IS_CANCELED);
}
}
}

View File

@@ -1,94 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update;
import java.util.Collection;
import org.talend.core.model.process.INode;
import org.talend.core.model.process.IProcess;
import org.talend.core.runtime.i18n.Messages;
/**
* DOC ggu class global comment. Detailled comment
*/
public final class UpdateManagerHelper {
// define in extension point
public static final String TYPE_JOBLET_CONTEXT = "JOBLET_CONTEXT"; //$NON-NLS-1$
public static void setConfigrationForReadOnlyJob(IProcess process, UpdateResult result) {
if (process != null && process.isReadOnly()) {
result.setChecked(false);
result.setRemark(Messages.getString("UpdateManagerHelper.ReadOnlyProcessUpdateWarningMessages")); //$NON-NLS-1$
result.setReadOnlyProcess(true);
}
}
public static String getResultTaskInfor(UpdateResult result) {
if (result == null) {
return UpdatesConstants.EMPTY;
}
StringBuffer infor = new StringBuffer();
infor.append(result.getName());
infor.append(UpdatesConstants.LEFT_BRACKETS);
infor.append(result.getCategory());
infor.append(UpdatesConstants.SEGMENT);
infor.append(result.getJobInfor());
infor.append(UpdatesConstants.RIGHT_BRACKETS);
return infor.toString();
}
public static String getRenamedDisplay(final String oldName, final String newName) {
if (oldName == null || newName == null) {
return null;
}
return oldName + UpdatesConstants.RENAME_SIGN + newName;
}
public static String getCollectionsDisplay(Object object, boolean all) {
if (object == null) {
return null;
}
String displayName = UpdatesConstants.EMPTY;
if (object instanceof Collection) {
for (Object obj : (Collection<?>) object) {
String tmp = null;
if (obj instanceof String) {
tmp = (String) obj;
} else if (obj instanceof INode) {
INode node = (INode) obj;
if (all && !node.getLabel().equals(node.getUniqueName())) {
tmp = node.getLabel() + addBrackets(node.getUniqueName());
} else {
tmp = node.getLabel();
}
}
if (tmp != null) {
displayName = displayName + UpdatesConstants.SEGMENT + tmp;
}
}
if (displayName.startsWith(UpdatesConstants.SEGMENT)) {
displayName = displayName.substring(1);
}
}
return displayName;
}
public static String addBrackets(String value) {
if (value == null || UpdatesConstants.EMPTY.equals(value.trim())) {
return UpdatesConstants.EMPTY;
}
return UpdatesConstants.SPACE + UpdatesConstants.LEFT_BRACKETS + value + UpdatesConstants.RIGHT_BRACKETS;
}
}

View File

@@ -1,86 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update.extension;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.talend.core.model.process.IProcess2;
import org.talend.core.model.relationship.Relation;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.update.IUpdateItemType;
import org.talend.core.model.update.RepositoryUpdateManagerHelper;
import org.talend.core.model.update.UpdateResult;
/**
* created by ggu on Mar 28, 2014 Detailled comment
*
* If refactor RepositoryUpdateManager totally later, need change this class, because there are some dupliates.
*
*/
public abstract class AbstractRepository4ProcessUpdateManagerProvider extends AbstractRepositoryNodeUpdateManagerProvider {
@Override
protected List<UpdateResult> retrieveUpdateResults(IProgressMonitor monitor, final IRepositoryViewObject object) {
if (object == null) {
return Collections.emptyList();
}
RepositoryUpdateManagerHelper helper = new RepositoryUpdateManagerHelper() {
@Override
protected boolean enableCheckItem() {
return AbstractRepository4ProcessUpdateManagerProvider.this.enableCheckItem(object);
}
@Override
protected List<Relation> getRelations() {
return AbstractRepository4ProcessUpdateManagerProvider.this.getRelations(object);
}
@Override
protected List<UpdateResult> getOtherUpdateResults(IProgressMonitor monitor, List<IProcess2> openedProcessList,
final Set<IUpdateItemType> types) {
return AbstractRepository4ProcessUpdateManagerProvider.this.getOtherUpdateResults(monitor, object,
openedProcessList, types);
}
@Override
protected void checkAndSetParameters(IProcess2 process2) {
AbstractRepository4ProcessUpdateManagerProvider.this.checkAndSetParameters(object, process2);
}
};
return helper.checkJobItemsForUpdate(monitor, getTypes());
}
protected boolean enableCheckItem(final IRepositoryViewObject object) {
return false; // false, will only check the opened job.
}
protected List<Relation> getRelations(final IRepositoryViewObject object) {
// get the relation of item with other items
return null;
}
protected List<UpdateResult> getOtherUpdateResults(IProgressMonitor monitor, final IRepositoryViewObject object,
List<IProcess2> openedProcessList, final Set<IUpdateItemType> types) {
return Collections.emptyList(); // no, default
}
protected void checkAndSetParameters(final IRepositoryViewObject object, IProcess2 process2) {
// nothing to do
}
}

View File

@@ -1,117 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update.extension;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.talend.core.model.properties.Item;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.update.UpdateResult;
import org.talend.repository.ProjectManager;
import org.talend.repository.model.ERepositoryStatus;
import org.talend.repository.model.IRepositoryNode;
import org.talend.repository.model.IRepositoryNode.ENodeType;
/**
* created by ggu on Mar 27, 2014 Detailled comment
*
*/
public abstract class AbstractRepositoryNodeUpdateManagerProvider extends AbstractRepositoryUpdateManagerProvider {
/*
* (non-Javadoc)
*
* @see
* org.talend.core.model.update.extension.IRepositoryUpdateManagerProvider#validateAction(org.eclipse.jface.viewers
* .TreeViewer, org.eclipse.jface.viewers.IStructuredSelection)
*/
@Override
public boolean validateAction(TreeViewer viewer, IStructuredSelection selection) {
if (super.validateAction(viewer, selection)) {
Object obj = selection.getFirstElement();
if (obj instanceof IRepositoryNode) {
return validRepositoryNode((IRepositoryNode) obj);
}
}
return false;
}
protected boolean validRepositoryNode(IRepositoryNode repNode) {
// not in current project
if (!ProjectManager.getInstance().isInCurrentMainProject(repNode)) {
// element
if (ENodeType.REPOSITORY_ELEMENT.equals(repNode.getType())) {
ERepositoryObjectType objectType = repNode.getObjectType();
if (validRepositoryType(objectType) && isDeletedNode(repNode)) {
return true;
}
}
}
return false;
}
/**
*
* DOC ggu Comment method "validRepositoryType".
*
* @param objectType repository type.
* @return
*/
protected abstract boolean validRepositoryType(ERepositoryObjectType objectType);
/**
*
* DOC ggu Comment method "isDeletedNode".
*
* @param repNode
* @return
*/
protected boolean isDeletedNode(IRepositoryNode repNode) {
Item item = repNode.getObject().getProperty().getItem();
ERepositoryStatus status = factory.getStatus(item);
if (!status.equals(ERepositoryStatus.DELETED)) {
return true;
}
return false;
}
@Override
protected List<UpdateResult> retrieveUpdateResults(IProgressMonitor monitor, IStructuredSelection selection) {
if (selection != null) {
Object node = selection.getFirstElement();
if (node != null && node instanceof IRepositoryNode) {
IRepositoryNode repNode = (IRepositoryNode) node;
IRepositoryViewObject object = repNode.getObject();
return retrieveUpdateResults(monitor, object);
}
}
return null;
}
/**
*
* DOC ggu Comment method "retrieveUpdateResults".
*
*
* retrieve the view object, like item, metadata table, query, etc.
*
* @param monitor
* @param object
* @return
*/
protected abstract List<UpdateResult> retrieveUpdateResults(IProgressMonitor monitor, IRepositoryViewObject object);
}

View File

@@ -1,197 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update.extension;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.model.update.IUpdateItemType;
import org.talend.core.model.update.UpdateResult;
import org.talend.core.model.update.UpdatesConstants;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.designer.core.IDesignerCoreService;
import org.talend.repository.model.IProxyRepositoryFactory;
/**
* created by ggu on Mar 27, 2014 Detailled comment
*
*/
public abstract class AbstractRepositoryUpdateManagerProvider implements IRepositoryUpdateManagerProvider {
protected IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
/*
* (non-Javadoc)
*
* @see
* org.talend.core.model.update.extension.IRepositoryUpdateManagerProvider#validateAction(org.eclipse.jface.viewers
* .TreeViewer, org.eclipse.jface.viewers.IStructuredSelection)
*/
@Override
public boolean validateAction(TreeViewer viewer, IStructuredSelection selection) {
if (viewer != null && selection != null) {
// only work for one item
if (!selection.isEmpty() && selection.size() == 1) {
// not read only
if (!factory.isUserReadOnlyOnCurrentProject()) {
Object obj = selection.getFirstElement();
if (obj != null) {
return true;
}
}
}
}
return false;
}
/*
* (non-Javadoc)
*
* @see
* org.talend.core.model.update.extension.IRepositoryUpdateManagerProvider#updateForRepository(IStructuredSelection)
*/
@Override
public boolean updateForRepository(IStructuredSelection selection) {
if (!needPropagate(selection)) {
return false;
}
/*
* NOTE: Most of functions are similar with RepositoryUpdateManager.doWork, so if update the old dowork, maybe
* need update here too.
*/
// retrieve Results
List<UpdateResult> updateResults = retrieveUpdateResults(selection);
// valid results
List<UpdateResult> validResults = validResults(updateResults);
// do update
if (doUpdate(validResults)) {
return true;
}
return false;
}
/**
*
* DOC ggu Comment method "needPropagate".
*
* @return
*/
@Override
public boolean needPropagate(IStructuredSelection selection) {
if (needForcePropagation(selection)) {
return true;
}
// by default, will propagate always.
return true;
}
@Override
public boolean needForcePropagation(IStructuredSelection selection) {
return false; // diable to force propagating by default
}
/**
*
* DOC ggu Comment method "retrieveUpdateResults".
*
* @param node
* @return
*/
protected List<UpdateResult> retrieveUpdateResults(final IStructuredSelection selection) {
final List<UpdateResult> results = new ArrayList<UpdateResult>();
boolean cancelable = !needForcePropagation(selection);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
List<UpdateResult> returnResult = retrieveUpdateResults(monitor, selection);
if (returnResult != null) {
results.addAll(returnResult);
}
}
};
try {
final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(null);
dialog.run(true, cancelable, runnable);
// PlatformUI.getWorkbench().getProgressService().run(true, true, runnable);
return results;
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
if (!e.getMessage().equals(UpdatesConstants.MONITOR_IS_CANCELED)) {
ExceptionHandler.process(e); // if not cancele, log it.
}
}
return Collections.emptyList();
}
protected abstract Set<IUpdateItemType> getTypes();
/**
*
* DOC ggu Comment method "retrieveUpdateResults".
*
* retrieve the result for current node.
*
* @param selection
* @return
*/
protected abstract List<UpdateResult> retrieveUpdateResults(IProgressMonitor monitor, IStructuredSelection selection);
/**
*
* DOC ggu Comment method "validResults".
*
* will do some validation for results, if need.
*
* @param updateResults
* @return
*/
protected List<UpdateResult> validResults(List<UpdateResult> updateResults) {
return updateResults; // by default, nothing to check and valid. so retrurn it directly.
}
/**
*
* DOC ggu Comment method "doUpdate".
*
* @param validResults
* @return
*/
protected boolean doUpdate(List<UpdateResult> validResults) {
if (validResults != null && !validResults.isEmpty()) {
IDesignerCoreService designerCoreService = CoreRuntimePlugin.getInstance().getDesignerCoreService();
if (designerCoreService != null) {
return designerCoreService.executeUpdatesManager(validResults, false);
}
}
return false;
}
}

View File

@@ -1,24 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update.extension;
/**
* DOC ggu class global comment. Detailled comment
*/
public enum EPriority {
LOWEST,
LOW,
NORMAL,
HIGH,
HIGHEST;
}

View File

@@ -1,100 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update.extension;
import org.talend.core.model.update.IUpdateItemType;
/**
* DOC ggu class global comment. Detailled comment
*
* this is from extension point.
*/
public class ExtensionUpdateItemType implements IUpdateItemType {
private final String name, bundleId;
private String displayLabel, description;
public ExtensionUpdateItemType(String name, String bundlId) {
super();
this.name = name;
this.bundleId = bundlId;
}
public ExtensionUpdateItemType(String name, String bundleId, String displayLabel) {
this(name, bundleId);
this.displayLabel = displayLabel;
}
public void setDisplayLabel(String displayLabel) {
this.displayLabel = displayLabel;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String getName() {
return this.name;
}
@Override
public String getDisplayLabel() {
return this.displayLabel;
}
public String getBundleId() {
return this.bundleId;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ExtensionUpdateItemType)) {
return false;
}
ExtensionUpdateItemType other = (ExtensionUpdateItemType) obj;
if (this.name == null) {
if (other.name != null) {
return false;
}
} else if (!this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public String toString() {
return this.name;
}
}

View File

@@ -1,121 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update.extension;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.talend.core.model.process.IProcess;
import org.talend.core.model.update.IUpdateItemType;
import org.talend.core.model.update.UpdateResult;
/**
* DOC ggu class global comment. Detailled comment
*/
public interface IProcessUpdateManagerProvider extends IUpdateManagerProvider {
/**
*
* DOC ggu Comment method "validate".
*
* check the type need current provider to do or not.
*
* @param type
* @return
*/
boolean validate(IUpdateItemType type);
/**
*
* DOC ggu Comment method "retrieveUpdateResults".
*
* @param process
* @return
*/
List<UpdateResult> retrieveUpdateResults(IProcess process);
/**
*
* DOC ggu Comment method "getDisplayImage".
*
* mostly work for label provider in update manager dialog.
*
* @return
*/
Object getDisplayImage(Object element, int columnIndex);
/**
*
* DOC ggu Comment method "getDisplayText".
*
* mostly work for label provider in update manager dialog.
*
* @return
*/
String getDisplayText(Object element, int columnIndex);
/**
*
* DOC ggu Comment method "getDisplayCategory".
*
* mostly work for label provider in update manager dialog.
*
* @param result
* @return
*/
String getDisplayCategory(UpdateResult result);
/**
*
* DOC ggu Comment method "getResultName".
*
* the label of result.
*
* @param result
* @return
*/
String getResultName(UpdateResult result);
/**
*
* DOC ggu Comment method "doUpdate".
*
* Will do the real update by result via GEF command, if it's opened job/joblet to be dirty by the command.
*
* @param result
* @param monitor
* @return
*/
boolean doUpdate(IProgressMonitor monitor, UpdateResult result);
/**
*
* DOC ggu Comment method "postUpdate".
*
* most like needRefreshRelatedViews, after udpate, need something to do.
*
* @param results
*/
void postUpdate(List<UpdateResult> results);
/**
*
* DOC ggu Comment method "needRefreshRelatedViews".
*
* @param results all result to check the related views
* @return will refresh the view ids.
*/
Set<String> needRefreshRelatedViews(List<UpdateResult> results);
}

View File

@@ -1,64 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update.extension;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
/**
* DOC ggu class global comment. Detailled comment
*/
public interface IRepositoryUpdateManagerProvider extends IUpdateManagerProvider {
/**
*
* DOC ggu Comment method "validateAction".
*
* Mostly work for the method init(TreeViewer,IStructuredSelection) of class DetecteViewImpactAction.
*
* @param viewer
* @param selection
* @return
*/
boolean validateAction(TreeViewer viewer, IStructuredSelection selection);
/**
*
* DOC ggu Comment method "needPropagate".
*
* @param selection
* @return
*/
boolean needPropagate(IStructuredSelection selection);
/**
*
* DOC ggu Comment method "needForcePropagation".
*
* @param selection
* @return if true, will force propagate to update manager.
*/
boolean needForcePropagation(IStructuredSelection selection);
/**
*
* DOC ggu Comment method "updateForRepository".
*
* Work for DetecteViewImpactAction.
*
* @param selection
* @return true, update successfully
*/
boolean updateForRepository(IStructuredSelection selection);
}

View File

@@ -1,20 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update.extension;
/**
* DOC ggu class global comment. Detailled comment
*/
public interface IUpdateManagerProvider {
}

View File

@@ -1,334 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update.extension;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.talend.core.model.metadata.builder.connection.AbstractMetadataObject;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
import org.talend.core.model.metadata.builder.connection.MetadataTable;
import org.talend.core.model.metadata.builder.connection.Query;
import org.talend.core.model.metadata.builder.connection.SAPFunctionUnit;
import org.talend.core.model.process.IProcess;
import org.talend.core.model.properties.ConnectionItem;
import org.talend.core.model.properties.ContextItem;
import org.talend.core.model.properties.Item;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.repository.ISubRepositoryObject;
import org.talend.core.model.update.IUpdateItemType;
import org.talend.core.model.update.RepositoryUpdateManager;
import org.talend.core.model.update.UpdateResult;
import org.talend.core.prefs.ITalendCorePrefConstants;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.designer.core.IDesignerCoreService;
import org.talend.repository.model.RepositoryNode;
/**
* DOC ggu class global comment. Detailled comment
*/
public enum UpdateManagerProviderDetector {
INSTANCE;
private UpdateManagerProviderReader reader = new UpdateManagerProviderReader();
public IUpdateItemType[] getAllUpdateItemTypes() {
return reader.getExtensionUpdateItemTypes().values().toArray(new IUpdateItemType[0]);
}
public IUpdateItemType getUpdateItemType(String name) {
return reader.getExtensionUpdateItemTypes().get(name);
}
/**
*
* DOC ggu Comment method "retrieveProcessUpdateResults".
*
* @param process check the process to detect the different.
* @param type
* @return
*/
public List<UpdateResult> retrieveProcessUpdateResults(IProcess process, IUpdateItemType type) {
List<UpdateResult> results = new ArrayList<UpdateResult>();
IProcessUpdateManagerProvider[] processProviders = reader.getProcessProviders();
for (IProcessUpdateManagerProvider provider : processProviders) {
if (provider.validate(type)) {
List<UpdateResult> processResults = provider.retrieveUpdateResults(process);
if (processResults != null) {
results.addAll(processResults);
}
}
}
return results;
}
/**
*
* DOC ggu Comment method "getDisplayImage".
*
* mainly for label provider of update manager dialog.
*
* @param type
* @return
*/
public Object getDisplayImage(Object element, int columnIndex) {
IProcessUpdateManagerProvider[] processProviders = reader.getProcessProviders();
for (IProcessUpdateManagerProvider provider : processProviders) {
Object displayImage = provider.getDisplayImage(element, columnIndex);
if (displayImage != null) {
return displayImage;
}
}
return null;
}
/**
*
* DOC ggu Comment method "getDisplayText".
*
* mainly for label provider of update manager dialog.
*
* @param element
* @param columnIndex
* @return
*/
public String getDisplayText(Object element, int columnIndex) {
IProcessUpdateManagerProvider[] processProviders = reader.getProcessProviders();
for (IProcessUpdateManagerProvider provider : processProviders) {
String displayText = provider.getDisplayText(element, columnIndex);
if (displayText != null) {
return displayText;
}
}
return null;
}
/**
*
* DOC ggu Comment method "getDisplayCategory".
*
* mainly for label provider of update manager dialog.
*
* @param result
* @return
*/
public String getDisplayCategory(UpdateResult result) {
IProcessUpdateManagerProvider[] processProviders = reader.getProcessProviders();
for (IProcessUpdateManagerProvider provider : processProviders) {
String displayLabel = provider.getDisplayCategory(result);
if (displayLabel != null) {
return displayLabel;
}
}
return null;
}
/**
*
* DOC ggu Comment method "getResultName".
*
* the label of result.
*
* @param result
* @return
*/
public String getResultName(UpdateResult result) {
IProcessUpdateManagerProvider[] processProviders = reader.getProcessProviders();
for (IProcessUpdateManagerProvider provider : processProviders) {
String displayLabel = provider.getResultName(result);
if (displayLabel != null) {
return displayLabel;
}
}
return null;
}
/**
*
* DOC ggu Comment method "doUpdate".
*
* @param monitor
* @param result
* @return
*/
public boolean doUpdate(IProgressMonitor monitor, UpdateResult result) {
boolean updated = false;
if (result != null) {
IProcessUpdateManagerProvider[] processProviders = reader.getProcessProviders();
for (IProcessUpdateManagerProvider provider : processProviders) {
if (provider.doUpdate(monitor, result)) {
updated = true;
}
}
}
return updated;
}
/**
*
* DOC ggu Comment method "needRefreshRelatedViews".
*
* @param results
* @return
*/
public Set<String> needRefreshRelatedViews(List<UpdateResult> results) {
Set<String> viewIds = new HashSet<String>();
IProcessUpdateManagerProvider[] processProviders = reader.getProcessProviders();
for (IProcessUpdateManagerProvider provider : processProviders) {
Set<String> viewSet = provider.needRefreshRelatedViews(results);
if (viewSet != null) {
viewIds.addAll(viewSet);
}
}
return viewIds;
}
/**
*
* DOC ggu Comment method "postUpdate".
*
* after update, will do something.
*
* @param results
*/
public void postUpdate(List<UpdateResult> results) {
IProcessUpdateManagerProvider[] processProviders = reader.getProcessProviders();
for (IProcessUpdateManagerProvider provider : processProviders) {
provider.postUpdate(results);
}
}
/**
*
* DOC ggu Comment method "validateAction".
*
* Worked for DetecteViewImpactAction
*
* @param viewer
* @param selection
* @return
*/
public boolean validateAction(TreeViewer viewer, IStructuredSelection selection) {
IRepositoryUpdateManagerProvider[] repositoryProviders = reader.getRepositoryProviders();
for (IRepositoryUpdateManagerProvider provider : repositoryProviders) {
if (provider.validateAction(viewer, selection)) { // if one is valid, will enable this action.
return true;
}
}
return false;
}
/**
*
* DOC ggu Comment method "updateForRepository".
*
* Worked for DetecteViewImpactAction
*
* @param node
* @return
*/
public boolean updateForRepository(IStructuredSelection selection, boolean needConfirm) {
boolean forcePropagation = false;
IRepositoryUpdateManagerProvider[] repositoryProviders = reader.getRepositoryProviders();
for (IRepositoryUpdateManagerProvider provider : repositoryProviders) {
if (provider.needForcePropagation(selection)) {
forcePropagation = true;
}
}
if (!forcePropagation && needConfirm) {
IDesignerCoreService designerCoreService = CoreRuntimePlugin.getInstance().getDesignerCoreService();
boolean deactive = designerCoreService != null ? Boolean.parseBoolean(designerCoreService
.getPreferenceStore(ITalendCorePrefConstants.DEACTIVE_REPOSITORY_UPDATE)) : true;
if (deactive) {// disable to do update
return false;
}
boolean propagated = RepositoryUpdateManager.openPropagationDialog();
if (!propagated) {
return false;
}
}
boolean updated = false;
for (IRepositoryUpdateManagerProvider provider : repositoryProviders) {
// if one upate successfully, will return true.
if (provider.updateForRepository(selection)) {
updated = true;
}
}
// Old Updates
if (doOldUpdates(selection)) {
updated = true;
}
if (!updated) {
// nothing to update
RepositoryUpdateManager.openNoModificationDialog();
}
return updated;
}
private boolean doOldUpdates(IStructuredSelection selection) {
Object firstElement = selection.getFirstElement();
if (firstElement == null || !(firstElement instanceof RepositoryNode)) {
return false;
}
RepositoryNode node = (RepositoryNode) firstElement;
if (node.getObject() instanceof ISubRepositoryObject) {
ISubRepositoryObject subObject = (ISubRepositoryObject) node.getObject();
if (subObject != null) {
// schema
AbstractMetadataObject metadataObject = subObject.getAbstractMetadataObject();
if (metadataObject instanceof MetadataTable) {
return RepositoryUpdateManager.updateSchema((MetadataTable) metadataObject, node, false, false);
} else
// query
if (metadataObject instanceof Query) {
return RepositoryUpdateManager.updateQuery((Query) metadataObject, node, false, false);
} else
// sap function
if (metadataObject instanceof SAPFunctionUnit) {
return RepositoryUpdateManager.updateSAPFunction((SAPFunctionUnit) metadataObject, false, false);
}
}
} else {
IRepositoryViewObject object = node.getObject();
if (object != null) {
Item item = object.getProperty().getItem();
if (item != null) {
// context
if (item instanceof ContextItem) {
return RepositoryUpdateManager.updateContext((ContextItem) item, false, false);
} else
// connection
if (item instanceof ConnectionItem) {
Connection connection = ((ConnectionItem) item).getConnection();
if (connection instanceof DatabaseConnection) {
return RepositoryUpdateManager.updateDBConnection((ConnectionItem) item, false, false);
} else {
return RepositoryUpdateManager.updateFileConnection((ConnectionItem) item, false, false);
}
}
}
}
}
return false;
}
}

View File

@@ -1,77 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update.extension;
/**
* DOC ggu class global comment. Detailled comment
*/
class UpdateManagerProviderExtension {
private final String id;
private String name, description, overrideId;
private EPriority priority;
private IUpdateManagerProvider provider;
public UpdateManagerProviderExtension(String id) {
super();
this.id = id;
}
public String getId() {
return this.id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public EPriority getPriority() {
return this.priority;
}
public void setPriority(EPriority priority) {
this.priority = priority;
}
public IUpdateManagerProvider getProvider() {
return this.provider;
}
public void setProvider(IUpdateManagerProvider provider) {
this.provider = provider;
}
public String getOverrideId() {
return this.overrideId;
}
public void setOverrideId(String overrideId) {
this.overrideId = overrideId;
}
}

View File

@@ -1,243 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update.extension;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.SafeRunner;
import org.osgi.framework.FrameworkUtil;
import org.talend.core.model.update.EUpdateItemType;
import org.talend.core.model.update.IUpdateItemType;
import org.talend.core.utils.RegistryReader;
/**
* DOC ggu class global comment. Detailled comment
*/
public class UpdateManagerProviderReader extends RegistryReader {
private static Logger log = Logger.getLogger(UpdateManagerProviderReader.class);
/**
* key is name of type.
*/
private Map<String, IUpdateItemType> extensionUpdateItemTypes = new HashMap<String, IUpdateItemType>();
/**
* key is id of provider.
*/
private Map<String, UpdateManagerProviderExtension> processProvidersMap = new HashMap<String, UpdateManagerProviderExtension>();
private Map<String, UpdateManagerProviderExtension> repositorProvidersMap = new HashMap<String, UpdateManagerProviderExtension>();
private IProcessUpdateManagerProvider[] processProviders;
private IRepositoryUpdateManagerProvider[] repositoryProviders;
protected UpdateManagerProviderReader() {
super(FrameworkUtil.getBundle(UpdateManagerProviderReader.class).getSymbolicName(), "updateManager_provider"); //$NON-NLS-1$
init();
}
Map<String, IUpdateItemType> getExtensionUpdateItemTypes() {
return this.extensionUpdateItemTypes;
}
IProcessUpdateManagerProvider[] getProcessProviders() {
return this.processProviders;
}
IRepositoryUpdateManagerProvider[] getRepositoryProviders() {
return this.repositoryProviders;
}
private void init() {
// init types
for (EUpdateItemType type : EUpdateItemType.values()) {
extensionUpdateItemTypes.put(type.getName(), type);
}
readRegistry();
//
List<IUpdateManagerProvider> validProcessProviders = processProviders(new HashMap<String, UpdateManagerProviderExtension>(
processProvidersMap));
Iterator<IUpdateManagerProvider> processItr = validProcessProviders.iterator();
while (processItr.hasNext()) {
IUpdateManagerProvider provider = processItr.next();
// make sure the provider is for process only.
if (!IProcessUpdateManagerProvider.class.isInstance(provider)) {
processItr.remove();
}
}
processProviders = validProcessProviders.toArray(new IProcessUpdateManagerProvider[0]);
//
List<IUpdateManagerProvider> validRepProviders = processProviders(new HashMap<String, UpdateManagerProviderExtension>(
repositorProvidersMap));
Iterator<IUpdateManagerProvider> repItr = validRepProviders.iterator();
while (repItr.hasNext()) {
IUpdateManagerProvider provider = repItr.next();
// make sure the provider is for reposiory only.
if (!IRepositoryUpdateManagerProvider.class.isInstance(provider)) {
repItr.remove();
}
}
repositoryProviders = validRepProviders.toArray(new IRepositoryUpdateManagerProvider[0]);
}
private List<IUpdateManagerProvider> processProviders(Map<String, UpdateManagerProviderExtension> providersMap) {
// process override and wrong provider setting.
List<String> wrongProviders = new ArrayList<String>();
List<String> overrideIds = new ArrayList<String>();
for (String key : providersMap.keySet()) {
UpdateManagerProviderExtension prividerExtension = providersMap.get(key);
String overrideId = prividerExtension.getOverrideId();
if (overrideId != null) {
overrideIds.add(overrideId);
}
//
IUpdateManagerProvider provider = prividerExtension.getProvider();
if (provider == null) {
wrongProviders.add(prividerExtension.getId());
}
}
// override ids
for (String id : overrideIds) {
providersMap.remove(id);
}
// wrong providers
for (String id : wrongProviders) {
providersMap.remove(id);
}
// sort
List<UpdateManagerProviderExtension> providerExtensions = new ArrayList<UpdateManagerProviderExtension>(
providersMap.values());
Collections.sort(providerExtensions, new Comparator<UpdateManagerProviderExtension>() {
@Override
public int compare(UpdateManagerProviderExtension arg1, UpdateManagerProviderExtension arg2) {
return arg2.getPriority().compareTo(arg1.getPriority());
}
});
//
List<IUpdateManagerProvider> providers = new ArrayList<IUpdateManagerProvider>();
for (UpdateManagerProviderExtension extension : providerExtensions) {
IUpdateManagerProvider provider = extension.getProvider();
if (provider != null) {
providers.add(provider);
}
}
return providers;
}
/*
* (non-Javadoc)
*
* @see org.talend.core.utils.RegistryReader#readElement(org.eclipse.core.runtime.IConfigurationElement)
*/
@Override
protected boolean readElement(final IConfigurationElement element) {
if ("UpdateItemType".equals(element.getName())) { //$NON-NLS-1$
SafeRunner.run(new RegistryReader.RegistrySafeRunnable() {
@Override
public void run() throws Exception {
try {
final String name = element.getAttribute("name"); //$NON-NLS-1$
final String description = element.getAttribute("description"); //$NON-NLS-1$
final String displayLabel = element.getAttribute("displayLabel"); //$NON-NLS-1$
ExtensionUpdateItemType type = new ExtensionUpdateItemType(name, element.getContributor().getName(),
displayLabel);
type.setDescription(description);
IUpdateItemType existedType = extensionUpdateItemTypes.get(name);
if (existedType != null) {
if (existedType instanceof ExtensionUpdateItemType) {
log.error(MessageFormat.format("There is a same type {0} with different bundles {1} and {2}.", //$NON-NLS-1$
name, type.getBundleId(), ((ExtensionUpdateItemType) existedType).getBundleId()));
} else {
log.error(MessageFormat.format("There is a same type {0} in EUpdateItemType for bundle {1}.", //$NON-NLS-1$
name, type.getBundleId()));
}
} else {
extensionUpdateItemTypes.put(name, type);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
});
return true;
} else if ("ProcessUpdateManagerProvider".equals(element.getName())) {//$NON-NLS-1$
readProviderElement(element, processProvidersMap);
return true;
} else if ("RepositoryUpdateManagerProvider".equals(element.getName())) { //$NON-NLS-1$
readProviderElement(element, repositorProvidersMap);
return true;
}
return false;
}
/**
* DOC ggu Comment method "readProviderElement".
*
* @param element
*/
private void readProviderElement(final IConfigurationElement element,
final Map<String, UpdateManagerProviderExtension> providersMap) {
SafeRunner.run(new RegistryReader.RegistrySafeRunnable() {
@Override
public void run() throws Exception {
try {
final String id = element.getAttribute("id"); //$NON-NLS-1$
final String name = element.getAttribute("name"); //$NON-NLS-1$
final String description = element.getAttribute("description"); //$NON-NLS-1$
final String overrideId = element.getAttribute("override"); //$NON-NLS-1$
String priorityString = element.getAttribute("priority"); //$NON-NLS-1$
final EPriority priority = (priorityString != null && priorityString.length() > 0) ? EPriority
.valueOf(priorityString.toUpperCase()) : EPriority.NORMAL;
UpdateManagerProviderExtension providerExtension = new UpdateManagerProviderExtension(id);
providerExtension.setName(name);
providerExtension.setDescription(description);
providerExtension.setPriority(priority);
providerExtension.setOverrideId(overrideId);
IUpdateManagerProvider provider = (IUpdateManagerProvider) element.createExecutableExtension("provider"); //$NON-NLS-1$
providerExtension.setProvider(provider);
providersMap.put(id, providerExtension);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
});
}
}

View File

@@ -1,516 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternCompiler;
import org.apache.oro.text.regex.PatternMatcher;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;
import org.apache.oro.text.regex.Perl5Substitution;
import org.apache.oro.text.regex.Substitution;
import org.apache.oro.text.regex.Util;
import org.eclipse.emf.common.util.EList;
import org.eclipse.swt.graphics.Point;
import org.talend.core.model.context.UpdateContextVariablesHelper;
import org.talend.core.model.process.EParameterFieldType;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.utils.TalendQuoteUtils;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ElementValueType;
/**
* cli class global comment. Detailled comment
*/
public final class ParameterValueUtil {
private ParameterValueUtil() {
}
@SuppressWarnings("unchecked")
public static void renameValues(final IElementParameter param, final String oldName, final String newName) {
if (param == null || oldName == null || newName == null) {
return;
}
// boolean flag = true;
// if (param.getFieldType() == EParameterFieldType.MEMO_SQL) {
// flag = false;
// }
if (param.getValue() instanceof String) { // for TEXT / MEMO etc..
String value = (String) param.getValue();
if (value.contains(oldName)) {
// param.setValue(value.replaceAll(oldName, newName));
// String newValue = renameValues(value, oldName, newName, flag);
String newValue = splitQueryData(oldName, newName, value);
if (!value.equals(newValue)) {
param.setValue(newValue);
}
}
} else if (param.getValue() instanceof List) { // for TABLE
List<Map<String, Object>> tableValues = (List<Map<String, Object>>) param.getValue();
for (Map<String, Object> line : tableValues) {
for (String key : line.keySet()) {
Object cellValue = line.get(key);
if (cellValue instanceof String) { // cell is text so
// rename data if
// needed
String value = (String) cellValue;
if (value.contains(oldName)) {
// line.put(key, value.replaceAll(oldName,
// newName));
// String newValue = renameValues(value, oldName, newName, flag);
String newValue = splitQueryData(oldName, newName, value);
if (!value.equals(newValue)) {
line.put(key, newValue);
}
}
}
}
}
}
}
public static String renameValues(final String value, final String oldName, final String newName, boolean flag) {
if (value == null || oldName == null || newName == null) {
return value; // keep original value
}
PatternCompiler compiler = new Perl5Compiler();
Perl5Matcher matcher = new Perl5Matcher();
matcher.setMultiline(true);
Perl5Substitution substitution = new Perl5Substitution(newName + "$2", Perl5Substitution.INTERPOLATE_ALL); //$NON-NLS-1$
Pattern pattern;
try {
pattern = compiler.compile(getQuotePattern(oldName));
} catch (MalformedPatternException e) {
return value; // keep original value
}
if (matcher.contains(value, pattern)) {
// replace
String returnValue = "";
if (value.contains(TalendQuoteUtils.getQuoteChar()) && !flag) {
// returnValue = splitQueryData(matcher, pattern, substitution, value, Util.SUBSTITUTE_ALL);
returnValue = splitQueryData(oldName, newName, value);
} else {
returnValue = Util.substitute(matcher, pattern, substitution, value, Util.SUBSTITUTE_ALL);
}
return returnValue;
}
return value; // keep original value
}
// function before TDI-29092 modify,this function seems only rename variables in context,I put this funciton back
// incase any problem with the new function and we can refer the old one to check the problem.
public static String splitQueryData(PatternMatcher matcher, Pattern pattern, Substitution sub, String value, int numSubs) {
String[] split = value.split("\"");
int i = 0;
String replace = "";
for (String s : split) {
if (i % 2 == 0) {
replace = s;
if (i != 0) {
if (matcher.contains(value, pattern)) {
replace = split[i].toString();
split[i] = Util.substitute(matcher, pattern, sub, replace, numSubs);
}
}
}
i++;
}
String returnValue = "";
for (int t = 1; t < split.length; t++) {
if (t % 2 == 0) {
returnValue += split[t];
} else {
returnValue += "\"" + split[t] + "\"";
}
}
return returnValue;
}
// for bug 12594 split "; for bug 29092(it has JUnits)
public static String splitQueryData(String oldName, String newName, String value) {
// example:"drop table "+context.oracle_schema+".\"TDI_26803\""
// >>>>>>>>_*_(const)__ _____*_(varible)_______ __*_(const)___
final int length = value.length();
// quotaStrings which stores the start and end point for all const strings in the value
LinkedHashMap<Integer, Integer> quotaStrings = new LinkedHashMap<Integer, Integer>();
List<Point> functionNameAreas = new ArrayList<Point>();
// get and store all start and end point of const strings
int start = -1;
int end = -2;
char ch;
for (int i = 0; i < length; i++) {
ch = value.charAt(i);
if (ch == '\"') {
// in case of cases :
// case 1 : [ "select * from " + context.table + " where value = \"context.table\"" ]
// case 2 : [ "select * from " + context.table + " where value = \"\\" + context.table +
// "\\context.table\"" ]
if (isEscapeSequence(value, i)) {
continue;
}
// [0 <= start] >> in case the first const String position compute error
if (0 <= start && end < start) {
end = i;
quotaStrings.put(start, end);
} else {
start = i;
}
}
}
{
// in case the value has not complete quota
// exapmle > "select a,context.b from " + context.b + "where value = context.b
// **but** maybe more impossible truth is that
// they write this(context.b) just want to use it as a varible...
// so maybe should not set the string behind the quota as a const by default..
// ---*--- the following code is set the string behind the quota as a const
// if (0 <= start && end < start) {
// end = length - 1;
// quotaStrings.put(start, end);
// }
}
// find the varible string, do replace, then concat them
StringBuffer strBuffer = new StringBuffer();
String subString = null;
int vStart = 0;
int vEnd = 0;
int methodMaxIndex = 0;
int calcMaxIndex = 0;
start = 0;
end = 0;
for (Entry<Integer, Integer> entry : quotaStrings.entrySet()) {
start = entry.getKey();
end = entry.getValue() + 1;
vEnd = start;
if (vStart == start) {
// const string follow with const string, maybe won't happen...
// get the const string
subString = value.substring(start, end);
if (start < methodMaxIndex) {
subString = subString.replaceAll(oldName, newName);
}
} else {
// get the varible string, do replace, then append it
subString = value.substring(vStart, vEnd);
calcMaxIndex = calcMethodArea(subString, value, vStart, functionNameAreas, methodMaxIndex);
if (methodMaxIndex < calcMaxIndex) {
methodMaxIndex = calcMaxIndex;
}
String replacedString = doVaribleReplace(oldName, newName, value, functionNameAreas, vStart, vEnd);
strBuffer.append(replacedString);
// get the const string
// deal with: context.getProperty("test") + "test"
subString = value.substring(start, end);
if (start < methodMaxIndex) {
subString = subString.replaceAll(oldName, newName);
}
}
// append the const string
strBuffer.append(subString);
// update the varible string start point
vStart = end;
}
// in case the last string of the value is a varible string
// then get it, and do replace, finally append it.
if (vStart < length) {
vEnd = length;
String replacedString = doVaribleReplace(oldName, newName, value, functionNameAreas, vStart, vEnd);
strBuffer.append(replacedString);
}
return strBuffer.toString();
}
/**
* DOC cmeng Comment method "doVaribleReplace".
*
* @param oldName
* @param newName
* @param value
* @param functionNameAreas
* @param vStart
* @param vEnd
*/
private static String doVaribleReplace(String oldName, String newName, String value, List<Point> functionNameAreas,
int vStart, int vEnd) {
if (value.trim().isEmpty()) {
return value;
}
StringBuffer replacedString = new StringBuffer();
int replaceableStart = vStart;
int replaceableEnd = vEnd;
for (Point functionNameArea : functionNameAreas) {
if (vEnd <= functionNameArea.x) {
break;
}
if (functionNameArea.y <= vStart) {
continue;
}
if (replaceableStart < functionNameArea.x) {
replaceableEnd = functionNameArea.x;
String replaceableString = value.substring(replaceableStart, replaceableEnd);
replacedString.append(doReplace(oldName, newName, replaceableString));
replacedString.append(doReplace(oldName, newName, value.substring(functionNameArea.x, functionNameArea.y)));
} else {
replacedString.append(doReplace(oldName, newName, value.substring(functionNameArea.x, functionNameArea.y)));
}
replaceableStart = functionNameArea.y;
}
if (replaceableStart < vEnd) {
String replaceableString = value.substring(replaceableStart, vEnd);
replacedString.append(doReplace(oldName, newName, replaceableString));
}
return replacedString.toString();
}
private static String doReplace(String oldName, String newName, String value) {
if (value.trim().isEmpty()) {
return value;
}
String vOldName = oldName.replaceAll("\\.", "\\\\."); //$NON-NLS-1$ //$NON-NLS-2$
// ((\b\w+\s*\.\s*)+schema(\s*\.\s*\w+)*)|((\b\w+\s*\.\s*)*schema(\s*\.\s*\w+)+)
String regex = "((\\b\\w+\\s*\\.\\s*)+" + vOldName + "\\b)|(\\b" + vOldName + "\\s*\\()"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// obtain all varibles
String[] split = value.split(regex);
Map<String, String> replacedStrings = new HashMap<String, String>();
StringBuffer returnValue = new StringBuffer();
// replace the variables & store both value of old and new
for (String s : split) {
if (s.contains(oldName)) {
replacedStrings.put(s, s.replaceAll("\\b" + oldName + "\\b", newName)); //$NON-NLS-1$ //$NON-NLS-2$
} else {
replacedStrings.put(s, s);
}
}
if (split.length == 1) {
returnValue.append(replacedStrings.get(split[0]));
}
// obtain consts & concat the consts with the variables
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(regex);
Matcher matcher = pattern.matcher(value);
if (matcher.find()) {
int x = matcher.start();
int y = matcher.end();
int curPos = 0;
int valueLength = value.length();
String oldFill = null;
String newFill = null;
String subRegEx = "^" + vOldName + "(\\s*\\.\\s*\\w+)+"; //$NON-NLS-1$ //$NON-NLS-2$
java.util.regex.Pattern subPattern = java.util.regex.Pattern.compile(subRegEx);
while (true) {
if (curPos == valueLength) {
break;
}
if (curPos < x) {
oldFill = value.substring(curPos, x);
if ((newFill = replacedStrings.get(oldFill)) != null) {
returnValue.append(newFill);
} else {
returnValue.append(oldFill);
}
curPos = x;
continue;
}
String matchedString = matcher.group();
Matcher subMatcher = subPattern.matcher(matchedString);
if (subMatcher.find()) {
returnValue.append(matchedString.replaceFirst(vOldName, newName));
} else {
returnValue.append(matchedString);
}
curPos = y;
if (!matcher.find()) {
x = valueLength;
} else {
x = matcher.start();
y = matcher.end();
}
}
}
return returnValue.toString();
}
/**
* DOC cmeng Comment method "isEscapeSequence".
*
* @param value
* @param i
* @return
*/
private static boolean isEscapeSequence(String value, int i) {
boolean isEscapeSequence = false;
for (int index = i; 0 < index; index--) {
if (value.charAt(index - 1) == '\\') {
isEscapeSequence = !isEscapeSequence;
} else {
break;
}
}
return isEscapeSequence;
}
private static int calcMethodArea(String varibleString, String wholeString, int beginIndex, List<Point> functionNameAreas,
int lastIndex) {
// globalMap.get(...)
// String regex = "\\b\\S*\\s*\\.\\s*\\S*\\s*\\(\\z"; //$NON-NLS-1$
// maybe get(...) also is target
String regex = "\\b[\\S\\.]*?\\s*\\("; //$NON-NLS-1$
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(regex);
Matcher matcher = pattern.matcher(varibleString);
int i = 0;
int varibleStringMaxIndex = beginIndex + varibleString.length() - 1;
while (matcher.find()) {
boolean isInQuota = false;
int parenthesisNum = 0;
Point functionNameArea = new Point(beginIndex + matcher.start(), beginIndex + matcher.end());
functionNameAreas.add(functionNameArea);
if (varibleStringMaxIndex < i || varibleStringMaxIndex < lastIndex) {
continue;
}
for (i = matcher.end(); i < wholeString.length(); i++) {
char ch = wholeString.charAt(i);
if (ch == '\"' && !isEscapeSequence(wholeString, i)) {
isInQuota = !isInQuota;
}
if (isInQuota) {
continue;
}
if (ch == '(') {
parenthesisNum++;
} else if (ch == ')') {
parenthesisNum--;
}
if (parenthesisNum < 0) {
break;
}
}
}
return i;
}
public static boolean isUseData(final IElementParameter param, final String name) {
if (param == null || name == null) {
return false;
}
if (param.getValue() instanceof String) { // for TEXT / MEMO etc..
String value = (String) param.getValue();
if (ParameterValueUtil.valueContains(value, name)) {
return true;
}
} else if (param.getValue() instanceof List) { // for TABLE
List<Map<String, Object>> tableValues = (List<Map<String, Object>>) param.getValue();
for (Map<String, Object> line : tableValues) {
for (String key : line.keySet()) {
Object cellValue = line.get(key);
if (cellValue instanceof String) { // cell is text so
// test data
if (ParameterValueUtil.valueContains((String) cellValue, name)) {
return true;
}
}
}
}
}
return false;
}
@SuppressWarnings("unchecked")
public static boolean isUseData(final ElementParameterType param, final String name) {
if (param == null || name == null) {
return false;
}
if (param.getField().equals(EParameterFieldType.TABLE.getName())) { // for TABLE
EList elementValue = param.getElementValue();
if (elementValue != null) {
for (ElementValueType valueType : (List<ElementValueType>) elementValue) {
if (valueType.getValue() != null) { // cell is text so
// test data
if (ParameterValueUtil.valueContains(valueType.getValue(), name)) {
return true;
}
}
}
}
} else {
String value = param.getValue();
if (value != null && ParameterValueUtil.valueContains(value, name)) {
return true;
}
}
return false;
}
public static boolean valueContains(String value, String toTest) {
if (value.contains(toTest)) {
Perl5Matcher matcher = new Perl5Matcher();
Perl5Compiler compiler = new Perl5Compiler();
Pattern pattern;
try {
pattern = compiler.compile(getQuotePattern(toTest));
if (matcher.contains(value, pattern)) {
return true;
}
} catch (MalformedPatternException e) {
throw new RuntimeException(e);
}
}
return false;
}
private static String getQuotePattern(String toTest) {
final String prefix = "\\b("; //$NON-NLS-1$
String suffix = ")\\b"; //$NON-NLS-1$
if (!ContextParameterUtils.isContainContextParam(toTest)) { // context parameter renamed
suffix = ")(\\b|\\_)"; //$NON-NLS-1$
}
return prefix + UpdateContextVariablesHelper.replaceSpecialChar(toTest) + suffix;
}
}

View File

@@ -1,71 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.utils;
import java.util.HashMap;
import java.util.Map;
/**
* created by ggu on Apr 3, 2014 Detailled comment
*
*/
public final class ProductUtils {
/*
* perspectives.
*/
public static final String PERSPECTIVE_DI_ID = "org.talend.rcp.perspective"; //$NON-NLS-1$
public static final String PERSPECTIVE_CAMEL_ID = "org.talend.camel.perspective"; //$NON-NLS-1$
public static final String PERSPECTIVE_DQ_ID = "org.talend.dataprofiler.DataProfilingPerspective"; //$NON-NLS-1$
public static final String PERSPECTIVE_MDM_ID = "org.talend.mdm.perspective"; //$NON-NLS-1$
public static final String PERSPECTIVE_MAPPING_ID = "com.oaklandsw.transform.perspective"; //$NON-NLS-1$
/*
* products.
*/
public static final String PROD_DI = "DI"; //$NON-NLS-1$
public static final String PROD_CAMEL = "CAMEL"; //$NON-NLS-1$
public static final String PROD_DQ = "DQ"; //$NON-NLS-1$
public static final String PROD_MDM = "MDM"; //$NON-NLS-1$
public static final String PROD_MAPPING = "MAPPING"; //$NON-NLS-1$
/*
* mapping.
*/
private static Map<String, String> productPerspectiveMap = new HashMap<String, String>();
static {
productPerspectiveMap.put(PROD_DI, PERSPECTIVE_DI_ID);
productPerspectiveMap.put(PROD_DQ, PERSPECTIVE_DQ_ID);
productPerspectiveMap.put(PROD_CAMEL, PERSPECTIVE_CAMEL_ID);
productPerspectiveMap.put(PROD_MDM, PERSPECTIVE_MDM_ID);
productPerspectiveMap.put(PROD_MAPPING, PERSPECTIVE_MAPPING_ID);
}
/*
*
*/
public static String getPerspectiveId(String product) {
if (product != null) {
return productPerspectiveMap.get(product);
}
return null;
}
}

View File

@@ -1,155 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.ui.context.cmd;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.emf.common.util.EList;
import org.eclipse.gef.commands.Command;
import org.talend.core.model.context.ContextUtils;
import org.talend.core.model.context.JobContext;
import org.talend.core.model.context.JobContextParameter;
import org.talend.core.model.process.IContext;
import org.talend.core.model.process.IContextManager;
import org.talend.core.model.process.IContextParameter;
import org.talend.core.model.properties.ContextItem;
import org.talend.core.ui.context.ContextManagerHelper;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl;
import org.talend.designer.core.ui.editor.cmd.ContextRemoveParameterCommand;
/**
* DOC talend2 class global comment. Detailled comment
*/
public class CheckAndAddContextDNDCommand extends Command {
private List<ContextType> contexts = new ArrayList<ContextType>();
private String defaultContextName;
private String contextItemId;
private IContextManager ctxManager;
private Set<String> addedVars = new HashSet<String>();
private List<ContextParameterType> newAddParameter = new ArrayList<ContextParameterType>();
private ContextManagerHelper helper;
public CheckAndAddContextDNDCommand(List<ContextType> contexts, String defaultContextName, String contextItemId,
IContextManager ctxManager) {
this.contexts = contexts;
this.defaultContextName = defaultContextName;
this.contextItemId = contextItemId;
this.ctxManager = ctxManager;
this.helper = new ContextManagerHelper(ctxManager);
}
/**
* DOC xqliu Comment method "getContextNameParamsMap".
*
* @param contexts
* @return
*/
private static Map<String, List<ContextParameterType>> getContextNameParamsMap(List<ContextType> contexts) {
Map<String, List<ContextParameterType>> map = new HashMap<String, List<ContextParameterType>>();
Iterator<ContextType> iterator = contexts.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ContextTypeImpl) {
ContextTypeImpl contextTypeImpl = (ContextTypeImpl) obj;
String name = contextTypeImpl.getName();
EList<ContextParameterType> contextParameters = contextTypeImpl.getContextParameter();
Iterator<ContextParameterType> contextParas = contextParameters.iterator();
List<ContextParameterType> list = new ArrayList<ContextParameterType>();
while (contextParas.hasNext()) {
ContextParameterType contextParameterType = contextParas.next();
list.add(contextParameterType);
}
map.put(name, list);
}
}
return map;
}
public void execute() {
Map<String, List<ContextParameterType>> map = getContextNameParamsMap(contexts);
if (map.isEmpty()) {
return;
}
ctxManager.getListContext().clear();
for (String key : map.keySet()) {
List<ContextParameterType> list = map.get(key);
newAddParameter.addAll(list);
JobContext jobContext = new JobContext(key);
for (ContextParameterType contextImpl : list) {
JobContextParameter contextParam = new JobContextParameter();
ContextUtils.updateParameter(contextImpl, contextParam);
if (contextItemId != null) {
contextParam.setSource(contextItemId);
}
contextParam.setContext(jobContext);
jobContext.getContextParameterList().add(contextParam);
}
ctxManager.getListContext().add(jobContext);
if (key.equals(defaultContextName)) {
ctxManager.setDefaultContext(jobContext);
}
}
}
public void redo() {
execute();
this.helper.refreshContextView();
}
public void undo() {
ContextManagerHelper helper = new ContextManagerHelper(ctxManager);
List<IContext> removeList = new ArrayList<IContext>();
for (IContext con : ctxManager.getListContext()) {
if (addedVars.contains(con.getName())) {
removeList.add(con);
}
}
ctxManager.getListContext().removeAll(removeList);
for (ContextParameterType defaultContextParamType : newAddParameter) {
ContextItem contextItem = (ContextItem) helper.getParentContextItem(defaultContextParamType);
if (contextItem == null) {
continue;
}
IContextParameter paramExisted = helper.getExistedContextParameter(defaultContextParamType.getName());
if (paramExisted != null) {
// modelManager.onContextRemoveParameter(manager, defaultContextParamType.getName(),
// paramExisted.getSource());
new ContextRemoveParameterCommand(ctxManager, defaultContextParamType.getName(), paramExisted.getSource())
.execute();
}
}
}
}

View File

@@ -1,131 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.ui.context.cmd;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.gef.commands.Command;
import org.talend.core.model.context.ContextUtils;
import org.talend.core.model.context.JobContextParameter;
import org.talend.core.model.process.IContext;
import org.talend.core.model.process.IContextManager;
import org.talend.core.model.process.IContextParameter;
import org.talend.core.model.properties.ContextItem;
import org.talend.core.ui.context.ContextManagerHelper;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.core.ui.editor.cmd.ContextRemoveParameterCommand;
/**
* DOC hwang class global comment. Detailled comment
*/
public class CheckAndAddContextVariablesCommand extends Command {
private IContextManager ctxManager = null;
private List<ContextType> contexts = new ArrayList<ContextType>();
private Set<String> neededVars = new HashSet<String>();
private String defaultContextName = null;
private boolean added;
private String contextItemId = null;
private Set<String> addedVars = new HashSet<String>();
private List<ContextParameterType> newAddParameter = new ArrayList<ContextParameterType>();
private ContextManagerHelper helper;
public CheckAndAddContextVariablesCommand(final List<ContextType> contexts, final String defaultContextName,
final String contextItemId, final Set<String> neededVars, final IContextManager ctxManager, boolean added) {
this.contexts = contexts;
this.defaultContextName = defaultContextName;
this.contextItemId = contextItemId;
this.neededVars = neededVars;
this.ctxManager = ctxManager;
this.added = added;
this.helper = new ContextManagerHelper(ctxManager);
}
public void execute() {
Set<String> addedVars = new HashSet<String>();
for (IContext context : ctxManager.getListContext()) {
ContextType type = ContextUtils.getContextTypeByName(contexts, context.getName(), defaultContextName);
if (type != null) {
for (String var : neededVars) {
if (context.getContextParameter(var) != null) {
continue;
}
ContextParameterType param = ContextUtils.getContextParameterTypeByName(type, var);
newAddParameter.add(param);
if (param != null) {
//
if (added) {
JobContextParameter contextParam = new JobContextParameter();
ContextUtils.updateParameter(param, contextParam);
if (contextItemId != null) {
contextParam.setSource(contextItemId);
}
contextParam.setContext(context);
context.getContextParameterList().add(contextParam);
}
addedVars.add(var);
}
}
}
}
}
public void redo() {
execute();
this.helper.refreshContextView();
}
public void undo() {
ContextManagerHelper helper = new ContextManagerHelper(ctxManager);
List<IContext> removeList = new ArrayList<IContext>();
for (IContext con : ctxManager.getListContext()) {
if (addedVars.contains(con.getName())) {
removeList.add(con);
}
}
ctxManager.getListContext().removeAll(removeList);
for (ContextParameterType defaultContextParamType : newAddParameter) {
ContextItem contextItem = (ContextItem) helper.getParentContextItem(defaultContextParamType);
if (contextItem == null) {
continue;
}
IContextParameter paramExisted = helper.getExistedContextParameter(defaultContextParamType.getName());
if (paramExisted != null) {
// modelManager.onContextRemoveParameter(manager, defaultContextParamType.getName(),
// paramExisted.getSource());
new ContextRemoveParameterCommand(ctxManager, defaultContextParamType.getName(), paramExisted.getSource())
.execute();
}
}
}
}

View File

@@ -1,275 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.ui.context.cmd;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.emf.common.util.EList;
import org.eclipse.gef.commands.Command;
import org.talend.core.model.context.ContextUtils;
import org.talend.core.model.context.JobContext;
import org.talend.core.model.context.JobContextParameter;
import org.talend.core.model.process.IContext;
import org.talend.core.model.process.IContextManager;
import org.talend.core.model.process.IContextParameter;
import org.talend.core.model.properties.ContextItem;
import org.talend.core.ui.context.ContextManagerHelper;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl;
import org.talend.designer.core.ui.editor.cmd.ContextRemoveParameterCommand;
/**
* DOC hwang class global comment. Detailled comment
*/
public class MergeContextVariablesCommand extends Command {
private IContextManager ctxManager = null;
private List<ContextType> contexts = new ArrayList<ContextType>();
private String defaultContextName = null;
private String contextItemId = null;
private Set<String> addedVars = new HashSet<String>();
private Set<String> contextGoupNameSet = new HashSet<String>();
private boolean fillFlag;
private ContextManagerHelper helper;
private List<ContextParameterType> newAddParameter = new ArrayList<ContextParameterType>();
public MergeContextVariablesCommand(List<ContextType> contexts, String defaultContextName, String contextItemId,
IContextManager ctxManager, Set<String> addedVars, Set<String> contextGoupNameSet, boolean fillFlag) {
this.contexts = contexts;
this.defaultContextName = defaultContextName;
this.contextItemId = contextItemId;
this.addedVars = addedVars;
this.ctxManager = ctxManager;
this.fillFlag = fillFlag;
this.contextGoupNameSet = contextGoupNameSet;
this.helper = new ContextManagerHelper(ctxManager);
}
public void execute() {
Map<String, List<ContextParameterType>> map = getContextNameParamsMap(contexts);
if (map.isEmpty()) {
return;
}
Set<String> existGroupNameSet = new HashSet<String>();
Set<String> addedContextGroupNames = new HashSet<String>();
Set<String> alreadyUpdateNameSet = new HashSet<String>();
for (IContext con : ctxManager.getListContext()) {
existGroupNameSet.add(con.getName());
}
if (contextGoupNameSet.isEmpty()) {
contextGoupNameSet.add(defaultContextName);
}
for (String key : map.keySet()) {
for (String groupName : contextGoupNameSet) {
boolean isExtraGroup = false;
for (String existGroup : existGroupNameSet) {
if (key.equals(existGroup)) {
isExtraGroup = true;
alreadyUpdateNameSet.add(existGroup);
break;
}
}
if (key.equals(groupName) || isExtraGroup) {
List<ContextParameterType> list = map.get(key);
newAddParameter.addAll(list);
JobContext jobContext = new JobContext(key);
boolean isExistContext = false;
if (isExtraGroup) {
for (IContext con : ctxManager.getListContext()) {
if (key.equals(con.getName())) {
if (con instanceof JobContext) {
jobContext = (JobContext) con;
isExistContext = true;
break;
}
}
}
}
// add the new context's parameter into the new context group
setContextParameter(contextItemId, addedVars, list, jobContext);
if (!isExistContext) {
ctxManager.getListContext().add(jobContext);
addedContextGroupNames.add(jobContext.getName());
}
break;
}
}
}
// if job context group is not in current add's context,then update context group value to default group value
existGroupNameSet.removeAll(alreadyUpdateNameSet);
List<ContextParameterType> list = map.get(defaultContextName);
if (list == null) {
return;
}
for (String existGroup : existGroupNameSet) {
for (IContext con : ctxManager.getListContext()) {
if ((existGroup).equals(con.getName())) {
if (con instanceof JobContext) {
JobContext jobContext = (JobContext) con;
setContextParameter(contextItemId, addedVars, list, jobContext);
}
}
}
}
if (fillFlag) {
// if the new conext group not in the job's context, then update the new context group value to the default
// group value of the job
List<IContextParameter> contextParameterList = ctxManager.getDefaultContext().getContextParameterList();
if (contextParameterList == null) {
return;
}
Set<String> existVars = new HashSet<String>();
for (IContextParameter ctxPara : contextParameterList) {
String ctxParaName = ctxPara.getName();
if (!addedVars.contains(ctxParaName)) {
existVars.add(ctxParaName);
}
}
for (String addedGroup : addedContextGroupNames) {
for (IContext con : ctxManager.getListContext()) {
if (addedGroup.equals(con.getName())) {
if (con instanceof JobContext) {
JobContext jobContext = (JobContext) con;
setContextParameter(existVars, contextParameterList, jobContext);
}
}
}
}
}
}
/**
* add the variables from ctxParams into JobContext.
*
* @param addedVars the variables need to adding
* @param ctxParams the list of IContextParameter
* @param jobContext the JobContext
*/
private static void setContextParameter(Set<String> addedVars, List<IContextParameter> ctxParams, JobContext jobContext) {
for (IContextParameter contextImpl : ctxParams) {
for (String var : addedVars) {
if (var.equals(contextImpl.getName())) {
JobContextParameter contextParam = new JobContextParameter();
ContextUtils.updateParameter(contextImpl, contextParam);
if (contextImpl.getSource() != null) {
contextParam.setSource(contextImpl.getSource());
}
contextParam.setContext(jobContext);
jobContext.getContextParameterList().add(contextParam);
}
}
}
}
/**
* DOC xqliu Comment method "getContextNameParamsMap".
*
* @param contexts
* @return
*/
private static Map<String, List<ContextParameterType>> getContextNameParamsMap(List<ContextType> contexts) {
Map<String, List<ContextParameterType>> map = new HashMap<String, List<ContextParameterType>>();
Iterator<ContextType> iterator = contexts.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ContextTypeImpl) {
ContextTypeImpl contextTypeImpl = (ContextTypeImpl) obj;
String name = contextTypeImpl.getName();
EList<ContextParameterType> contextParameters = contextTypeImpl.getContextParameter();
Iterator<ContextParameterType> contextParas = contextParameters.iterator();
List<ContextParameterType> list = new ArrayList<ContextParameterType>();
while (contextParas.hasNext()) {
ContextParameterType contextParameterType = contextParas.next();
list.add(contextParameterType);
}
map.put(name, list);
}
}
return map;
}
/**
* add the variables from ctxParams into JobContext.
*
* @param contextItemId the ContextItem's property Id
* @param addedVars the variables need to adding
* @param ctxParams the list of IContextParameter
* @param jobContext the JobContext
*/
public static void setContextParameter(String contextItemId, Set<String> addedVars, List<ContextParameterType> ctxParams,
JobContext jobContext) {
for (ContextParameterType contextImpl : ctxParams) {
for (String var : addedVars) {
if (var.equals(contextImpl.getName())) {
JobContextParameter contextParam = new JobContextParameter();
ContextUtils.updateParameter(contextImpl, contextParam);
if (contextItemId != null) {
contextParam.setSource(contextItemId);
}
contextParam.setContext(jobContext);
jobContext.getContextParameterList().add(contextParam);
}
}
}
}
public void redo() {
execute();
this.helper.refreshContextView();
}
public void undo() {
List<IContext> removeList = new ArrayList<IContext>();
for (IContext con : ctxManager.getListContext()) {
if (addedVars.contains(con.getName())) {
removeList.add(con);
}
}
ctxManager.getListContext().removeAll(removeList);
for (ContextParameterType defaultContextParamType : newAddParameter) {
ContextItem contextItem = (ContextItem) helper.getParentContextItem(defaultContextParamType);
if (contextItem == null) {
continue;
}
IContextParameter paramExisted = helper.getExistedContextParameter(defaultContextParamType.getName());
if (paramExisted != null) {
// modelManager.onContextRemoveParameter(manager, defaultContextParamType.getName(),
// paramExisted.getSource());
new ContextRemoveParameterCommand(ctxManager, defaultContextParamType.getName(), paramExisted.getSource())
.execute();
}
}
}
}

View File

@@ -1,102 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.ui.metadata.extended.command;
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.gef.commands.Command;
import org.eclipse.jface.dialogs.MessageDialog;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.MetadataSchema;
import org.talend.core.model.metadata.editor.MetadataTableEditor;
import org.talend.core.runtime.i18n.Messages;
/**
* DOC amaumont class global comment. Detailled comment <br/>
*
* $Id$
*
*/
public class MetadataExportXmlCommand extends Command {
private File file;
private MetadataTableEditor extendedTableModel;
/**
* DOC amaumont MetadataPasteCommand constructor comment.
*
* @param extendedTableModel
* @param extendedTable
* @param validAssignableType
* @param indexStartAdd
*/
public MetadataExportXmlCommand(MetadataTableEditor extendedTableModel,
File file) {
super();
this.file = file;
this.extendedTableModel = extendedTableModel;
}
/*
* (non-Javadoc)
*
* @see org.talend.commons.ui.command.CommonCommand#execute()
*/
@Override
public void execute() {
// export file if it not exists and if it exists, show up a confirm
// dialog.
if (file != null) {
if (file.exists()) {
boolean flag = MessageDialog.openConfirm(null,
Messages.getString("MetadataExportXmlCommand_title"), //$NON-NLS-1$
Messages.getString("MetadataExportXmlCommand_message")); //$NON-NLS-1$
if (flag) {
excuteExportFile();
} else {
return;
}
} else {
excuteExportFile();
}
}
}
/**
* show up a confirm dialog
*
* DOC hfchang Comment method "excuteExportFile".
*/
public void excuteExportFile() {
try {
file.createNewFile();
if (extendedTableModel != null) {
IMetadataTable currentTable = extendedTableModel
.getMetadataTable();
// get all the columns from the table
if (currentTable != null) {
MetadataSchema.saveMetadataColumnToFile(file, currentTable);
}
}
} catch (IOException e) {
ExceptionHandler.process(e);
} catch (ParserConfigurationException e) {
ExceptionHandler.process(e);
}
}
}

View File

@@ -1,38 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.utils;
import org.talend.core.model.metadata.IDatabaseConstant;
import org.talend.core.model.process.EParameterFieldType;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.INode;
/**
* created by ldong on Jan 16, 2015 Detailled comment
*
*/
public class MetaDataDialogUtil {
public static final String PROPERTY = "PROPERTY"; //$NON-NLS-1$
public static boolean isRedShiftNode(INode node) {
if (node != null) {
IElementParameter param = node.getElementParameter(PROPERTY);
if (param != null && param.getFieldType() == EParameterFieldType.PROPERTY_TYPE
&& IDatabaseConstant.REDSHIFT.equals(param.getRepositoryValue())) {
return true;
}
}
return false;
}
}

View File

@@ -1,224 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2005 Actuate Corporation. All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors: Actuate Corporation - initial API and implementation
*******************************************************************************/
package org.talend.datatools.xml.utils;
import java.util.ArrayList;
import java.util.List;
/**
* This class is a Utility class which is used to help UI to populate the list of possible XPath Expressions.
*/
final public class XPathPopulationUtil {
private static final String XPATH_WILDCARD = "*";
private static final String XPATH_ATTR_HEADER_WITH_SLASH = "/@";
private static final String XPATH_ATTR_HEADER_WITH_SQUARE_PATTERN = "\\Q[@\\E";
/**
* This method is used to populate the possible root path expressions List
*
* @param absolutePath must be the absolute path of root path
* @return
*/
public static List populateRootPath(String absolutePath) {
assert absolutePath != null;
List result = new ArrayList();
result.add(absolutePath);
if (absolutePath.startsWith(UtilConstants.XPATH_SLASH)) {
absolutePath = absolutePath.replaceFirst(UtilConstants.XPATH_SLASH, "");
}
String[] xPathFrags = absolutePath.split(UtilConstants.XPATH_SLASH);
for (int i = 1; i < xPathFrags.length; i++) {
String temp = UtilConstants.XPATH_DOUBLE_SLASH;
temp = addXPathFragsToAString(xPathFrags, i, temp);
result.add(temp);
}
return result;
}
/**
* This method appends the items starting from certain index in an array to a String to build an XPath expression
*
* @param xPathFrags the String array
* @param i the index
* @param s the string
* @return
*/
private static String addXPathFragsToAString(String[] xPathFrags, int i, String s) {
for (int j = i; j < xPathFrags.length; j++) {
if (j < xPathFrags.length - 1) {
s += xPathFrags[j] + UtilConstants.XPATH_SLASH;
} else {
s += xPathFrags[j];
}
}
return s;
}
/**
* This method is used to populate the possible column path expressions List
*
* @param rootPath the root path of the table the column in, must be absolute path.
* @param columnPath the absolute column path.
* @return
*/
public static String populateColumnPath(String rootPath, String columnPath) {
assert rootPath != null;
assert columnPath != null;
rootPath = SaxParserUtil.processParentAxis(rootPath);
if (rootPath.equals("//") || rootPath.equals("//*")) {
String[] temp = columnPath.split("\\Q/\\E");
if (temp.length <= 2) {
return null;
} else {
String result = "";
for (int i = 2; i < temp.length; i++) {
result += "/" + temp[i];
}
return result;
}
}
String tempRootPath = rootPath + UtilConstants.XPATH_SLASH;
if (columnPath.startsWith(tempRootPath)) {
return columnPath.replaceFirst("\\Q" + rootPath + "\\E", "");
} else {
return getXPathExpression(rootPath, columnPath);
}
}
/**
* @param rootPath
* @param columnPath
* @return
*/
private static String getXPathExpression(String rootPath, String columnPath) {
String[] rootPathFrags = rootPath.replaceAll(UtilConstants.XPATH_ELEM_INDEX_PATTERN, "").split(UtilConstants.XPATH_SLASH);
String[] columnPathFrags = columnPath.replaceAll(UtilConstants.XPATH_ELEM_INDEX_PATTERN, "").split(
UtilConstants.XPATH_SLASH);
// The length of rootPathFrags and columnPathFrags should larger than 2,
// for the simplest path would be /elementName, which, if being splitted by "/",
// would produces a 2 element string array.
if (rootPathFrags.length < 2 || columnPathFrags.length < 2) {
return null;
}
// The position which starting the common part of root path and column path in columnPathFrags array.
int startingIndex = 0;
// The position which ending the common part of root path and column path in columnPathFrags array
int endingIndex = 0;
// If rootPath starting with "//", then mean the rootPath is a relative path, else,
// the rootPath is an absolute path
if (!rootPath.startsWith(UtilConstants.XPATH_DOUBLE_SLASH)) {
// If rootPath is absolute path, then the startingIndex must be 1.If not then
// the rootPath and columnPath has nothing in common.
if (!is2FragmentsEqual(columnPathFrags[1], rootPathFrags[1])) {
return null;
} else {
rootPathFrags = (UtilConstants.XPATH_SLASH + rootPath).split(UtilConstants.XPATH_SLASH);
}
}
assert rootPathFrags.length >= 3;
String commonRoot = rootPathFrags[2];
startingIndex = getStartingIndex(columnPathFrags, commonRoot);
// If startingIndex == 0, that means the given column path do not have common
if (columnPathFrags.length < startingIndex + 1 || startingIndex == 0) {
return null;
}
endingIndex = getEndingIndex(rootPathFrags, columnPathFrags, startingIndex);
return populateXpathExpression(columnPath, rootPathFrags, startingIndex, endingIndex);
}
/**
* @param columnPathFrags
* @param startingIndex
* @param commonRoot
* @return
*/
private static int getStartingIndex(String[] columnPathFrags, String commonRoot) {
int startingIndex = 0;
for (int i = 1; i < columnPathFrags.length; i++) {
if (is2FragmentsEqual(commonRoot, columnPathFrags[i])) {
startingIndex = i;
break;
}
}
return startingIndex;
}
/**
*
* @param frag1
* @param frag2
* @return
*/
private static boolean is2FragmentsEqual(String frag1, String frag2) {
if (frag1.equals(XPATH_WILDCARD) || frag2.equals(XPATH_WILDCARD)) {
return true;
} else {
return frag1.equals(frag2);
}
}
/**
* @param rootPathFrags
* @param columnPathFrags
* @param startingIndex
* @param endingIndex
* @return
*/
private static int getEndingIndex(String[] rootPathFrags, String[] columnPathFrags, int startingIndex) {
int start = startingIndex;
int endingIndex = 0;
for (int i = startingIndex + 1; i < columnPathFrags.length && i - startingIndex + 2 < rootPathFrags.length; i++) {
if (!is2FragmentsEqual(columnPathFrags[i], rootPathFrags[i - startingIndex + 2])) {
endingIndex = i - 1;
break;
}
start = i;
}
if (endingIndex == 0 && startingIndex != 0) {
endingIndex = start;
}
return endingIndex;
}
/**
* @param columnPath
* @param rootPathFrags
* @param startingIndex
* @param endingIndex
* @return
*/
private static String populateXpathExpression(String columnPath, String[] rootPathFrags, int startingIndex, int endingIndex) {
String result = "";
int fetchBackLevel = rootPathFrags.length - 3 - (endingIndex - startingIndex);
for (int i = 0; i < fetchBackLevel; i++) {
result += "../";
}
return addXPathFragsToAString(columnPath.replaceAll(XPATH_ATTR_HEADER_WITH_SQUARE_PATTERN, XPATH_ATTR_HEADER_WITH_SLASH)
.split(UtilConstants.XPATH_SLASH), endingIndex + 1, result);
}
}

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,135 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Cxf
Bundle-SymbolicName: org.talend.libraries.apache.cxf;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: lib/javax.ws.rs-api-2.0-m10.jar,
lib/neethi-3.0.1.jar,
lib/cxf-api-2.7.7.jar,
lib/cxf-rt-bindings-xml-2.7.7.jar,
lib/cxf-rt-core-2.7.7.jar,
lib/cxf-rt-frontend-jaxrs-2.7.7.jar,
lib/cxf-rt-transports-http-2.7.7.jar,
lib/stax2-api-3.1.1.jar,
lib/woodstox-core-asl-4.2.0.jar,
.
Export-Package: javax.ws.rs,
javax.ws.rs.client,
javax.ws.rs.container,
javax.ws.rs.core,
javax.ws.rs.ext,
org.apache.cxf,
org.apache.cxf.annotations,
org.apache.cxf.attachment,
org.apache.cxf.binding,
org.apache.cxf.binding.xml,
org.apache.cxf.binding.xml.interceptor,
org.apache.cxf.binding.xml.wsdl11,
org.apache.cxf.bindings.xformat,
org.apache.cxf.bus,
org.apache.cxf.bus.blueprint,
org.apache.cxf.bus.extension,
org.apache.cxf.bus.managers,
org.apache.cxf.bus.osgi,
org.apache.cxf.bus.resource,
org.apache.cxf.bus.spring,
org.apache.cxf.buslifecycle,
org.apache.cxf.catalog,
org.apache.cxf.common,
org.apache.cxf.common.annotation,
org.apache.cxf.common.classloader,
org.apache.cxf.common.commands,
org.apache.cxf.common.i18n,
org.apache.cxf.common.injection,
org.apache.cxf.common.jaxb,
org.apache.cxf.common.logging,
org.apache.cxf.common.security,
org.apache.cxf.common.util,
org.apache.cxf.common.xmlschema,
org.apache.cxf.configuration,
org.apache.cxf.configuration.blueprint,
org.apache.cxf.configuration.jsse,
org.apache.cxf.configuration.security,
org.apache.cxf.configuration.spring,
org.apache.cxf.continuations,
org.apache.cxf.databinding,
org.apache.cxf.databinding.source,
org.apache.cxf.databinding.source.mime,
org.apache.cxf.databinding.stax,
org.apache.cxf.endpoint,
org.apache.cxf.extension,
org.apache.cxf.feature,
org.apache.cxf.feature.transform,
org.apache.cxf.feature.validation,
org.apache.cxf.headers,
org.apache.cxf.helpers,
org.apache.cxf.interceptor,
org.apache.cxf.interceptor.security,
org.apache.cxf.interceptor.transform,
org.apache.cxf.internal,
org.apache.cxf.io,
org.apache.cxf.jaxrs,
org.apache.cxf.jaxrs.blueprint,
org.apache.cxf.jaxrs.client,
org.apache.cxf.jaxrs.client.spec,
org.apache.cxf.jaxrs.ext,
org.apache.cxf.jaxrs.ext.form,
org.apache.cxf.jaxrs.ext.multipart,
org.apache.cxf.jaxrs.ext.xml,
org.apache.cxf.jaxrs.impl,
org.apache.cxf.jaxrs.impl.tl,
org.apache.cxf.jaxrs.interceptor,
org.apache.cxf.jaxrs.lifecycle,
org.apache.cxf.jaxrs.model,
org.apache.cxf.jaxrs.model.wadl,
org.apache.cxf.jaxrs.provider,
org.apache.cxf.jaxrs.security,
org.apache.cxf.jaxrs.servlet,
org.apache.cxf.jaxrs.spring,
org.apache.cxf.jaxrs.utils,
org.apache.cxf.jaxrs.utils.multipart,
org.apache.cxf.jaxrs.utils.schemas,
org.apache.cxf.logging,
org.apache.cxf.management,
org.apache.cxf.management.annotation,
org.apache.cxf.message,
org.apache.cxf.phase,
org.apache.cxf.policy,
org.apache.cxf.resource,
org.apache.cxf.security,
org.apache.cxf.security.claims.authorization,
org.apache.cxf.security.transport,
org.apache.cxf.service,
org.apache.cxf.service.factory,
org.apache.cxf.service.invoker,
org.apache.cxf.service.model,
org.apache.cxf.staxutils,
org.apache.cxf.staxutils.transform,
org.apache.cxf.test,
org.apache.cxf.transport,
org.apache.cxf.transport.common.gzip,
org.apache.cxf.transport.http,
org.apache.cxf.transport.http.auth,
org.apache.cxf.transport.http.blueprint,
org.apache.cxf.transport.http.osgi,
org.apache.cxf.transport.http.policy,
org.apache.cxf.transport.http.policy.impl,
org.apache.cxf.transport.http.spring,
org.apache.cxf.transport.https,
org.apache.cxf.transport.servlet,
org.apache.cxf.transport.servlet.servicelist,
org.apache.cxf.transports.http,
org.apache.cxf.transports.http.configuration,
org.apache.cxf.transports.http.internal,
org.apache.cxf.version,
org.apache.cxf.workqueue,
org.apache.cxf.ws.addressing,
org.apache.cxf.ws.addressing.v200403,
org.apache.cxf.ws.addressing.v200408,
org.apache.cxf.ws.addressing.wsdl,
org.apache.cxf.wsdl,
org.apache.cxf.wsdl.http,
org.apache.cxf.wsdl11
Require-Bundle: javax.wsdl;bundle-version="1.6.2",
org.apache.log4j

View File

@@ -1,19 +0,0 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
lib/neethi-3.0.1.jar,\
lib/cxf-2.7.7-modified.jar,\
lib/cxf-xjc-boolean-2.6.2.jar,\
lib/cxf-xjc-bug671-2.6.2.jar,\
lib/cxf-xjc-dv-2.6.2.jar,\
lib/cxf-xjc-runtime-2.6.2.jar,\
lib/cxf-xjc-ts-2.6.2.jar,\
lib/cxf-api-2.7.7.jar,\
lib/cxf-rt-bindings-xml-2.7.7.jar,\
lib/cxf-rt-core-2.7.7.jar,\
lib/cxf-rt-frontend-jaxrs-2.7.7.jar,\
lib/cxf-rt-transports-http-2.7.7.jar,\
lib/woodstox-core-asl-4.2.0.jar,\
lib/stax2-api-3.1.1.jar,\
lib/stax-api-1.0.1.jar

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry exported="true" kind="lib" path="lib/javacsv.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,67 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package routines.system;
/**
* created by talend2 on 2014-4-11 Detailled comment
*
*/
public class Hex {
private static final char[] DIGITS_LOWER = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
public static String encodeHexString(byte[] data) {
return new String(encodeHex(data));
}
private static char[] encodeHex(byte[] data) {
int l = data.length;
char[] out = new char[l << 1];
// two characters form the hex value.
for (int i = 0, j = 0; i < l; i++) {
out[j++] = DIGITS_LOWER[(0xF0 & data[i]) >>> 4];
out[j++] = DIGITS_LOWER[0x0F & data[i]];
}
return out;
}
public static byte[] decodeHex(char[] data) {
int len = data.length;
if ((len & 0x01) != 0) {
throw new RuntimeException("Odd number of characters.");
}
byte[] out = new byte[len >> 1];
// two characters form the hex value.
for (int i = 0, j = 0; j < len; i++) {
int f = toDigit(data[j], j) << 4;
j++;
f = f | toDigit(data[j], j);
j++;
out[i] = (byte) (f & 0xFF);
}
return out;
}
private static int toDigit(char ch, int index) {
int digit = Character.digit(ch, 16);
if (digit == -1) {
throw new RuntimeException("Illegal hexadecimal character " + ch + " at index " + index);
}
return digit;
}
}

View File

@@ -1,47 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package routines.system;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.StreamCorruptedException;
/**
* DOC bchen class global comment. Detailled comment <br/>
*
* $Id: talend.epf 55206 2011-02-15 17:32:14Z mhirt $
*
*/
public class NoHeaderObjectInputStream extends ObjectInputStream {
public NoHeaderObjectInputStream(InputStream in) throws IOException {
super(in);
}
/**
* DOC bchen NoHeaderObjectInputStream constructor comment.
*
* @throws IOException
* @throws SecurityException
*/
protected NoHeaderObjectInputStream() throws IOException, SecurityException {
super();
// TODO Auto-generated constructor stub
}
@Override
protected void readStreamHeader() throws IOException, StreamCorruptedException {
// don't need to check the header
}
}

View File

@@ -1,47 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package routines.system;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
/**
* DOC bchen class global comment. Detailled comment <br/>
*
* $Id: talend.epf 55206 2011-02-15 17:32:14Z mhirt $
*
*/
public class NoHeaderObjectOutputStream extends ObjectOutputStream {
public NoHeaderObjectOutputStream(OutputStream out) throws IOException {
super(out);
}
/**
* DOC bchen TalendObjectOutputStream constructor comment.
*
* @throws IOException
* @throws SecurityException
*/
protected NoHeaderObjectOutputStream() throws IOException, SecurityException {
super();
// TODO Auto-generated constructor stub
}
@Override
protected void writeStreamHeader() throws IOException {
// do nothing
}
}

View File

@@ -1,77 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package routines.system;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
/**
* DOC chuang class global comment. Detailled comment
*/
public class PasswordEncryptUtil {
public static String ENCRYPT_KEY = "Encrypt"; //$NON-NLS-1$
private static String rawKey = "Talend-Key"; //$NON-NLS-1$
private static SecretKey key = null;
private static SecureRandom secureRandom = new SecureRandom();
private static String CHARSET = "UTF-8";
private static SecretKey getSecretKey() throws Exception {
if (key == null) {
byte rawKeyData[] = rawKey.getBytes(CHARSET);//$NON-NLS-1$
DESKeySpec dks = new DESKeySpec(rawKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); //$NON-NLS-1$
key = keyFactory.generateSecret(dks);
}
return key;
}
public static String encryptPassword(String input) throws Exception {
if (input == null || input.length() == 0) {
return input;
}
SecretKey key = getSecretKey();
Cipher c = Cipher.getInstance("DES"); //$NON-NLS-1$
c.init(Cipher.ENCRYPT_MODE, key, secureRandom);
byte[] cipherByte = c.doFinal(input.getBytes(CHARSET));//$NON-NLS-1$
String dec = Hex.encodeHexString(cipherByte);
return dec;
}
public static String decryptPassword(String input) {
if (input == null || input.length() == 0) {
return input;
}
try {
byte[] dec = Hex.decodeHex(input.toCharArray());
SecretKey key = getSecretKey();
Cipher c = Cipher.getInstance("DES"); //$NON-NLS-1$
c.init(Cipher.DECRYPT_MODE, key, secureRandom);
byte[] clearByte = c.doFinal(dec);
return new String(clearByte, CHARSET);
} catch (Exception e) {
//do nothing
}
return input;
}
}

View File

@@ -1,25 +0,0 @@
package routines.system;
/**
* talend pig component helper
*
* @author Administrator
*
*/
public class PigHelper {
private java.util.List<Object[]> pigLatins = new java.util.ArrayList<Object[]>();
public java.util.List<Object[]> getPigLatins() {
return this.pigLatins;
}
public void add(String type, Object pigLatin) {
Object[] pl = new Object[2];
pl[0] = type;
pl[1] = pigLatin;
pigLatins.add(pl);
}
}

View File

@@ -1,41 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package routines.system;
import java.util.HashMap;
/**
* created by hwang on 2014-4-15 Detailled comment
*
*/
public class RuntimeMap {
public static java.util.Map<String, Object> globalTDMMap = null;
private static RuntimeMap runtimeMap;
public static synchronized RuntimeMap getInstance() {
if (runtimeMap == null) {
runtimeMap = new RuntimeMap();
}
return runtimeMap;
}
public java.util.Map<String, Object> getRuntimeMap() {
if (globalTDMMap == null) {
globalTDMMap = new HashMap<String, Object>();
}
return globalTDMMap;
}
}

View File

@@ -1,25 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package routines.system;
/**
* DOC bchen class global comment. Detailled comment <br/>
*
* $Id: talend.epf 55206 2011-02-15 17:32:14Z mhirt $
*
*/
public interface TraceBean {
public boolean equals(TraceBean traceBean);
}

View File

@@ -1,71 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package routines.system;
import java.io.Serializable;
import java.util.LinkedHashMap;
/**
* DOC bchen class global comment. Detailled comment <br/>
*
* $Id: talend.epf 55206 2011-02-15 17:32:14Z mhirt $
*
*/
public class TraceDataBean implements TraceBean, Serializable {
private static final long serialVersionUID = -4580437449518099406L;
private String connectionId;
private int nbLine;
private LinkedHashMap<String, String> data = new LinkedHashMap<String, String>();
public TraceDataBean(String connectionId) {
this.connectionId = connectionId;
}
public String getConnectionId() {
return this.connectionId;
}
public void setConnectionId(String connectionId) {
this.connectionId = connectionId;
}
public int getNbLine() {
return this.nbLine;
}
public void setNbLine(int nbLine) {
this.nbLine = nbLine;
}
public LinkedHashMap<String, String> getData() {
return this.data;
}
public void setData(LinkedHashMap<String, String> data) {
this.data = data;
}
/*
* (non-Javadoc)
*
* @see routines.system.RunTrace.TraceBean#equals(routines.system.RunTrace.TraceBean)
*/
public boolean equals(TraceBean traceBean) {
// TODO Auto-generated method stub
return false;
}
}

View File

@@ -1,42 +0,0 @@
package routines.system;
import java.io.Serializable;
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
/**
* DOC bchen class global comment. Detailled comment <br/>
*
* $Id: talend.epf 55206 2011-02-15 17:32:14Z mhirt $
*
*/
public enum TraceStatusBean implements TraceBean, Serializable {
UI_STATUS,
ID_STATUS,
PAUSE,
NEXT_ROW,
NEXT_BREAKPOINT,
STATUS_OK,
STATUS_WAITING;
public boolean equals(TraceBean traceBean) {
if (traceBean != null && traceBean instanceof TraceStatusBean) {
if (this == ((TraceStatusBean) traceBean)) {
return true;
}
}
return false;
}
}

View File

@@ -1,453 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.repository.ui.utils;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import javax.xml.namespace.QName;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.EList;
import org.eclipse.swt.widgets.Display;
import org.eclipse.xsd.XSDSchema;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.utils.VersionUtils;
import org.talend.commons.utils.data.list.UniqueStringGenerator;
import org.talend.core.context.Context;
import org.talend.core.context.RepositoryContext;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.MappingTypeRetriever;
import org.talend.core.model.metadata.MetadataTalendType;
import org.talend.core.model.metadata.builder.ConvertionHelper;
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
import org.talend.core.model.metadata.builder.connection.MetadataColumn;
import org.talend.core.model.metadata.builder.connection.MetadataTable;
import org.talend.core.model.metadata.builder.connection.XMLFileNode;
import org.talend.core.model.metadata.builder.connection.XmlFileConnection;
import org.talend.core.model.properties.ByteArray;
import org.talend.core.model.properties.ItemState;
import org.talend.core.model.properties.PropertiesFactory;
import org.talend.core.model.properties.Property;
import org.talend.core.model.properties.XmlFileConnectionItem;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.update.RepositoryUpdateManager;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.cwm.helper.ConnectionHelper;
import org.talend.cwm.helper.PackageHelper;
import org.talend.datatools.xml.utils.ATreeNode;
import org.talend.datatools.xml.utils.OdaException;
import org.talend.datatools.xml.utils.XSDPopulationUtil2;
import org.talend.repository.ProjectManager;
import org.talend.repository.model.IProxyRepositoryFactory;
import org.talend.repository.ui.wizards.metadata.connection.files.xml.treeNode.FOXTreeNode;
import org.talend.repository.ui.wizards.metadata.connection.files.xml.util.TreeUtil;
import orgomg.cwm.resource.record.RecordFactory;
import orgomg.cwm.resource.record.RecordFile;
/**
* created by hcyi on Aug 29, 2014 Detailled comment
*
* related to: class PublishMetadataRunnable
*
*/
public final class XsdMetadataUtils {
private static final Pattern PATTERN_TOREPLACE = Pattern.compile("[^a-zA-Z0-9]"); //$NON-NLS-1$
private static final Pattern PATTERN_PUNCT_EXCEPT_SLASH = Pattern.compile("(?![/])\\p{Punct}");//$NON-NLS-1$
private static int orderId;
private static boolean loopElementFound;
public static void createMetadataFromXSD(QName parameter, File schemaFile) {
XSDPopulationUtil2 populationUtil = new XSDPopulationUtil2();
Collection<XmlFileConnectionItem> selectItems = new ArrayList<XmlFileConnectionItem>();
try {
createMetadataFromXSD(parameter, "", "", schemaFile, selectItems, schemaFile, populationUtil);//$NON-NLS-1$//$NON-NLS-2$
} catch (IOException e) {
e.printStackTrace();
}
}
public static void createMetadataFromXSD(QName parameter, String connectionLabel, String portTypeName, String operationName,
File schemaFile) {
XSDPopulationUtil2 populationUtil = new XSDPopulationUtil2();
Collection<XmlFileConnectionItem> selectItems = new ArrayList<XmlFileConnectionItem>();
try {
createMetadataFromXSD(parameter, connectionLabel, portTypeName, operationName, schemaFile, selectItems, schemaFile,
populationUtil);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
*
* DOC hcyi Comment method "createMetadataFromXSD".
*
* @param parameter
* @param portTypeName
* @param operationName
* @param schemaFile
* @param selectItems
* @param zip
* @param populationUtil
* @throws IOException
*/
public static void createMetadataFromXSD(QName parameter, String portTypeName, String operationName, File schemaFile,
Collection<XmlFileConnectionItem> selectItems, File zip, XSDPopulationUtil2 populationUtil) throws IOException {
createMetadataFromXSD(parameter, parameter.getLocalPart(), portTypeName, operationName, schemaFile, selectItems, zip,
populationUtil);
}
/**
*
* DOC wchen Comment method "createMetadataFromXSD".
*
* @param parameter
* @param connectionLabel
* @param portTypeName
* @param operationName
* @param schemaFile
* @param selectItems
* @param zip
* @param populationUtil
* @throws IOException
*/
public static void createMetadataFromXSD(QName parameter, String connectionLabel, String portTypeName, String operationName,
File schemaFile, Collection<XmlFileConnectionItem> selectItems, File zip, XSDPopulationUtil2 populationUtil)
throws IOException {
String name = /* componentName + "_"+ */parameter.getLocalPart();
XmlFileConnection connection = null;
Property connectionProperty = null;
XmlFileConnectionItem connectionItem = null;
String oldConnectionId = null;
String oldTableId = null;
IMetadataTable oldMetadataTable = null;
Map<String, String> oldTableMap = null;
if (!selectItems.isEmpty()) {
boolean needRewrite = false;
for (XmlFileConnectionItem item : selectItems) {
connectionProperty = item.getProperty();
if (connectionProperty.getLabel().equals(name)) {
oldConnectionId = connectionProperty.getId();
connectionItem = item;
connection = (XmlFileConnection) connectionItem.getConnection();
needRewrite = true;
Set<MetadataTable> tables = ConnectionHelper.getTables(connection);
MetadataTable oldTable = null;
if (tables.size() > 0) {
oldTable = tables.toArray(new MetadataTable[0])[0];
oldTableId = oldTable.getId();
oldMetadataTable = ConvertionHelper.convert(oldTable);
}
oldTableMap = RepositoryUpdateManager.getOldTableIdAndNameMap(connectionItem, oldTable, false);
break;
}
}
if (!needRewrite && !isNameValidInXmlFileConnection(parameter, portTypeName, operationName)) {
return;
}
}
connection = ConnectionFactory.eINSTANCE.createXmlFileConnection();
connection.setName(ERepositoryObjectType.METADATA_FILE_XML.getKey());
connectionItem = PropertiesFactory.eINSTANCE.createXmlFileConnectionItem();
connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
connectionProperty.setAuthor(((RepositoryContext) CoreRuntimePlugin.getInstance().getContext()
.getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
connectionProperty.setLabel(connectionLabel);
connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
connectionProperty.setStatusCode(""); //$NON-NLS-1$
connectionItem.setProperty(connectionProperty);
connectionItem.setConnection(connection);
connection.setInputModel(false);
ByteArray byteArray = PropertiesFactory.eINSTANCE.createByteArray();
byteArray.setInnerContentFromFile(zip);
connection.setFileContent(byteArray.getInnerContent());
// don't put any XSD directly inside the xml connection but put zip file
// Use xsd schema file name + zip file name as xml file path in case we need get the root schema of xml
// connection after.
String schemaFileName = schemaFile.getName();
schemaFileName = schemaFileName.substring(0, schemaFileName.lastIndexOf(".")); //$NON-NLS-1$
connection.setXmlFilePath(schemaFileName.concat("_").concat(zip.getName())); //$NON-NLS-1$
try {
String filePath = schemaFile.getPath(); // name of xsd file needed
XSDSchema xsdSchema = populationUtil.getXSDSchema(filePath);
List<ATreeNode> rootNodes = populationUtil.getAllRootNodes(xsdSchema);
ATreeNode node = null;
// try to find the root element needed from XSD file.
// note: if there is any prefix, it will get the node with the first correct name, no matter the prefix.
// once the we can get the correct prefix value from the wsdl, this code should be modified.
for (ATreeNode curNode : rootNodes) {
String curName = (String) curNode.getValue();
if (curName.contains(":")) { //$NON-NLS-1$
// if with prefix, don't care about it for now, just compare the name.
if (curName.split(":")[1].equals(name)) { //$NON-NLS-1$
node = curNode;
break;
}
} else if (curName.equals(name)) {
node = curNode;
break;
}
}
node = populationUtil.getSchemaTree(xsdSchema, node);
orderId = 1;
loopElementFound = false;
if (ConnectionHelper.getTables(connection).isEmpty()) {
MetadataTable table = ConnectionFactory.eINSTANCE.createMetadataTable();
if (oldTableId != null) {
table.setId(oldTableId);
} else {
table.setId(ProxyRepositoryFactory.getInstance().getNextId());
}
RecordFile record = (RecordFile) ConnectionHelper.getPackage(connection.getName(), connection, RecordFile.class);
if (record != null) { // hywang
PackageHelper.addMetadataTable(table, record);
} else {
RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
newrecord.setName(connection.getName());
ConnectionHelper.addPackage(newrecord, connection);
PackageHelper.addMetadataTable(table, newrecord);
}
}
boolean haveElement = false;
for (Object curNode : node.getChildren()) {
if (((ATreeNode) curNode).getType() == ATreeNode.ELEMENT_TYPE) {
haveElement = true;
break;
}
}
List<FOXTreeNode> foxTreeNodes = TreeUtil.getFoxTreeNodesByRootNode(xsdSchema, node, true);
if (foxTreeNodes.size() > 0 && false) {
FOXTreeNode foxTreeNode = foxTreeNodes.get(0);
EList root = connection.getRoot();
if (root != null) {
XMLFileNode xmlFileNode = ConnectionFactory.eINSTANCE.createXMLFileNode();
String currentPath = "/" + foxTreeNode.getLabel();
xmlFileNode.setXMLPath(currentPath);
xmlFileNode.setRelatedColumn(foxTreeNode.getColumnLabel());
xmlFileNode.setAttribute(foxTreeNode.isMain() ? "main" : "branch");
xmlFileNode.setDefaultValue(foxTreeNode.getDefaultValue());
xmlFileNode.setType(foxTreeNode.getDataType());
XMLFileNode originalXmlNode = null;
if (root.size() > 0) {
originalXmlNode = (XMLFileNode) root.get(0);
}
root.clear();
root.add(xmlFileNode);
}
}
fillRootInfo(connection, node, "", !haveElement); //$NON-NLS-1$
} catch (IOException e) {
throw e;
} catch (URISyntaxException e1) {
ExceptionHandler.process(e1);
} catch (OdaException e) {
ExceptionHandler.process(e);
}
// save
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
connectionProperty.setId(factory.getNextId());
try {
// http://jira.talendforge.org/browse/TESB-3655 Remove possible
// schema prefix
String folderPath = getImportedXmlSchemaPath(parameter.getNamespaceURI(), portTypeName, operationName);
IPath path = new Path(folderPath);
factory.create(connectionItem, path, true); // consider this as migration will overwrite the old metadata if
// existing in the same path
if (oldConnectionId != null) {
connectionItem.getProperty().setId(oldConnectionId);
factory.save(connectionItem);
}
propagateSchemaChange(oldMetadataTable, oldTableMap, connection, connectionItem);
ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (URISyntaxException e) {
ExceptionHandler.process(e);
}
}
private static void propagateSchemaChange(final IMetadataTable oldMetaTable, final Map<String, String> oldTableMap,
final XmlFileConnection connection, final XmlFileConnectionItem connectionItem) {
if (oldMetaTable == null) {
return;
}
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MetadataTable newTable = ConnectionHelper.getTables(connection).toArray(new MetadataTable[0])[0];
RepositoryUpdateManager.updateSingleSchema(connectionItem, newTable, oldMetaTable, oldTableMap);
}
});
}
private static void fillRootInfo(XmlFileConnection connection, ATreeNode node, String path, boolean inLoop) {
XMLFileNode xmlNode = ConnectionFactory.eINSTANCE.createXMLFileNode();
xmlNode.setXMLPath(path + '/' + node.getValue());
xmlNode.setOrder(orderId);
orderId++;
MappingTypeRetriever retriever;
String nameWithoutPrefixForColumn;
String curName = (String) node.getValue();
if (curName.contains(":")) { //$NON-NLS-1$
nameWithoutPrefixForColumn = curName.split(":")[1]; //$NON-NLS-1$
} else {
nameWithoutPrefixForColumn = curName;
}
retriever = MetadataTalendType.getMappingTypeRetriever("xsd_id"); //$NON-NLS-1$
xmlNode.setAttribute("attri"); //$NON-NLS-1$
xmlNode.setType(retriever.getDefaultSelectedTalendType(node.getDataType()));
MetadataColumn column = null;
MetadataTable metadataTable = ConnectionHelper.getTables(connection).toArray(new MetadataTable[0])[0];
switch (node.getType()) {
case ATreeNode.ATTRIBUTE_TYPE:
// fix for TDI-20390 and TDI-20671 ,XMLPath for attribute should only store attribute name but not full
// xpath
xmlNode.setXMLPath("" + node.getValue()); //$NON-NLS-1$
column = ConnectionFactory.eINSTANCE.createMetadataColumn();
column.setTalendType(xmlNode.getType());
String uniqueName = extractColumnName(nameWithoutPrefixForColumn, metadataTable.getColumns());
column.setLabel(uniqueName);
xmlNode.setRelatedColumn(uniqueName);
metadataTable.getColumns().add(column);
break;
case ATreeNode.ELEMENT_TYPE:
boolean haveElementOrAttributes = false;
for (Object curNode : node.getChildren()) {
if (((ATreeNode) curNode).getType() != ATreeNode.NAMESPACE_TYPE) {
haveElementOrAttributes = true;
break;
}
}
if (!haveElementOrAttributes) {
xmlNode.setAttribute("branch"); //$NON-NLS-1$
column = ConnectionFactory.eINSTANCE.createMetadataColumn();
column.setTalendType(xmlNode.getType());
uniqueName = extractColumnName(nameWithoutPrefixForColumn, metadataTable.getColumns());
column.setLabel(uniqueName);
xmlNode.setRelatedColumn(uniqueName);
metadataTable.getColumns().add(column);
} else {
xmlNode.setAttribute("main"); //$NON-NLS-1$
}
break;
case ATreeNode.NAMESPACE_TYPE:
xmlNode.setAttribute("ns"); //$NON-NLS-1$
// specific for namespace... no path set, there is only the prefix value.
// this value is saved now in node.getDataType()
xmlNode.setXMLPath(node.getDataType());
xmlNode.setDefaultValue((String) node.getValue());
break;
case ATreeNode.OTHER_TYPE:
break;
}
boolean subElementsInLoop = inLoop;
// will try to get the first element (branch or main), and set it as loop.
if ((!loopElementFound && path.split("/").length == 2 && node.getType() == ATreeNode.ELEMENT_TYPE) || subElementsInLoop) { //$NON-NLS-1$
connection.getLoop().add(xmlNode);
loopElementFound = true;
subElementsInLoop = true;
} else {
connection.getRoot().add(xmlNode);
}
if (node.getChildren().length > 0) {
for (Object curNode : node.getChildren()) {
if (!path.contains("/" + (String) node.getValue() + "/")) { //$NON-NLS-1$ //$NON-NLS-2$
fillRootInfo(connection, (ATreeNode) curNode, path + '/' + node.getValue(), subElementsInLoop);
}
}
}
}
private static String extractColumnName(String currentExpr, List<MetadataColumn> fullSchemaTargetList) {
String columnName = currentExpr.startsWith("@") ? currentExpr.substring(1) : currentExpr; //$NON-NLS-1$
columnName = PATTERN_TOREPLACE.matcher(columnName).replaceAll("_"); //$NON-NLS-1$
UniqueStringGenerator<MetadataColumn> uniqueStringGenerator = new UniqueStringGenerator<MetadataColumn>(columnName,
fullSchemaTargetList) {
@Override
protected String getBeanString(MetadataColumn bean) {
return bean.getLabel();
}
};
columnName = uniqueStringGenerator.getUniqueString();
return columnName;
}
public static boolean isNameValidInXmlFileConnection(QName parameter, String portTypeName, String operationName) {
try {
XmlFileConnectionItem item = PropertiesFactory.eINSTANCE.createXmlFileConnectionItem();
XmlFileConnection connection = ConnectionFactory.eINSTANCE.createXmlFileConnection();
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setId(ProxyRepositoryFactory.getInstance().getNextId());
property.setLabel(parameter.getLocalPart());
property.setVersion(VersionUtils.DEFAULT_VERSION);
//
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
String folderPath = getImportedXmlSchemaPath(parameter.getNamespaceURI(), portTypeName, operationName);
itemState.setPath(folderPath);
item.setConnection(connection);
item.setProperty(property);
item.setState(itemState);
return ProxyRepositoryFactory.getInstance().isNameAvailable(property.getItem(), parameter.getLocalPart());
} catch (PersistenceException e) {
return false;
} catch (URISyntaxException e) {
return false;
}
}
public static String replaceAllLimited(String input) {
if (input == null) {
return input;
}
return PATTERN_PUNCT_EXCEPT_SLASH.matcher(input).replaceAll("-");//$NON-NLS-1$
}
public static String getImportedXmlSchemaPath(String namespace, String portType, String operation) throws URISyntaxException {
if (namespace == null || portType == null || operation == null) {
throw new URISyntaxException(namespace + " " + portType + " " + operation,//$NON-NLS-1$//$NON-NLS-2$
"The arguments can't be empty, please check");//$NON-NLS-1$
}
StringBuilder builder = new StringBuilder(replaceAllLimited(new URI(namespace).getRawSchemeSpecificPart()));
if (portType.equals("") && operation.equals("")) {//$NON-NLS-1$//$NON-NLS-2$
return builder.toString();
}
if (builder.length() > 0) {
while (builder.charAt(0) == '/') {
builder.deleteCharAt(0);
}
if (builder.charAt(builder.length() - 1) != '/') {
builder.append('/');
}
}
builder.append(portType).append('/').append(operation);
return builder.toString();
}
}

View File

@@ -1,87 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.metadata;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.talend.commons.utils.database.SybaseDatabaseMetaData;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
import org.talend.cwm.helper.SchemaHelper;
import org.talend.utils.sql.metadata.constants.MetaDataConstants;
import orgomg.cwm.resource.relational.Catalog;
import orgomg.cwm.resource.relational.Schema;
/**
* created by talend on Dec 30, 2013 Detailled comment
*
*/
public class SybaseConnectionFillerImpl extends DBConnectionFillerImpl {
private static Logger log = Logger.getLogger(SybaseConnectionFillerImpl.class);
/*
* (non-Javadoc)
*
* @see
* org.talend.core.model.metadata.DBConnectionFillerImpl#fillSchemaToCatalog(org.talend.core.model.metadata.builder
* .connection.Connection, java.sql.DatabaseMetaData, orgomg.cwm.resource.relational.Catalog, java.util.List)
*/
@Override
public List<Schema> fillSchemaToCatalog(Connection dbConn, DatabaseMetaData dbJDBCMetadata, Catalog catalog,
List<String> schemaFilter) throws Throwable {
ResultSet schemaRs = null;
if (dbJDBCMetadata instanceof SybaseDatabaseMetaData) {
schemaRs = ((SybaseDatabaseMetaData) dbJDBCMetadata).getSchemas(catalog.getName(), null);
} else {
schemaRs = dbJDBCMetadata.getSchemas();
}
List<String> schemaNameCacheTmp = new ArrayList<String>();
List<Schema> schemaList = new ArrayList<Schema>();
if (schemaRs != null) {
try {
while (schemaRs.next()) {
String schemaName = schemaRs.getString(MetaDataConstants.TABLE_SCHEM.name());
// MOD mzhao bug 9606 filter duplicated schemas.
if (!schemaNameCacheTmp.contains(schemaName)) {
if (dbConn != null&&!isNullUiSchema(dbConn)) {
// this case we only create one schema which name is same as UiSchema
Schema createByUiSchema = createSchemaByUiSchema((DatabaseConnection) dbConn);
schemaList.add(createByUiSchema);
break;
} else if (isCreateElement(schemaFilter, schemaName)) {
Schema schema = SchemaHelper.createSchema(schemaName);
schemaList.add(schema);
schemaNameCacheTmp.add(schemaName);
}
}
}
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug(e, e);
}
}finally{
schemaRs.close();
}
}
return schemaList;
}
}

Some files were not shown because too many files have changed in this diff Show More