use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class ConnTextEditPolicy method getDirectEditCommand.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.gef.editpolicies.DirectEditPolicy#getDirectEditCommand(org.eclipse.gef.requests.DirectEditRequest)
*/
protected Command getDirectEditCommand(DirectEditRequest edit) {
String labelText = (String) edit.getCellEditor().getValue();
ConnLabelEditPart labelPart = (ConnLabelEditPart) getHost();
Connection connec = (Connection) getHost().getParent().getModel();
// if the user enter the same name as the current connection, we just ignore it.
if (!connec.getName().equalsIgnoreCase(labelText)) {
if (!ConnectionManager.canRename(connec.getSource(), connec.getTarget(), connec.getLineStyle(), labelText)) {
//$NON-NLS-1$
String message = Messages.getString("ConnectionCreateAction.errorCreateConnectionName", labelText);
MessageDialog.openError(getHost().getViewer().getControl().getShell(), Messages.getString("ConnTextEditPolicy.ErrorTitle"), //$NON-NLS-1$
message);
return null;
} else {
final IMetadataTable metadataTable = connec.getMetadataTable();
if (connec.getSource() != null && connec.getSource().getComponent() != null && metadataTable != null) {
IComponent comp = connec.getSource().getComponent();
if ("tMap".equals(comp.getName()) && metadataTable.getTableName().endsWith("ErrorReject")) {
//$NON-NLS-1$//$NON-NLS-1$
MessageDialog.openInformation(getHost().getViewer().getControl().getShell(), "Infor", "Can't rename tMap ErrorReject");
return null;
}
}
}
}
ChangeConnTextCommand command = new ChangeConnTextCommand((Connection) labelPart.getParent().getModel(), labelText);
return command;
}
use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class Connection method orderConnectionsByMetadata.
private void orderConnectionsByMetadata() {
List<IMetadataTable> tableList = source.getMetadataList();
List<IConnection> connectionList = (List<IConnection>) source.getOutgoingConnections();
List<IConnection> tmpList = new ArrayList<IConnection>(connectionList);
connectionList.clear();
for (IMetadataTable table : tableList) {
String tableName = table.getTableName();
for (IConnection connection : tmpList) {
if (connection.isActivate() && connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA) && connection.getMetadataTable() != null && connection.getMetadataTable().getTableName() != null && connection.getMetadataTable().getTableName().equals(tableName) && connection.getConnectorName().equals(table.getAttachedConnector())) {
connectionList.add(connection);
}
}
}
// add connections without metadata
for (IConnection connection : tmpList) {
if (!connectionList.contains(connection)) {
connectionList.add(connection);
}
}
}
use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class Connection method initTraceFilterParameters.
/**
* just keep this method in case we need it again in some day, or we can delete it dirrectly, since it is never
* used.
*/
private void initTraceFilterParameters() {
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
IMetadataTable metadataTable = this.getMetadataTable();
if (metadataTable != null) {
for (IMetadataColumn metaColumn : metadataTable.getListColumns()) {
Map<String, Object> line = new HashMap<String, Object>();
line.put(IConnection.TRACE_SCHEMA_COLUMN, metaColumn.getLabel());
line.put(IConnection.TRACE_SCHEMA_COLUMN_CHECKED, true);
line.put(IConnection.TRACE_SCHEMA_COLUMN_CONDITION, null);
values.add(line);
}
}
if (getElementParameter(EParameterName.TRACES_CONNECTION_FILTER.getName()) != null && values != null) {
getElementParameter(EParameterName.TRACES_CONNECTION_FILTER.getName()).setValue(values);
}
}
use of org.talend.core.model.metadata.IMetadataTable 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));
}
use of org.talend.core.model.metadata.IMetadataTable in project tdi-studio-se by Talend.
the class NodeQueryCheckUtil method compareNodeTableColumnsNoFunc.
/**
*
* DOC wzhang Comment method "compareNodeTableColumnsNoFunc".
*
* @param node
* @param columns
* @return
*/
private static boolean compareNodeTableColumnsNoFunc(Node node, String columns) {
if (node.getMetadataList().size() == 0) {
return true;
}
IMetadataTable metaTable = node.getMetadataList().get(0);
if (metaTable == null || metaTable.getListColumns() == null) {
return true;
}
int originColumnSize = metaTable.getListColumns().size();
//$NON-NLS-1$
String[] columnArray = columns.split(",");
// columns not match
if (columnArray.length != originColumnSize) {
return false;
}
return true;
}
Aggregations