use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class AbstractAnalysisMetadataPage method getCurrentConnectionRepNode.
protected IRepositoryNode getCurrentConnectionRepNode() {
// MOD klliu 2010-12-10
IEditorInput editorInput = getEditor().getEditorInput();
if (editorInput instanceof AnalysisItemEditorInput) {
AnalysisItemEditorInput fileEditorInput = (AnalysisItemEditorInput) editorInput;
return fileEditorInput.getConnectionNode();
} else {
// ADD TDQ-9613 msjian: when the user do something from the other views for example: from task view
FileEditorInput fileEditorInput = (FileEditorInput) editorInput;
Analysis findAnalysis = AnaResourceFileHelper.getInstance().findAnalysis(fileEditorInput.getFile());
DataManager connection = findAnalysis.getContext().getConnection();
if (connection != null) {
return RepositoryNodeHelper.recursiveFind(connection);
}
// TDQ-9613~
}
return null;
}
use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class DQRepositoryViewLabelProvider method addWarnIconIfNeeded.
/**
* if it is needed,add a over warning icon..eg., it is empty analysis or report; imported a MDM analysis or report.
*
* @param image
* @param node
* @param originalImageName
* @return
*/
private Image addWarnIconIfNeeded(IRepositoryNode node, String originalImageName) {
ModelElement modEle = RepositoryNodeHelper.getResourceModelElement(node);
ERepositoryObjectType objectType = node.getObjectType();
if (modEle != null) {
if (ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT == objectType) {
Analysis analysis = (Analysis) modEle;
AnalysisContext context = analysis.getContext();
if (context == null) {
return ImageLib.createInvalidIcon(originalImageName);
}
EList<ModelElement> analysedElements = context.getAnalysedElements();
DataManager connection = context.getConnection();
if (analysedElements.isEmpty() || connection instanceof MDMConnection) {
return ImageLib.createInvalidIcon(originalImageName);
}
} else if (ERepositoryObjectType.TDQ_REPORT_ELEMENT == objectType) {
TdReport report = (TdReport) modEle;
EList<AnalysisMap> analysisMap = report.getAnalysisMap();
if (analysisMap.isEmpty()) {
return ImageLib.createInvalidIcon(originalImageName);
}
for (AnalysisMap anaMap : report.getAnalysisMap()) {
Analysis analysis = anaMap.getAnalysis();
if (analysis == null || analysis.getContext() == null) {
continue;
}
DataManager connection = analysis.getContext().getConnection();
if (connection instanceof MDMConnection) {
return ImageLib.createInvalidIcon(originalImageName);
}
}
}
}
return ImageLib.getImage(originalImageName);
}
use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class ColumnCorrelationAnalysisHandler method addIndicator.
/**
* The resources that are connected to this analysis and that are potentially modified.
*/
// private Collection<Resource> modifiedResources = new HashSet<Resource>();
/**
* Method "addColumnToAnalyze".
*
* @param column
* @return
*/
public boolean addIndicator(List<TdColumn> columns, Indicator indicator) {
for (ModelElement tdColumn : columns) {
if (!analysis.getContext().getAnalysedElements().contains(tdColumn)) {
analysis.getContext().getAnalysedElements().add(tdColumn);
}
}
// store first level of indicators in result.
analysis.getResults().getIndicators().add(indicator);
initializeIndicator(indicator, columns);
DataManager connection = analysis.getContext().getConnection();
if (connection == null) {
// try to get one
for (ModelElement element : columns) {
TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
// $NON-NLS-1$
log.error(Messages.getString("ColumnCorrelationAnalysisHandler.CONNNOTBEENSETINANALYSIS"));
connection = ConnectionHelper.getTdDataProvider(tdColumn);
if (connection != null) {
analysis.getContext().setConnection(connection);
}
}
}
TypedReturnCode<Dependency> rc = DependenciesHandler.getInstance().setDependencyOn(analysis, connection);
return rc.isOk();
}
use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class TableAnalysisHandler method addIndicator.
public boolean addIndicator(NamedColumnSet set, Indicator... indicators) {
if (!analysis.getContext().getAnalysedElements().contains(set)) {
analysis.getContext().getAnalysedElements().add(set);
}
for (Indicator indicator : indicators) {
// store first level of indicators in result.
analysis.getResults().getIndicators().add(indicator);
initializeIndicator(indicator, set);
}
DataManager connection = analysis.getContext().getConnection();
if (connection == null) {
// try to get one
// $NON-NLS-1$
log.error(Messages.getString("ColumnCorrelationAnalysisHandler.CONNNOTBEENSETINANALYSIS"));
connection = ConnectionHelper.getTdDataProvider(PackageHelper.getParentPackage((MetadataTable) set));
analysis.getContext().setConnection(connection);
}
TypedReturnCode<Dependency> rc = DependenciesHandler.getInstance().setDependencyOn(analysis, connection);
return rc.isOk();
}
use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class TdqAnalysisConnectionPool method newConnection.
/**
* DOC xqliu Comment method "newConnection".
*
* @return
*/
private Connection newConnection() {
Connection conn = null;
if (isFull()) {
return conn;
}
DataManager datamanager = analysis.getContext().getConnection();
if (datamanager == null) {
// $NON-NLS-1$
log.error(Messages.getString("AnalysisExecutor.DataManagerNull", analysis.getName()));
return null;
}
if (datamanager != null && datamanager.eIsProxy()) {
datamanager = (DataManager) EObjectHelper.resolveObject(datamanager);
}
org.talend.core.model.metadata.builder.connection.Connection dataprovider = SwitchHelpers.CONNECTION_SWITCH.doSwitch(datamanager);
TypedReturnCode<Connection> trcConn = null;
IMetadataConnection metadataConnection = ConvertionHelper.convert(dataprovider);
if (metadataConnection != null && EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(metadataConnection.getDbType())) {
trcConn = new TypedReturnCode<Connection>(false);
try {
HiveConnectionHandler hiveConnHandler = HiveConnectionManager.getInstance().createHandler(metadataConnection);
Connection hiveConnection = hiveConnHandler.createHiveConnection();
if (hiveConnection != null) {
trcConn.setOk(true);
trcConn.setObject(hiveConnection);
}
} catch (ClassNotFoundException e) {
trcConn.setOk(false);
log.error(e);
} catch (InstantiationException e) {
trcConn.setOk(false);
log.error(e);
} catch (IllegalAccessException e) {
trcConn.setOk(false);
log.error(e);
} catch (SQLException e) {
trcConn.setOk(false);
log.error(e);
}
} else {
trcConn = JavaSqlFactory.createConnection(dataprovider);
}
if (trcConn != null && trcConn.isOk()) {
conn = trcConn.getObject();
synchronized (this.synchronizedFlag) {
this.getPConnections().add(new PooledTdqAnalysisConnection(conn));
}
}
if (conn != null) {
try {
if (metadataConnection != null && EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(metadataConnection.getDbType())) {
// don't set the max connection number if it is hive connection
} else {
DatabaseMetaData metaData = conn.getMetaData();
int currentDriverMaxConnections = new Float(metaData.getMaxConnections() * DEFAULT_CONNECTION_NUMBER_OFFSET).intValue();
synchronized (this.synchronizedFlag) {
this.setDriverMaxConnections(currentDriverMaxConnections);
}
}
} catch (SQLException e) {
log.debug(e, e);
}
}
return conn;
}
Aggregations