Search in sources :

Example 31 with Dependency

use of orgomg.cwm.objectmodel.core.Dependency 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();
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) Dependency(orgomg.cwm.objectmodel.core.Dependency)

Example 32 with Dependency

use of orgomg.cwm.objectmodel.core.Dependency 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();
}
Also used : DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) Dependency(orgomg.cwm.objectmodel.core.Dependency) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator)

Example 33 with Dependency

use of orgomg.cwm.objectmodel.core.Dependency in project tdq-studio-se by Talend.

the class DependenciesHandler method getSupplierDependency.

/**
 * @param object
 * @return SupplierDependency
 *
 * getSupplierDependency
 */
public List<IRepositoryViewObject> getSupplierDependency(IRepositoryViewObject object) {
    List<IRepositoryViewObject> listViewObject = new ArrayList<IRepositoryViewObject>();
    ModelElement modelElement = PropertyHelper.getModelElement(object.getProperty());
    if (object.getProperty().getItem() instanceof TDQFileItem) {
        return listViewObject;
    }
    if (modelElement instanceof IndicatorDefinition) {
        listViewObject.addAll(getIndicatorDependency(object));
    } else {
        EList<Dependency> supplierDependency = modelElement.getSupplierDependency();
        for (Dependency supplier : supplierDependency) {
            for (ModelElement depencyModelElement : supplier.getClient()) {
                if (depencyModelElement.eIsProxy()) {
                // the depency ModelElement is proxy means it is not exist in current project, so need not to do
                // anyting, just skip it
                } else {
                    Property property = PropertyHelper.getProperty(depencyModelElement);
                    IRepositoryViewObject repositoryViewObject = new RepositoryViewObject(property);
                    listViewObject.add(repositoryViewObject);
                }
            }
        }
    }
    return listViewObject;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TDQFileItem(org.talend.dataquality.properties.TDQFileItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) Dependency(orgomg.cwm.objectmodel.core.Dependency) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) Property(org.talend.core.model.properties.Property) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 34 with Dependency

use of orgomg.cwm.objectmodel.core.Dependency in project tdq-studio-se by Talend.

the class DependenciesHandler method removeDependenciesBetweenModels.

/**
 * Method "removeDependenciesBetweenModels" is to be used before a model dependency(elementToRemove) removed from
 * the elementFromRemove. The elementToRemove not truly to deleted, not a file to deleted, just remove the
 * dependency between elementFromRemove and elementToRemove,
 *
 * @param elementFromRemove
 * @param elementToRemove
 * @return
 */
public List<Resource> removeDependenciesBetweenModels(ModelElement elementFromRemove, List<? extends ModelElement> elementToRemove) {
    EList<Dependency> clientDependencies;
    List<Resource> toRemoveResources = new ArrayList<Resource>();
    for (ModelElement modelElement : elementToRemove) {
        toRemoveResources.add(modelElement.eResource());
    }
    // get the client dependencies (
    clientDependencies = elementFromRemove.getClientDependency();
    // locate resource of each Dependency object
    List<Resource> modifiedResources = new ArrayList<Resource>();
    if (clientDependencies != null) {
        Iterator<Dependency> dependencyIterator = clientDependencies.iterator();
        while (dependencyIterator.hasNext()) {
            Dependency dependency = dependencyIterator.next();
            Resource dependencyResource = dependency.eResource();
            if (!toRemoveResources.contains(dependencyResource)) {
                continue;
            }
            if (dependencyResource != null) {
                modifiedResources.add(dependencyResource);
                dependencyIterator.remove();
            }
        }
    }
    return modifiedResources;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Resource(org.eclipse.emf.ecore.resource.Resource) ArrayList(java.util.ArrayList) Dependency(orgomg.cwm.objectmodel.core.Dependency)

Example 35 with Dependency

use of orgomg.cwm.objectmodel.core.Dependency in project tdq-studio-se by Talend.

the class DependenciesHandler method createUsageDependencyOn.

/**
 * Method "createUsageDependencyOn".
 *
 * @param clientElement the analysis that depends on the data provider.
 * @param dataManager the data provider
 * @return a true return code if the dependency has been correctly added to the resource of the supplier element.
 * Return false otherwise. In any case, the dependency is created and the getObject() method returns it.
 */
TypedReturnCode<Dependency> createUsageDependencyOn(ModelElement clientElement, ModelElement dataManager) {
    assert dataManager != null;
    Dependency dependency = createDependencyOn(USAGE, clientElement, dataManager);
    TypedReturnCode<Dependency> rc = new TypedReturnCode<Dependency>();
    rc.setObject(dependency);
    return rc;
}
Also used : TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) Dependency(orgomg.cwm.objectmodel.core.Dependency)

Aggregations

Dependency (orgomg.cwm.objectmodel.core.Dependency)43 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)30 ArrayList (java.util.ArrayList)18 Analysis (org.talend.dataquality.analysis.Analysis)18 Property (org.talend.core.model.properties.Property)11 Resource (org.eclipse.emf.ecore.resource.Resource)10 Test (org.junit.Test)9 PersistenceException (org.talend.commons.exception.PersistenceException)8 File (java.io.File)7 IFile (org.eclipse.core.resources.IFile)6 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)6 TypedReturnCode (org.talend.utils.sugars.TypedReturnCode)6 URI (org.eclipse.emf.common.util.URI)5 EObject (org.eclipse.emf.ecore.EObject)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 Connection (org.talend.core.model.metadata.builder.connection.Connection)5 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 TdColumn (org.talend.cwm.relational.TdColumn)5 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)5