use of orgomg.cwm.objectmodel.core.Dependency in project tdq-studio-se by Talend.
the class ModelElementAnalysisHandler method addIndicator.
public boolean addIndicator(ModelElement modelElement, Indicator... indicators) {
if (!analysis.getContext().getAnalysedElements().contains(modelElement)) {
analysis.getContext().getAnalysedElements().add(modelElement);
}
for (Indicator indicator : indicators) {
// ADD TDQ-7164 msjian 2013-5-14:set default indicator parameters.
if (indicator.getParameters() == null) {
indicator.setParameters(IndicatorsFactory.eINSTANCE.createIndicatorParameters());
}
// TDQ-7164~
// store first level of indicators in result.
analysis.getResults().getIndicators().add(indicator);
initializeIndicator(indicator, modelElement);
}
DataManager connection = analysis.getContext().getConnection();
if (connection == null) {
// try to get one
// $NON-NLS-1$
log.error(Messages.getString("ColumnCorrelationAnalysisHandler.CONNNOTBEENSETINANALYSIS"));
connection = ModelElementHelper.getTdDataProvider(modelElement);
analysis.getContext().setConnection(connection);
}
TypedReturnCode<Dependency> rc = DependenciesHandler.getInstance().setDependencyOn(analysis, connection);
return rc.isOk();
}
use of orgomg.cwm.objectmodel.core.Dependency in project tdq-studio-se by Talend.
the class CheckAndUpdateAnalysisDependencyTask method checkAndRemoveWrongDependencies.
/**
* check each analysis if it has only one client dependency, if more than one, remove the useless one.
*
* @param list
* @throws CoreException
*/
private void checkAndRemoveWrongDependencies(List<Analysis> analyses) throws CoreException {
for (Analysis analysis : analyses) {
if (analysis != null) {
boolean isAnalysisModified = false;
if (analysis.getContext().getAnalysedElements() == null || analysis.getContext().getAnalysedElements().size() < 1) {
continue;
}
TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(analysis.getContext().getAnalysedElements().get(0));
if (tdColumn == null) {
continue;
}
// find the correct db connection from analyzed element
DataManager correctDB = ConnectionHelper.getConnection(tdColumn);
// check if the connection is correct or not
DataManager connection = analysis.getContext().getConnection();
if (connection == null || !correctDB.getName().equals(connection.getName())) {
analysis.getContext().setConnection(correctDB);
isAnalysisModified = true;
}
List<DataProvider> clientDependencyDB = null;
for (Dependency dependency : analysis.getClientDependency()) {
ModelElement supplier = dependency.getSupplier().get(0);
if (supplier instanceof DataProvider) {
if (supplier != null && correctDB.getName().equals(supplier.getName())) {
continue;
} else {
if (clientDependencyDB == null) {
clientDependencyDB = new ArrayList<DataProvider>();
}
clientDependencyDB.add((DataProvider) supplier);
}
}
}
if (clientDependencyDB != null) {
for (DataProvider uselessDB : clientDependencyDB) {
// if the db in client dependency do not equal to the correct db, remove it from both the
// analysis and db connection
removeDependenciesBetweenAnaCon(uselessDB, analysis);
isAnalysisModified = true;
}
}
if (isAnalysisModified) {
EMFSharedResources.getInstance().saveResource(analysis.eResource());
}
}
}
}
use of orgomg.cwm.objectmodel.core.Dependency in project tdq-studio-se by Talend.
the class CheckAndUpdateAnalysisDependencyTask method removeSupplierDependenciesBetweenModels.
private List<Resource> removeSupplierDependenciesBetweenModels(ModelElement elementFromRemove, List<? extends ModelElement> elementToRemove) {
EList<Dependency> supplierDependencies;
List<String> toRemoveResources = new ArrayList<String>();
for (ModelElement modelElement : elementToRemove) {
toRemoveResources.add(modelElement.getName());
}
// get the client dependencies (
supplierDependencies = elementFromRemove.getSupplierDependency();
List<Resource> modifiedResources = new ArrayList<Resource>();
for (Dependency dependency : supplierDependencies) {
EList<ModelElement> client = dependency.getClient();
// get the resource of each client
Iterator<ModelElement> dependencyIterator = client.iterator();
while (dependencyIterator.hasNext()) {
ModelElement dependencyModel = dependencyIterator.next();
Resource clientResource = dependencyModel.eResource();
if (clientResource != null) {
if (toRemoveResources.contains(dependencyModel.getName())) {
modifiedResources.add(clientResource);
dependencyIterator.remove();
}
}
}
}
return modifiedResources;
}
Aggregations