use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class TAmazonOracleDndFilter method except.
@Override
public boolean except(Item item, ERepositoryObjectType type, RepositoryNode seletetedNode, IComponent component, String repositoryType) {
if (component != null) {
// for tAmazonOracleInput/Output/Connection/Row
if (component.getName().startsWith("tAmazonOracle")) {
//$NON-NLS-1$
String dbType = null;
if (item != null && item instanceof DatabaseConnectionItem) {
if (((DatabaseConnectionItem) item).getConnection() instanceof DatabaseConnection) {
dbType = ((DatabaseConnection) ((DatabaseConnectionItem) item).getConnection()).getDatabaseType();
}
}
Node node = new Node(component);
if (node != null) {
//$NON-NLS-1$
IElementParameter param = node.getElementParameter("CONNECTION_TYPE");
if (param != null) {
Object[] valuesList = param.getListItemsValue();
for (Object element : valuesList) {
String conType = EDatabaseTypeName.getTypeFromDbType(element.toString()).getDisplayName();
if (conType != null && dbType != null && conType.equals(dbType)) {
return false;
}
}
}
}
return true;
} else if (("tOracleCDCOutput").equals(component.getName())) {
//$NON-NLS-1$
if (item != null && item instanceof DatabaseConnectionItem) {
if (((DatabaseConnectionItem) item).getConnection() instanceof DatabaseConnection) {
DatabaseConnection connection = ((DatabaseConnection) ((DatabaseConnectionItem) item).getConnection());
if (MetadataConnectionUtils.isOracle(connection)) {
String version = connection.getDbVersionString();
if (EDatabaseVersion4Drivers.ORACLE_12.name().equals(version)) {
return false;
}
}
}
}
return true;
}
}
return false;
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class MysqlOutputDBVersionForBug13250 method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
public ExecutionResult execute(Item item) {
if (item instanceof DatabaseConnectionItem) {
boolean modify = false;
DatabaseConnectionItem mysqlConnItem = (DatabaseConnectionItem) item;
if (mysqlConnItem.getConnection() instanceof DatabaseConnection) {
DatabaseConnection mysqlConnection = (DatabaseConnection) mysqlConnItem.getConnection();
if ("MySQL".equalsIgnoreCase(mysqlConnection.getDatabaseType())) {
if (mysqlConnection.getDbVersionString() == null || "".equals(mysqlConnection.getDbVersionString())) {
mysqlConnection.setDbVersionString("MYSQL_5");
modify = true;
}
}
}
if (modify) {
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class SchemaTypeProcessor method selectRepositoryNode.
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
if (super.selectRepositoryNode(viewer, parentNode, node)) {
IRepositoryViewObject object = node.getObject();
if (object != null) {
// query
if (object instanceof Query) {
return false;
}
}
// cdc
ICDCProviderService cdcService = null;
if (PluginChecker.isCDCPluginLoaded()) {
cdcService = (ICDCProviderService) GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
}
String repositoryType = getRepositoryType();
if (ERepositoryCategoryType.CDC.getName().equals(repositoryType) && (object != null)) {
if (object.getRepositoryObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
DatabaseConnectionItem item = (DatabaseConnectionItem) object.getProperty().getItem();
DatabaseConnection connection = (DatabaseConnection) item.getConnection();
if (cdcService != null && cdcService.canCreateCDCConnection(connection)) {
return true;
}
return false;
}
if (object instanceof MetadataTable) {
return ((MetadataTableRepositoryObject) object).getTable().isActivatedCDC();
}
}
return true;
}
return false;
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class SQLBuilderDialog method deleteNoUseTable.
private void deleteNoUseTable() {
// add for bug TDI-17097
connection = (DatabaseConnection) SQLBuilderRepositoryNodeManager.getItem(SQLBuilderRepositoryNodeManager.getRoot(nodeInEditor)).getConnection();
if (SQLBuilderRepositoryNodeManager.tList instanceof List) {
if (SQLBuilderRepositoryNodeManager.tList.size() == 0) {
SQLBuilderRepositoryNodeManager.tList.addAll(ConnectionHelper.getTables(connection));
}
} else {
SQLBuilderRepositoryNodeManager.tList = new ArrayList<MetadataTable>();
SQLBuilderRepositoryNodeManager.tList.addAll(ConnectionHelper.getTables(connection));
}
if (SQLBuilderRepositoryNodeManager.tList == null || SQLBuilderRepositoryNodeManager.tList.size() == 0) {
return;
}
// changed for bug TDI-19892
if (node == null) {
SQLBuilderRepositoryNodeManager.tList = null;
return;
}
IRepositoryViewObject repositoryObject = node.getObject();
Item item = repositoryObject.getProperty().getItem();
if (item instanceof DatabaseConnectionItem) {
manager.deleteNouseTables(((DatabaseConnectionItem) item).getConnection());
}
}
use of org.talend.core.model.properties.DatabaseConnectionItem in project tdi-studio-se by Talend.
the class MetadataColumnComparator method saveEMFMetadataColumn.
@SuppressWarnings("unchecked")
private static void saveEMFMetadataColumn(String id, List<MetadataColumn> columnNodes) {
DatabaseConnectionItem item = getEMFItem(id);
final DatabaseConnection connection = (DatabaseConnection) item.getConnection();
IMetadataConnection iMetadataConnection = ConvertionHelper.convert(connection);
Set<MetadataTable> tableset = ConnectionHelper.getTables(connection);
List<MetadataTable> tables = new ArrayList<MetadataTable>();
tables.addAll(tableset);
List<MetadataColumn> emfCols = new ArrayList<MetadataColumn>();
List<MetadataColumn> dbCols = new ArrayList<MetadataColumn>();
for (MetadataColumn col : columnNodes) {
for (MetadataTable table : tables) {
if (table.getLabel().equals(col.getTable().getLabel())) {
List<TdColumn> returnCols = ExtractMetaDataFromDataBase.returnMetadataColumnsFormTable(iMetadataConnection, table.getSourceName());
for (MetadataColumn emfcolumn : table.getColumns()) {
for (MetadataColumn column : returnCols) {
if (emfcolumn.getLabel().equals(col.getLabel()) && column.getLabel().equals(col.getOriginalField())) {
emfCols.add(emfcolumn);
dbCols.add(column);
}
}
}
}
}
}
saveOneMetadataColumn(emfCols, columnNodes, dbCols);
saveMetaData(item);
}
Aggregations