Search in sources :

Example 11 with UDIndicatorDefinition

use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.

the class FileSystemImportWriter method updateAnalysisClientDependence.

/**
 * remove the old client dependency add a new one in Anlaysis.
 *
 * @param supplierItem
 * @param modelElement
 * @throws PersistenceException
 */
private void updateAnalysisClientDependence(TDQItem supplierItem, Property property) throws PersistenceException {
    ModelElement anaModelElement = PropertyHelper.getModelElement(property);
    if (anaModelElement != null) {
        Analysis analysis = (Analysis) anaModelElement;
        EList<Dependency> clientDependency = anaModelElement.getClientDependency();
        Iterator<Dependency> it = clientDependency.iterator();
        ModelElement supplierModelElement = RepositoryNodeHelper.getResourceModelElement(supplierItem);
        Resource supModeResource = supplierModelElement.eResource();
        while (it.hasNext()) {
            Dependency clientDep = it.next();
            // systemSupplyModelElement,remove it.
            if (clientDep.eResource() == null) {
                URI clientDepURI = ((InternalEObject) clientDep).eProxyURI();
                boolean isUDI = clientDepURI.path().contains(ResourceManager.getUDIFolder().getProjectRelativePath().toString());
                boolean isPattern = clientDepURI.path().contains(ResourceManager.getPatternFolder().getProjectRelativePath().toString());
                if (supModeResource != null && (isUDI || isPattern) && clientDepURI.lastSegment().equals(supModeResource.getURI().lastSegment())) {
                    it.remove();
                    break;
                }
            }
        }
        DependenciesHandler.getInstance().setUsageDependencyOn(anaModelElement, supplierModelElement);
        // TDQ-8436 remove the old pattern and add the new pattern in analysis Indicator Parameters.
        if (isPattern(supplierModelElement)) {
            updatePatternInAnaParams(supplierModelElement, analysis);
            ElementWriterFactory.getInstance().createPatternWriter().save(supplierItem, true);
        }
        // remove old udi and set a new one in the analysis indicators.
        if (supplierModelElement instanceof UDIndicatorDefinition) {
            if (analysis.getResults() != null) {
                EList<Indicator> indicators = analysis.getResults().getIndicators();
                Iterator<Indicator> itIndicators = indicators.iterator();
                while (itIndicators.hasNext()) {
                    Indicator indicator = itIndicators.next();
                    IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
                    if (indicatorDefinition.eResource() == null) {
                        URI indicatorDefURI = ((InternalEObject) indicatorDefinition).eProxyURI();
                        if (supModeResource != null && UDIHelper.isUDI(indicator) && indicatorDefURI.lastSegment().equals(supModeResource.getURI().lastSegment())) {
                            indicator.setIndicatorDefinition((UDIndicatorDefinition) supplierModelElement);
                            break;
                        }
                    }
                }
                ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(supplierItem, true);
            }
        }
        // only save analysis item at here.
        ProxyRepositoryFactory.getInstance().save(property.getItem(), true);
    }
}
Also used : UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Resource(org.eclipse.emf.ecore.resource.Resource) Dependency(orgomg.cwm.objectmodel.core.Dependency) URI(org.eclipse.emf.common.util.URI) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) Indicator(org.talend.dataquality.indicators.Indicator) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 12 with UDIndicatorDefinition

use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.

the class DefinitionHandler method reloadAllUDIs.

/**
 * reload all user defined indicators, when some udi's name is changed, this method will be needed
 */
public void reloadAllUDIs() {
    List<IndicatorDefinition> udis = new ArrayList<IndicatorDefinition>();
    for (IndicatorDefinition indicatorDefinition : this.getIndicatorsDefinitions()) {
        if (indicatorDefinition instanceof UDIndicatorDefinition) {
            udis.add(indicatorDefinition);
        }
    }
    // remove all udis
    this.getIndicatorsDefinitions().removeAll(udis);
    // reload all udis
    this.getIndicatorsDefinitions().addAll(IndicatorResourceFileHelper.getInstance().getAllUDIs());
}
Also used : UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) ArrayList(java.util.ArrayList) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)

Example 13 with UDIndicatorDefinition

use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.

the class IndicatorDuplicateHandle method updateUDIModel.

private void updateUDIModel(String newName, ModelElement duplicateModelElement) {
    URI uri = duplicateModelElement.eResource().getURI();
    IFile file = ResourceManager.getRoot().getFile(new Path(uri.toPlatformString(false)));
    File ifileToFile = WorkspaceUtils.ifileToFile(file);
    Map<String, String> initIndicatorReplaceMap = UpdateUDIIndicatorsWithNewModelTask.initIndicatorReplaceMap();
    if (FilesUtils.migrateFile(ifileToFile, initIndicatorReplaceMap, log)) {
        try {
            for (IRepositoryViewObject viewObject : ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS)) {
                ProxyRepositoryFactory.getInstance().reload(viewObject.getProperty());
            }
        } catch (PersistenceException e) {
            log.error(e);
        }
        ResourceService.refreshStructure();
        // add templates for udi only.
        List<IndicatorDefinition> indiDefinitions = DefinitionHandler.getInstance().getUserDefinedIndicatorDefinitions();
        for (IndicatorDefinition indiDefinition : indiDefinitions) {
            if (indiDefinition instanceof UDIndicatorDefinition) {
                String name = indiDefinition.getLabel() != null ? indiDefinition.getLabel() : indiDefinition.getName();
                if (name != null && name.equals(newName)) {
                    UDIndicatorDefinition udi = (UDIndicatorDefinition) indiDefinition;
                    udi = UDIUtils.createDefaultDrillDownList(udi);
                    ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(udi);
                    break;
                }
            }
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) URI(org.eclipse.emf.common.util.URI) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)

Example 14 with UDIndicatorDefinition

use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.

the class UDIHelper method createUDI.

public static UDIndicatorDefinition createUDI(String name, String author, String description, String purpose, String status, String category, String javaClassName, String javaJarPath) {
    // IndicatorDefinition id = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    UDIndicatorDefinition id = UserdefineFactory.eINSTANCE.createUDIndicatorDefinition();
    id.setName(name);
    MetadataHelper.setAuthor(id, author == null ? PluginConstant.EMPTY_STRING : author);
    MetadataHelper.setDescription(description == null ? PluginConstant.EMPTY_STRING : description, id);
    MetadataHelper.setPurpose(purpose == null ? PluginConstant.EMPTY_STRING : purpose, id);
    // MOD mzhao feature 7479 2009-10-16
    MetadataHelper.setDevStatus(id, status == null ? PluginConstant.EMPTY_STRING : status);
    TaggedValueHelper.setTaggedValue(id, TaggedValueHelper.CLASS_NAME_TEXT, javaClassName);
    TaggedValueHelper.setTaggedValue(id, TaggedValueHelper.JAR_FILE_PATH, javaJarPath);
    setUDICategory(id, category);
    return id;
}
Also used : UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)

Example 15 with UDIndicatorDefinition

use of org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition in project tdq-studio-se by Talend.

the class FileTreeContentProvider method hideSomeItems.

/**
 * hide Some Items.
 *
 * @param itemRecords
 * @return
 */
private ItemRecord[] hideSomeItems(ItemRecord[] itemRecords) {
    List<ItemRecord> result = new ArrayList<ItemRecord>();
    for (ItemRecord itemRecord : itemRecords) {
        if (itemRecord != null) {
            // hide the Technial indicators
            if (itemRecord.getElement() != null && itemRecord.getElement() instanceof IndicatorDefinition && !(itemRecord.getElement() instanceof UDIndicatorDefinition)) {
                IndicatorDefinition indDef = (IndicatorDefinition) itemRecord.getElement();
                String uuid = ResourceHelper.getUUID(indDef);
                if (IndicatorDefinitionFileHelper.isTechnialIndicator(uuid)) {
                    continue;
                }
            }
            // TDQ-10933: Hide the Exchange node TDQ-11036: always hidden
            if (EResourceConstant.EXCHANGE.getName().equals(itemRecord.getName())) {
                continue;
            }
            // TDQ-9495: Hide the Reports node when top
            if (PluginChecker.isOnlyTopLoaded()) {
                if (EResourceConstant.REPORTS.getName().equals(itemRecord.getName())) {
                    continue;
                }
            }
        }
        result.add(itemRecord);
    }
    return result.toArray(new ItemRecord[result.size()]);
}
Also used : UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) ArrayList(java.util.ArrayList) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)

Aggregations

UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)31 TdExpression (org.talend.cwm.relational.TdExpression)18 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)13 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)7 TdColumn (org.talend.cwm.relational.TdColumn)7 Analysis (org.talend.dataquality.analysis.Analysis)7 TdTable (org.talend.cwm.relational.TdTable)6 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)6 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)6 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)6 Expression (orgomg.cwm.objectmodel.core.Expression)6 Domain (org.talend.dataquality.domain.Domain)5 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)5 File (java.io.File)4 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)4 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)4 Pattern (org.talend.dataquality.domain.pattern.Pattern)4 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)4 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)4