use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class ColumnSetAnalysisHandler 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<ModelElement> 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);
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);
break;
}
}
}
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 DQReferenceMerger method addInTarget.
/*
* override this method to fix a specail case: when add a catalog on database server,this new one can't be added in
* local db connection
*/
@Override
protected void addInTarget(ReferenceChange diff, boolean rightToLeft) {
final Match match = diff.getMatch();
final EObject expectedContainer;
if (rightToLeft) {
expectedContainer = match.getLeft();
} else {
expectedContainer = match.getRight();
}
if (expectedContainer == null) {
// one of the "required" diffs should have created our container.
return;
}
final Comparison comparison = match.getComparison();
final EReference reference = diff.getReference();
final EObject expectedValue;
final Match valueMatch = comparison.getMatch(diff.getValue());
if (valueMatch == null) {
// This is an out of scope value.
if (diff.getValue().eIsProxy()) {
// Copy the proxy
expectedValue = EcoreUtil.copy(diff.getValue());
} else {
// Use the same value.
expectedValue = diff.getValue();
}
} else if (rightToLeft) {
if (reference.isContainment()) {
expectedValue = createCopy(diff.getValue());
valueMatch.setLeft(expectedValue);
} else {
// qiongli: when I add catalog on remote server,test on reload, should replace "valueMatch.getLeft()"
// with "valueMatch.getRight()" at here.
// expectedValue = valueMatch.getLeft();
expectedValue = valueMatch.getRight();
// qiongli: remove the newest DataManage from the right Catalog or Schema,avoid a missing
// "datamanage herf=" "
Catalog catlog = SwitchHelpers.CATALOG_SWITCH.doSwitch(expectedValue);
Schema schema = SwitchHelpers.SCHEMA_SWITCH.doSwitch(expectedValue);
if (catlog != null) {
EList<DataManager> dataManager = catlog.getDataManager();
dataManager.clear();
} else if (schema != null) {
EList<DataManager> dataManager = schema.getDataManager();
dataManager.clear();
}
}
} else {
if (reference.isContainment()) {
expectedValue = createCopy(diff.getValue());
valueMatch.setRight(expectedValue);
} else {
expectedValue = valueMatch.getLeft();
}
}
// We have the container, reference and value. We need to know the insertion index.
if (reference.isMany()) {
final int insertionIndex = findInsertionIndex(comparison, diff, rightToLeft);
final List<EObject> targetList = (List<EObject>) safeEGet(expectedContainer, reference);
addAt(targetList, expectedValue, insertionIndex);
} else {
safeESet(expectedContainer, reference, expectedValue);
}
if (reference.isContainment()) {
// Copy XMI ID when applicable.
final Resource initialResource = diff.getValue().eResource();
final Resource targetResource = expectedValue.eResource();
if (initialResource instanceof XMIResource && targetResource instanceof XMIResource) {
((XMIResource) targetResource).setID(expectedValue, ((XMIResource) initialResource).getID(diff.getValue()));
}
}
// no need to check this for DQ items,
// checkImpliedDiffsOrdering(diff, rightToLeft);
}
use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class AnalysisExecutor method getConnection.
/**
* DOC scorreia Comment method "getConnection".
*
* @param analysis
* @param schema
* @return
*/
protected TypedReturnCode<java.sql.Connection> getConnection(Analysis analysis) {
// MODSCA 2008-03-25 scorreia schema is not used. removed (was used before to select the catalog of the db)
// now it is done elsewhere
TypedReturnCode<java.sql.Connection> rc = new TypedReturnCode<java.sql.Connection>();
DataManager datamanager = analysis.getContext().getConnection();
if (datamanager == null) {
// $NON-NLS-1$
rc.setReturnCode(Messages.getString("AnalysisExecutor.DataManagerNull", analysis.getName()), false);
return rc;
}
if (datamanager != null && datamanager.eIsProxy()) {
datamanager = (DataManager) EObjectHelper.resolveObject(datamanager);
}
Connection dataprovider = SwitchHelpers.CONNECTION_SWITCH.doSwitch(datamanager);
if (dataprovider == null) {
rc.setReturnCode(// $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"AnalysisExecutor.DataProviderNull", // $NON-NLS-1$
datamanager.getName(), analysis.getName()), false);
return rc;
}
// create hive connection
IMetadataConnection metadataConnection = ConvertionHelper.convert(dataprovider);
if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(metadataConnection.getDbType())) {
try {
HiveConnectionHandler hiveConnHandler = HiveConnectionManager.getInstance().createHandler(metadataConnection);
java.sql.Connection createConnection = hiveConnHandler.createHiveConnection();
rc.setOk(true);
rc.setObject(createConnection);
} catch (ClassNotFoundException e) {
log.error(e);
rc.setOk(false);
} catch (InstantiationException e) {
log.error(e);
rc.setOk(false);
} catch (IllegalAccessException e) {
log.error(e);
rc.setOk(false);
} catch (SQLException e) {
log.error(e);
rc.setOk(false);
}
return rc;
} else {
// create other type connection
TypedReturnCode<java.sql.Connection> connection = JavaSqlFactory.createConnection(dataprovider);
if (!connection.isOk()) {
rc.setReturnCode(connection.getMessage(), false);
return rc;
}
rc.setObject(connection.getObject());
return rc;
}
}
use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class TableAnalysisWizard method createAndSaveCWMFile.
/*
* (non-Javadoc)
*
* @see
* org.talend.dataprofiler.core.ui.wizard.analysis.AbstractAnalysisWizard#createAndSaveCWMFile(orgomg.cwm.objectmodel
* .core.ModelElement)
*/
@Override
public TypedReturnCode<Object> createAndSaveCWMFile(ModelElement cwmElement) {
Analysis analysis = (Analysis) cwmElement;
DataManager connection = analysis.getContext().getConnection();
if (connection != null) {
DependenciesHandler.getInstance().setDependencyOn(analysis, connection);
}
// MOD by hcheng for 7173:Broken dependency between analyses and connection
TypedReturnCode<Object> saveCWMFile = super.createAndSaveCWMFile(analysis);
if (saveCWMFile.isOk() && connection != null) {
ElementWriterFactory.getInstance().createDataProviderWriter().save(connection);
}
return saveCWMFile;
}
use of orgomg.cwm.foundation.softwaredeployment.DataManager in project tdq-studio-se by Talend.
the class AnalysisFilterWizard method createAndSaveCWMFile.
@Override
public TypedReturnCode<Object> createAndSaveCWMFile(ModelElement cwmElement) {
Analysis analysis = (Analysis) cwmElement;
// MOD klliu feature 15750 connection property define
// MOD qiongli 2011-2-24,bug 17588,add dependency.
DataManager connection = analysis.getContext().getConnection();
DependenciesHandler.getInstance().setDependencyOn(analysis, connection);
ConnectionItem connectionItem = (ConnectionItem) getParameter().getConnectionRepNode().getObject().getProperty().getItem();
TypedReturnCode<Object> saveCWMFile = super.createAndSaveCWMFile(analysis);
// MOD by hcheng for 7173:Broken dependency between analyses and connection
if (saveCWMFile.isOk()) {
// ProxyRepositoryViewObject.fetchAllRepositoryViewObjects(Boolean.TRUE, Boolean.TRUE);
// MOD yyi 2012-02-08 TDQ-4621:Explicitly set true for updating dependencies.
ElementWriterFactory.getInstance().createDataProviderWriter().save(connectionItem, true);
}
return saveCWMFile;
}
Aggregations