use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method updateRunJobContext.
protected void updateRunJobContext() {
final JobContextManager manager = (JobContextManager) getProcess().getContextManager();
if (manager.isModified()) {
final Map<String, String> nameMap = manager.getNameMap();
// gcui:add a progressDialog.
Shell shell = null;
Display display = PlatformUI.getWorkbench().getDisplay();
if (display != null) {
shell = display.getActiveShell();
}
if (shell == null) {
display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
if (display != null) {
shell = display.getActiveShell();
}
}
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) {
//$NON-NLS-1$
monitor.beginTask(Messages.getString("AbstractMultiPageTalendEditor_pleaseWait"), IProgressMonitor.UNKNOWN);
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
factory.executeRepositoryWorkUnit(new //$NON-NLS-1$
RepositoryWorkUnit<Object>(//$NON-NLS-1$
"..", //$NON-NLS-1$
this) {
@Override
protected void run() throws LoginException, PersistenceException {
try {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
Set<String> curContextVars = getCurrentContextVariables(manager);
IProcess2 process2 = getProcess();
String jobId = process2.getProperty().getId();
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
List<IProcess2> processes = CorePlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
// gcui:if nameMap is empty it do nothing.
if (!nameMap.isEmpty()) {
UpdateRunJobComponentContextHelper.updateItemRunJobComponentReference(factory, nameMap, jobId, curContextVars);
UpdateRunJobComponentContextHelper.updateOpenedJobRunJobComponentReference(processes, nameMap, jobId, curContextVars);
}
// add for bug 9564
List<IRepositoryViewObject> all = factory.getAll(ERepositoryObjectType.PROCESS, true);
List<ProcessItem> allProcess = new ArrayList<ProcessItem>();
for (IRepositoryViewObject repositoryObject : all) {
Item item = repositoryObject.getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
allProcess.add(processItem);
}
}
UpdateRunJobComponentContextHelper.updateRefJobRunJobComponentContext(factory, allProcess, process2);
} catch (PersistenceException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
manager.setModified(false);
}
});
}
});
monitor.done();
if (monitor.isCanceled()) {
try {
//$NON-NLS-1$
throw new InterruptedException("Save Fail");
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
}
};
try {
progressDialog.run(true, true, runnable);
} catch (InvocationTargetException e1) {
ExceptionHandler.process(e1);
} catch (InterruptedException e1) {
ExceptionHandler.process(e1);
}
}
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class QueryGuessCommand method generateNewQuery.
private String generateNewQuery() {
// used for generating new Query.
ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
if (realDBType != null) {
dbType = realDBType;
}
//
if (node != null && node instanceof INode) {
process = ((INode) node).getProcess();
}
if (this.realTableId != null && this.dbNameAndDbTypeMap.containsKey(this.realTableId)) {
dbType = this.dbNameAndDbTypeMap.get(this.realTableId);
}
if (dbType == null || dbType.equals("")) {
//$NON-NLS-1$
IElementParameter ptParam = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (ptParam != null && ptParam.getRepositoryValue() != null) {
if (ptParam.getRepositoryValue().endsWith(EDatabaseTypeName.GENERAL_JDBC.getProduct())) {
dbType = EDatabaseTypeName.GENERAL_JDBC.getDisplayName();
}
}
}
boolean isJdbc = false;
INode connectionNode = null;
IElementParameter existConnection = node.getElementParameter("USE_EXISTING_CONNECTION");
boolean useExistConnection = (existConnection == null ? false : (Boolean) existConnection.getValue());
if (useExistConnection) {
IElementParameter connector = node.getElementParameter("CONNECTION");
if (connector != null) {
String connectorValue = connector.getValue().toString();
List<? extends INode> graphicalNodes = process.getGeneratingNodes();
for (INode node : graphicalNodes) {
if (node.getUniqueName().equals(connectorValue)) {
connectionNode = node;
break;
}
}
}
}
// hywang add for bug 7575
if (dbType != null && dbType.equals(EDatabaseTypeName.GENERAL_JDBC.getDisplayName())) {
isJdbc = true;
String driverClassName = node.getElementParameter("DRIVER_CLASS").getValue().toString();
if (connectionNode != null) {
driverClassName = connectionNode.getElementParameter("DRIVER_CLASS").getValue().toString();
}
driverClassName = TalendTextUtils.removeQuotes(driverClassName);
//
if (driverClassName != null && !"".equals(driverClassName)) {
boolean isContextModeDriverClass = ContextParameterUtils.containContextVariables(driverClassName);
if (isContextModeDriverClass) {
driverClassName = JavaProcessUtil.getContextOriginalValue(process, driverClassName);
}
}
// specil handle Sybase Database's driverClassName
if (driverClassName != null && !"".equals(driverClassName)) {
if (driverClassName.equals("com.sybase.jdbc3.jdbc.SybDataSource")) {
driverClassName = EDatabase4DriverClassName.SYBASEASE.getDriverClass();
}
}
// DRIVER_JAR:
String driverJarName = node.getElementParameter("DRIVER_JAR").getValue().toString();
if (connectionNode != null) {
driverJarName = connectionNode.getElementParameter("DRIVER_JAR").getValue().toString();
}
if (driverJarName != null && driverJarName.startsWith("[") && driverJarName.endsWith("]")) {
driverJarName = driverJarName.substring(1, driverJarName.length() - 1);
if (driverJarName != null && driverJarName.startsWith("{") && driverJarName.endsWith("}")) {
driverJarName = driverJarName.substring(1, driverJarName.length() - 1);
}
}
if (driverJarName != null && !"".equals(driverJarName)) {
boolean isContextMode = ContextParameterUtils.containContextVariables(driverJarName);
if (isContextMode) {
driverJarName = JavaProcessUtil.getContextOriginalValue(process, driverJarName);
}
dbType = extractMeta.getDbTypeByClassNameAndDriverJar(driverClassName, driverJarName);
} else {
dbType = extractMeta.getDbTypeByClassName(driverClassName);
}
DatabaseConnection dbConn = null;
if (dbType == null) {
// handle context mode
if (conn != null) {
if (conn instanceof DatabaseConnection) {
dbConn = (DatabaseConnection) conn;
}
driverClassName = DatabaseConnectionParameterUtil.getTrueParamValue(dbConn, driverClassName);
dbType = extractMeta.getDbTypeByClassName(driverClassName);
}
}
if (dbType == null) {
// if we can not get the DB Type from the existing driver list, just set back the type to ORACLE
// since it's one DB unknown from Talend.
// it might not work directly for all DB, but it will generate a standard query.
dbType = EDatabaseTypeName.ORACLE_OCI.getDisplayName();
}
// data view, conn=null
// need add code here for dbtype(oracle)
}
if (dbNameAndSchemaMap != null) {
schema = this.dbNameAndSchemaMap.get(this.realTableId);
}
String propertyType = (String) node.getPropertyValue(EParameterName.PROPERTY_TYPE.getName());
boolean isTeradata = false;
if (dbType != null) {
isTeradata = dbType.equalsIgnoreCase(EDatabaseTypeName.TERADATA.getDisplayName());
}
if (propertyType != null && !propertyType.equals(EmfComponent.REPOSITORY)) {
List<? extends IElementParameter> elementParameters = this.node.getElementParameters();
if (useExistConnection) {
elementParameters = connectionNode.getElementParameters();
}
for (IElementParameter param : elementParameters) {
if (param.getRepositoryValue() != null) {
if (//$NON-NLS-1$
(!isTeradata && param.getRepositoryValue().equals("SCHEMA")) || (isTeradata && param.getRepositoryValue().equals("SID"))) {
// check if dbtype is //$NON-NLS-1$
// Teradata, always keep the
// query style like
// "dbname.tablename.columnname" on build-in mode
schema = (String) param.getValue();
//$NON-NLS-1$ //$NON-NLS-2$
schema = schema.replace("\"", "");
//$NON-NLS-1$ //$NON-NLS-2$
schema = schema.replace("\'", "");
break;
}
}
}
} else if (schema == null) {
IElementParameter param = node.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
if (param != null) {
try {
IRepositoryViewObject object = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getLastVersion((String) param.getValue());
if (object != null) {
Item item = object.getProperty().getItem();
if (item != null && item instanceof DatabaseConnectionItem) {
if (isTeradata) {
schema = (String) RepositoryToComponentProperty.getValue(((DatabaseConnectionItem) item).getConnection(), "SID", //$NON-NLS-1$
null);
} else {
schema = (String) RepositoryToComponentProperty.getValue(((DatabaseConnectionItem) item).getConnection(), "SCHEMA", //$NON-NLS-1$
null);
}
schema = TalendTextUtils.removeQuotes(schema);
}
}
} catch (PersistenceException e) {
//
}
}
}
// if (conn instanceof DatabaseConnection && conn.isContextMode()) {
// schema = DatabaseConnectionParameterUtil.getContextTrueValue((DatabaseConnection) conn, schema);
// }
String newQuery = null;
realTableName = QueryUtil.getTableName(node, newOutputMetadataTable, schema, dbType, realTableName);
if (realTableName.startsWith(TalendTextUtils.QUOTATION_MARK) && realTableName.endsWith(TalendTextUtils.QUOTATION_MARK) && realTableName.length() > 2) {
realTableName = realTableName.substring(1, realTableName.length() - 1);
}
if (conn != null && (isJdbc || dbType.equals(EDatabaseTypeName.JAVADB_EMBEDED.getDisplayName()) || (StringUtils.isEmpty(schema) && (EDatabaseTypeName.ORACLE_CUSTOM.equals(EDatabaseTypeName.getTypeFromDbType(dbType)) || EDatabaseTypeName.ORACLEFORSID.equals(EDatabaseTypeName.getTypeFromDbType(dbType)) || EDatabaseTypeName.ORACLESN.equals(EDatabaseTypeName.getTypeFromDbType(dbType)) || EDatabaseTypeName.ORACLE_OCI.equals(EDatabaseTypeName.getTypeFromDbType(dbType)))))) {
schema = getDefaultSchema(realTableName);
}
newQuery = QueryUtil.generateNewQuery(node, newOutputMetadataTable, isJdbc, dbType, schema, realTableName);
// Added yyin TDQ-5616: if there are where clause, append it to the query
if (whereClause != null) {
// the where clause is inputted by the user, so no need to modify it.
//$NON-NLS-1$
newQuery = newQuery.substring(0, newQuery.length() - 1) + whereClause + "\"";
}
return TalendTextUtils.addSQLQuotes(newQuery);
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class ComponentChooseDialog method setSAPSpecailValueForCommand.
private void setSAPSpecailValueForCommand(RepositoryNode selectedNode, ChangeValuesFromRepository command) {
// Noted by Marvin Wang on Jun. 29, 2012. The piece of code is used to judge if the selected node is SAP
// Table node, if so, set up the table name to command.
IRepositoryViewObject object = selectedNode.getObject();
if (object instanceof MetadataColumnRepositoryObject) {
object = selectedNode.getParent().getParent().getObject();
}
SAPFunctionUnit unit = null;
if (object != null) {
if (object instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject tableObject = (MetadataTableRepositoryObject) object;
MetadataTable abstractMetadataObject = (MetadataTable) tableObject.getAbstractMetadataObject();
if (abstractMetadataObject != null && abstractMetadataObject.eContainer() instanceof SAPFunctionUnit) {
unit = (SAPFunctionUnit) abstractMetadataObject.eContainer();
command.setSapFunctionLabel(unit.getLabel());
// set table name to functionName/type/tablename;
String currentTableName = //$NON-NLS-1$ //$NON-NLS-2$
unit.getLabel() + "/" + abstractMetadataObject.getTableType() + "/" + abstractMetadataObject.getLabel();
command.setCurrentTableName(currentTableName);
} else if (abstractMetadataObject instanceof SAPTable) {
command.setCurrentTableName(abstractMetadataObject.getLabel());
}
} else if (object instanceof SAPFunctionRepositoryObject) {
SAPFunctionRepositoryObject sapObj = (SAPFunctionRepositoryObject) object;
unit = sapObj.getModelElement();
command.setSapFunctionLabel(unit.getLabel());
} else if (object instanceof SAPIDocRepositoryObject) {
SAPIDocRepositoryObject sapObj = (SAPIDocRepositoryObject) object;
command.setSapIDocLabel(sapObj.getLabel());
}
}
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class AbstractElementPropertySectionController method openSQLBuilder.
/**
* DOC qzhang Comment method "openSQLBuilder".
*
* @param repositoryType
* @param propertyName
* @param query
*/
protected String openSQLBuilder(String repositoryType, String propertyName, String query) {
if (repositoryType.equals(EmfComponent.BUILTIN)) {
connParameters.setQuery(query);
if (connParameters.isShowConfigParamDialog()) {
if (!isUseExistingConnection()) {
initConnectionParametersWithContext(elem, part.getProcess().getContextManager().getDefaultContext());
} else {
initConnectionParametersWithContext(connectionNode, part.getProcess().getContextManager().getDefaultContext());
}
}
// add for bug TDI-20335
if (part == null) {
Shell parentShell = new Shell(composite.getShell().getDisplay());
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, "", connParameters);
sqlBuilder.open();
} else {
openSqlBuilderBuildIn(connParameters, propertyName);
}
} else if (repositoryType.equals(EmfComponent.REPOSITORY)) {
//$NON-NLS-1$
String repositoryName2 = "";
String repositoryId = null;
IElementParameter memoParam = elem.getElementParameter(propertyName);
IElementParameter repositoryParam = null;
for (IElementParameter param : elem.getElementParameters()) {
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE && param.getRepositoryValue().startsWith("DATABASE")) {
repositoryParam = param;
break;
}
}
// in case no database property found, take the first property (to keep compatibility with old code)
if (repositoryParam == null) {
for (IElementParameter param : elem.getElementParameters()) {
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
repositoryParam = param;
break;
}
}
}
if (repositoryParam != null) {
IElementParameter itemFromRepository = repositoryParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
String value = (String) itemFromRepository.getValue();
repositoryId = value;
// for (String key : this.dynamicProperty.getRepositoryConnectionItemMap().keySet()) {
// if (key.equals(value)) {
// repositoryName2 =
// this.dynamicProperty.getRepositoryConnectionItemMap().get(key).getProperty().getLabel();
// }
// }
/* get connection item dynamictly,not from cache ,see 16969 */
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
IRepositoryViewObject repobj = factory.getLastVersion(value);
if (repobj != null) {
Property property = repobj.getProperty();
if (property != null) {
repositoryName2 = property.getLabel();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
// When no repository avaiable on "Repository" mode, open a MessageDialog.
if (repositoryName2 == null || repositoryName2.length() == 0) {
MessageDialog.openError(composite.getShell(), Messages.getString("NoRepositoryDialog.Title"), //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"NoRepositoryDialog.Text"));
return null;
}
// Part maybe not exist
//$NON-NLS-1$
String processName = "";
//$NON-NLS-1$
String key = "";
if (elem instanceof Node) {
processName = ((Node) elem).getProcess().getName();
key = processName + ((Node) elem).getUniqueName();
} else if (elem instanceof IProcess) {
processName = ((IProcess) elem).getName();
key = processName;
}
key += repositoryName2;
final Dialog builderDialog = sqlbuilers.get(key);
if (!composite.isDisposed() && builderDialog != null && builderDialog.getShell() != null && !builderDialog.getShell().isDisposed()) {
builderDialog.getShell().setActive();
} else {
connParameters.setRepositoryName(repositoryName2);
if (repositoryId != null) {
connParameters.setRepositoryId(repositoryId);
}
Shell parentShell = new Shell(composite.getShell().getDisplay());
String nodeLabel = null;
if (elem instanceof Node) {
nodeLabel = (String) ((Node) elem).getElementParameter(EParameterName.LABEL.getName()).getValue();
}
TextUtil.setDialogTitle(processName, nodeLabel, elem.getElementName());
ISQLBuilderService service = (ISQLBuilderService) GlobalServiceRegister.getDefault().getService(ISQLBuilderService.class);
connParameters.setQuery(query);
// first open Sql Builder,set true
connParameters.setFirstOpenSqlBuilder(true);
Dialog sqlBuilder = service.openSQLBuilderDialog(parentShell, processName, connParameters);
sqlbuilers.put(key, sqlBuilder);
if (Window.OK == sqlBuilder.open()) {
if (!composite.isDisposed() && !connParameters.isNodeReadOnly()) {
String sql = connParameters.getQuery();
// modified by hyWang
if (!connParameters.getIfContextButtonCheckedFromBuiltIn()) {
sql = QueryUtil.checkAndAddQuotes(sql);
}
return sql;
}
}
}
}
return null;
}
use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.
the class AbstractElementPropertySectionController method setAllConnectionParameters.
private void setAllConnectionParameters(String typ, IElement element) {
IElementParameter basePropertyParameter = null;
for (IElementParameter param : elem.getElementParameters()) {
if (param.getFieldType() == EParameterFieldType.PROPERTY_TYPE) {
if (param.getRepositoryValue().startsWith("DATABASE")) {
basePropertyParameter = param;
break;
}
}
}
// jobsetting view load the db info from current selected category
IElementParameter updateBasePropertyParameter = updateBasePropertyParameter();
if (updateBasePropertyParameter != null && !updateBasePropertyParameter.equals(basePropertyParameter)) {
basePropertyParameter = updateBasePropertyParameter;
}
String type = null;
ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
if (typ != null && !typ.equals("")) {
//$NON-NLS-1$
type = typ;
} else {
//$NON-NLS-1$
type = getValueFromRepositoryName(element, "TYPE", basePropertyParameter);
}
if (type.equals("Oracle") || type.contains("OCLE")) {
IElementParameter ele = element.getElementParameter("CONNECTION_TYPE");
if (ele != null) {
type = (String) ele.getValue();
} else {
//$NON-NLS-1$
type = "ORACLE_SID";
}
}
// Get real hsqldb type
if (type.equals(EDatabaseTypeName.HSQLDB.name()) && getValueFromRepositoryName(element, "RUNNING_MODE", basePropertyParameter).equals("HSQLDB_INPROGRESS_PERSISTENT")) {
//$NON-NLS-1$
type = EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName();
}
// If the dbtype has been setted don't reset it again unless the dbtype of connParameters is null.
if (StringUtils.trimToNull(type) == null && StringUtils.trimToNull(connParameters.getDbType()) == null) {
type = EDatabaseTypeName.GENERAL_JDBC.getXmlName();
}
if (StringUtils.trimToNull(type) != null) {
connParameters.setDbType(type);
}
//$NON-NLS-1$
String frameWorkKey = getValueFromRepositoryName(element, "FRAMEWORK_TYPE", basePropertyParameter);
connParameters.setFrameworkType(frameWorkKey);
String schema = getValueFromRepositoryName(element, EConnectionParameterName.SCHEMA.getName(), basePropertyParameter);
connParameters.setSchema(schema);
String userName = getValueFromRepositoryName(element, EConnectionParameterName.USERNAME.getName(), basePropertyParameter);
connParameters.setUserName(userName);
String password = getValueFromRepositoryName(element, EConnectionParameterName.PASSWORD.getName(), basePropertyParameter);
connParameters.setPassword(password);
String host = getValueFromRepositoryName(element, EConnectionParameterName.SERVER_NAME.getName(), basePropertyParameter);
connParameters.setHost(host);
String port = getValueFromRepositoryName(element, EConnectionParameterName.PORT.getName(), basePropertyParameter);
connParameters.setPort(port);
boolean https = Boolean.parseBoolean(getValueFromRepositoryName(element, EConnectionParameterName.HTTPS.getName(), basePropertyParameter));
connParameters.setHttps(https);
boolean isOracleOCI = type.equals(EDatabaseTypeName.ORACLE_OCI.getXmlName()) || type.equals(EDatabaseTypeName.ORACLE_OCI.getDisplayName());
if (isOracleOCI) {
String localServiceName = getValueFromRepositoryNameAndParameterName(element, EConnectionParameterName.SID.getName(), EParameterName.LOCAL_SERVICE_NAME.getName());
// sid is the repository value both for DBName and Local_service_name
connParameters.setLocalServiceName(localServiceName);
}
String datasource = getValueFromRepositoryName(element, EConnectionParameterName.DATASOURCE.getName(), basePropertyParameter);
connParameters.setDatasource(datasource);
// qli modified to fix the bug "7364".
String dbName = getValueFromRepositoryName(element, EConnectionParameterName.SID.getName(), basePropertyParameter);
if (EDatabaseTypeName.EXASOL.getDisplayName().equals(connParameters.getDbType())) {
if (dbName.contains("\\\"")) {
dbName = dbName.replace("\\\"", "");
}
dbName = TextUtil.removeQuots(dbName);
} else if (EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(connParameters.getDbType())) {
//$NON-NLS-1$
dbName = "";
}
connParameters.setDbName(dbName);
if (connParameters.getDbType().equals(EDatabaseTypeName.SQLITE.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.ACCESS.getXmlName()) || connParameters.getDbType().equals(EDatabaseTypeName.FIREBIRD.getXmlName())) {
String file = getValueFromRepositoryName(element, EConnectionParameterName.FILE.getName(), basePropertyParameter);
connParameters.setFilename(file);
}
String dir = getValueFromRepositoryName(element, EConnectionParameterName.DIRECTORY.getName(), basePropertyParameter);
if (type.equals(EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName())) {
dir = getValueFromRepositoryName(elem, EConnectionParameterName.DBPATH.getName(), basePropertyParameter);
}
connParameters.setDirectory(dir);
// General jdbc
String url = getValueFromRepositoryName(element, EConnectionParameterName.URL.getName(), basePropertyParameter);
if (StringUtils.isEmpty(url)) {
// to get the Oracle RAC url.
if (EDatabaseTypeName.ORACLE_CUSTOM.getXmlName().equals(type)) {
url = getValueFromRepositoryName(element, "RAC_" + EConnectionParameterName.URL.getName(), basePropertyParameter);
}
}
connParameters.setUrl(TalendTextUtils.removeQuotes(url));
String driverJar = getValueFromRepositoryName(element, EConnectionParameterName.DRIVER_JAR.getName(), basePropertyParameter);
connParameters.setDriverJar(TalendTextUtils.removeQuotes(driverJar));
String driverClass = getValueFromRepositoryName(element, EConnectionParameterName.DRIVER_CLASS.getName(), basePropertyParameter);
String dbVersion = getValueFromRepositoryName(element, "DB_VERSION", basePropertyParameter);
connParameters.setDbVersion(dbVersion);
if (EDatabaseVersion4Drivers.VERTICA_5_1.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_6.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_6_1_X.getVersionValue().equals(dbVersion) || EDatabaseVersion4Drivers.VERTICA_7.getVersionValue().equals(dbVersion)) {
driverClass = EDatabase4DriverClassName.VERTICA2.getDriverClass();
}
connParameters.setDriverClass(TalendTextUtils.removeQuotes(driverClass));
if (driverClass != null && !"".equals(driverClass) && !EDatabaseTypeName.GENERAL_JDBC.getDisplayName().equals(connParameters.getDbType())) {
if (driverClass.startsWith("\"") && driverClass.endsWith("\"")) {
driverClass = TalendTextUtils.removeQuotes(driverClass);
}
String dbTypeByClassName = "";
if (driverJar != null && !"".equals(driverJar)) {
dbTypeByClassName = extractMeta.getDbTypeByClassNameAndDriverJar(driverClass, driverJar);
} else {
dbTypeByClassName = extractMeta.getDbTypeByClassName(driverClass);
}
if (dbTypeByClassName != null) {
connParameters.setDbType(dbTypeByClassName);
}
}
String jdbcProps = getValueFromRepositoryName(element, EConnectionParameterName.PROPERTIES_STRING.getName(), basePropertyParameter);
connParameters.setJdbcProperties(jdbcProps);
String realTableName = null;
if (EmfComponent.REPOSITORY.equals(elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()))) {
final Object propertyValue = elem.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
IMetadataTable metadataTable = null;
String connectionId = propertyValue.toString().split(" - ")[0];
String tableLabel = propertyValue.toString().split(" - ")[1];
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Item item = null;
try {
IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
if (repobj != null) {
Property property = repobj.getProperty();
if (property != null) {
item = property.getItem();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (item != null && item instanceof ConnectionItem) {
Connection connection = ((ConnectionItem) item).getConnection();
for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
if (table.getLabel().equals(tableLabel)) {
metadataTable = ConvertionHelper.convert(table);
break;
}
}
}
if (metadataTable != null) {
realTableName = metadataTable.getTableName();
}
}
connParameters.setSchemaName(QueryUtil.getTableName(elem, connParameters.getMetadataTable(), TalendTextUtils.removeQuotes(schema), type, realTableName));
}
Aggregations