use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class TOPRepositoryService method removeAliasInSQLExplorer.
public boolean removeAliasInSQLExplorer(IRepositoryNode children) {
boolean hasDependencyItem = true;
// MOD klliu 2011-04-28 bug 20204 removing connection is synced to the connection view of SQL explore
Item item = children.getObject().getProperty().getItem();
// MOD mzhao filter the connections which is not a type of database.
if (item != null && item instanceof ConnectionItem) {
Connection connection = ((ConnectionItem) item).getConnection();
if (connection instanceof DatabaseConnection || connection instanceof DelimitedFileConnection || connection instanceof MDMConnection) {
CWMPlugin.getDefault().removeAliasInSQLExplorer(connection);
}
}
return hasDependencyItem;
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class TOPRepositoryService method reloadDatabase.
/**
* Comment method "reloadDatabase".
*
* @param connectionItem
* @deprecated instead of it by TDQCompareService.reloadDatabase
*/
@Deprecated
public ReturnCode reloadDatabase(ConnectionItem connectionItem) {
ReturnCode retCode = new ReturnCode(Boolean.TRUE);
Connection conn = connectionItem.getConnection();
try {
if (conn instanceof DatabaseConnection) {
List<ModelElement> dependencyClients = EObjectHelper.getDependencyClients(conn);
if (!(dependencyClients == null || dependencyClients.isEmpty())) {
int isOk = DeleteModelElementConfirmDialog.showElementImpactConfirmDialog(null, new ModelElement[] { conn }, // $NON-NLS-1$
DefaultMessagesImpl.getString("TOPRepositoryService.dependcyTile"), DefaultMessagesImpl.getString("TOPRepositoryService.dependcyMessage", // $NON-NLS-1$
conn.getLabel()));
if (isOk != Dialog.OK) {
retCode.setOk(Boolean.FALSE);
// $NON-NLS-1$
retCode.setMessage("The user canceled the operation!");
return retCode;
}
}
final IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(conn);
Connection newConnection = creatComparisonLevel.reloadCurrentLevelElement();
// update the sql explore.
Property property = PropertyHelper.getProperty(newConnection);
if (property != null) {
Item newItem = property.getItem();
if (newItem != null) {
CWMPlugin.getDefault().updateConnetionAliasByName(newConnection, newConnection.getLabel());
// notifySQLExplorer(newItem);
}
}
// update the related analyses.
WorkbenchUtils.impactExistingAnalyses(newConnection);
}
} catch (ReloadCompareException e) {
log.error(e, e);
retCode.setOk(Boolean.FALSE);
retCode.setMessage(e.getMessage());
} catch (PartInitException e) {
log.error(e, e);
retCode.setOk(Boolean.FALSE);
retCode.setMessage(e.getMessage());
}
return retCode;
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class ExportConnectionToTOSAction method fillCatalogSchema.
/**
* DOC gdbu Comment method "fillCatalogSchema".
*
* @deprecated Won't be used.
* @param tdDataProvider
*/
@Deprecated
protected DatabaseConnection fillCatalogSchema(IMetadataConnection newMetadataConn) {
MetadataFillFactory instance = MetadataFillFactory.getDBInstance(newMetadataConn);
ReturnCode rc = instance.createConnection(newMetadataConn);
DatabaseConnection dbConn = null;
if (rc.isOk()) {
dbConn = (DatabaseConnection) instance.fillUIConnParams(newMetadataConn, null);
DatabaseMetaData dbMetadata = null;
java.sql.Connection sqlConn = null;
try {
if (rc instanceof TypedReturnCode) {
Object sqlConnObject = ((TypedReturnCode) rc).getObject();
if (sqlConnObject instanceof java.sql.Connection) {
sqlConn = (java.sql.Connection) sqlConnObject;
dbMetadata = ExtractMetaDataUtils.getInstance().getConnectionMetadata(sqlConn);
}
}
List<String> packageFilterCatalog = MetadataConnectionUtils.getPackageFilter(dbConn, dbMetadata, true);
instance.fillCatalogs(dbConn, dbMetadata, packageFilterCatalog);
List<String> packageFilterSchema = MetadataConnectionUtils.getPackageFilter(dbConn, dbMetadata, false);
instance.fillSchemas(dbConn, dbMetadata, packageFilterSchema);
} catch (SQLException e) {
log.error(e, e);
} finally {
if (sqlConn != null) {
ConnectionUtils.closeConnection(sqlConn);
}
}
} else {
log.error(rc.getMessage());
}
return dbConn;
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class AliasAndManaDriverHelper method addJars.
/**
* add jars into ManagedDriver attribute.these jars have a real path so that can be accessed.
*
* @param connection
* @param manDr
* @throws MalformedURLException
*/
public void addJars(Connection connection, ManagedDriver manDr) throws MalformedURLException {
List<String> driverJarNameList = new ArrayList<String>();
DatabaseConnection dbConnnection = (DatabaseConnection) connection;
String driverJarPath = JavaSqlFactory.getDriverJarPath(dbConnnection);
if (ConnectionHelper.isJDBC(dbConnnection) && driverJarPath != null) {
// $NON-NLS-1$
String[] pathArray = driverJarPath.split(";");
for (String path : pathArray) {
driverJarNameList.add(path);
}
} else {
String databaseType = dbConnnection.getDatabaseType();
if (StringUtils.equals(EDatabaseTypeName.IMPALA.getDisplayName(), databaseType)) {
driverJarNameList = getImpalaDriverJarNameList(dbConnnection);
} else {
driverJarNameList = EDatabaseVersion4Drivers.getDrivers(databaseType, dbConnnection.getDbVersionString());
}
}
manDr.setJars(getDriverJarRealPaths(driverJarNameList));
}
use of org.talend.core.model.metadata.builder.connection.DatabaseConnection in project tdq-studio-se by Talend.
the class TreeMessageInfoDialog method getLabelProvider.
protected ILabelProvider getLabelProvider() {
if (labelProvider == null) {
labelProvider = new LabelProvider() {
@Override
public String getText(Object obj) {
if (obj == null) {
// $NON-NLS-1$
return "";
}
if (obj instanceof ImpactNode) {
return ((ImpactNode) obj).toString();
} else if (obj instanceof IFile) {
IFile file = (IFile) obj;
ModelElement modelElement = ModelElementFileFactory.getModelElement(file);
// MOD msjian TDQ-5909: modify to displayName
return modelElement != null ? PropertyHelper.getProperty(modelElement).getDisplayName() : file.getName();
} else if (obj instanceof RepositoryViewObject) {
// Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
return ((IRepositoryViewObject) obj).getLabel();
} else if (obj instanceof MetadataTable) {
// ADD TDQ-7146: for all type's connection table/view node
return ((ModelElement) obj).getName();
}
Property property = PropertyHelper.getProperty((ModelElement) obj);
return property == null ? ((ModelElement) obj).getName() : property.getDisplayName();
}
@Override
public Image getImage(Object obj) {
ModelElement modelElement = null;
if (obj instanceof ModelElement) {
modelElement = (ModelElement) obj;
} else if (obj instanceof ImpactNode) {
modelElement = ((ImpactNode) obj).getNodeElement();
} else if (obj instanceof IFile) {
modelElement = ModelElementFileFactory.getModelElement((IFile) obj);
} else if (obj instanceof RepositoryViewObject) {
// Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
return ImageLib.getImage(ImageLib.JRXML_ICON);
}
// ~
if (modelElement == null) {
if (((ImpactNode) obj).getNode() != null) {
return ImageLib.getImage(ImageLib.JRXML_ICON);
}
return super.getImage(obj);
}
Image modelElementImage = null;
String imgName = null;
if (modelElement instanceof Analysis) {
imgName = ImageLib.ANALYSIS_OBJECT;
} else if (modelElement instanceof TdReport) {
imgName = ImageLib.REPORT_OBJECT;
} else if (modelElement instanceof DatabaseConnection) {
imgName = ImageLib.CONNECTION;
} else if (modelElement instanceof DelimitedFileConnection) {
imgName = ImageLib.FILE_DELIMITED;
} else if (modelElement instanceof Pattern) {
imgName = ImageLib.PATTERN_REG;
} else if (modelElement instanceof IndicatorDefinition) {
// IndicatorDefinition
if (modelElement instanceof DQRule) {
imgName = ImageLib.DQ_RULE;
} else if (modelElement instanceof MatchRuleDefinition) {
imgName = ImageLib.MATCH_RULE_ICON;
} else {
imgName = ImageLib.IND_DEFINITION;
}
// TDQ-8550~
} else if (modelElement instanceof MetadataTable) {
imgName = ImageLib.TABLE;
}
if (imgName != null) {
modelElementImage = ImageLib.getImage(imgName);
}
// add lock icon on the image
if (modelElementImage != null) {
if (modelElement != null) {
Property property = PropertyHelper.getProperty(modelElement);
if (property != null) {
Item item = property.getItem();
if (item != null) {
if (ProxyRepositoryManager.getInstance().isLockByUserOwn(item)) {
modelElementImage = ImageLib.createLockedByOwnIcon(imgName);
} else if (ProxyRepositoryManager.getInstance().isLockByOthers(item)) {
modelElementImage = ImageLib.createLockedByOtherIcon(imgName);
}
}
}
}
return modelElementImage;
}
return super.getImage(obj);
}
};
}
return labelProvider;
}
Aggregations