Search in sources :

Example 66 with IndicatorDefinition

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

the class TDQIndicatorDefinitionItemImpl method setIndicatorDefinition.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setIndicatorDefinition(IndicatorDefinition newIndicatorDefinition) {
    IndicatorDefinition oldIndicatorDefinition = indicatorDefinition;
    indicatorDefinition = newIndicatorDefinition;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, PropertiesPackage.TDQ_INDICATOR_DEFINITION_ITEM__INDICATOR_DEFINITION, oldIndicatorDefinition, indicatorDefinition));
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 67 with IndicatorDefinition

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

the class ExportFactory method export.

public static void export(File exportFile, IFolder folder, IndicatorDefinition... indicatorDefinitions) {
    if (exportFile.isDirectory()) {
        for (IndicatorDefinition id : indicatorDefinitions) {
            // $NON-NLS-1$
            File file = new File(exportFile, id.getName() + ".csv");
            export(file, folder, id);
        }
    }
    String fileExtName = getFileExtName(exportFile);
    if (FileUtils.isCSV(fileExtName)) {
        try {
            CSVWriter out = FileUtils.createCSVWriter(exportFile, FileUtils.TEXT_QUAL, FileUtils.TEXT_QUAL);
            PatternToExcelEnum[] values = PatternToExcelEnum.values();
            String[] temp = new String[values.length];
            for (int i = 0; i < indicatorDefinitions.length + 1; i++) {
                for (int j = 0; j < values.length; j++) {
                    if (i == 0) {
                        temp[j] = values[j].getLiteral();
                    } else {
                        temp[j] = getRelatedValueFromIndicatorDefinition(indicatorDefinitions[i - 1], folder).get(values[j]);
                    }
                }
                out.writeNext(temp);
            }
            out.flush();
            out.close();
        } catch (FileNotFoundException fe) {
            MessageDialogWithToggle.openError(null, DefaultMessagesImpl.getString("ExportFactory.errorOne"), // $NON-NLS-1$ //$NON-NLS-2$
            DefaultMessagesImpl.getString("ExportFactory.notFoundFile"));
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) CSVWriter(com.talend.csv.CSVWriter) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 68 with IndicatorDefinition

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

the class TreeMessageInfoDialog method getLabelProvider.

protected ILabelProvider getLabelProvider() {
    if (labelProvider == null) {
        labelProvider = new LabelProvider() {

            @Override
            public String getText(Object obj) {
                if (obj == null) {
                    // $NON-NLS-1$
                    return "";
                }
                if (obj instanceof ImpactNode) {
                    return ((ImpactNode) obj).toString();
                } else if (obj instanceof IFile) {
                    IFile file = (IFile) obj;
                    ModelElement modelElement = ModelElementFileFactory.getModelElement(file);
                    // MOD msjian TDQ-5909: modify to displayName
                    return modelElement != null ? PropertyHelper.getProperty(modelElement).getDisplayName() : file.getName();
                } else if (obj instanceof RepositoryViewObject) {
                    // Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
                    return ((IRepositoryViewObject) obj).getLabel();
                } else if (obj instanceof MetadataTable) {
                    // ADD TDQ-7146: for all type's connection table/view node
                    return ((ModelElement) obj).getName();
                }
                Property property = PropertyHelper.getProperty((ModelElement) obj);
                return property == null ? ((ModelElement) obj).getName() : property.getDisplayName();
            }

            @Override
            public Image getImage(Object obj) {
                ModelElement modelElement = null;
                if (obj instanceof ModelElement) {
                    modelElement = (ModelElement) obj;
                } else if (obj instanceof ImpactNode) {
                    modelElement = ((ImpactNode) obj).getNodeElement();
                } else if (obj instanceof IFile) {
                    modelElement = ModelElementFileFactory.getModelElement((IFile) obj);
                } else if (obj instanceof RepositoryViewObject) {
                    // Added 20130226 TDQ-6899 show the name for Jrxml object (which has no related ModelElement)
                    return ImageLib.getImage(ImageLib.JRXML_ICON);
                }
                // ~
                if (modelElement == null) {
                    if (((ImpactNode) obj).getNode() != null) {
                        return ImageLib.getImage(ImageLib.JRXML_ICON);
                    }
                    return super.getImage(obj);
                }
                Image modelElementImage = null;
                String imgName = null;
                if (modelElement instanceof Analysis) {
                    imgName = ImageLib.ANALYSIS_OBJECT;
                } else if (modelElement instanceof TdReport) {
                    imgName = ImageLib.REPORT_OBJECT;
                } else if (modelElement instanceof DatabaseConnection) {
                    imgName = ImageLib.CONNECTION;
                } else if (modelElement instanceof DelimitedFileConnection) {
                    imgName = ImageLib.FILE_DELIMITED;
                } else if (modelElement instanceof Pattern) {
                    imgName = ImageLib.PATTERN_REG;
                } else if (modelElement instanceof IndicatorDefinition) {
                    // IndicatorDefinition
                    if (modelElement instanceof DQRule) {
                        imgName = ImageLib.DQ_RULE;
                    } else if (modelElement instanceof MatchRuleDefinition) {
                        imgName = ImageLib.MATCH_RULE_ICON;
                    } else {
                        imgName = ImageLib.IND_DEFINITION;
                    }
                // TDQ-8550~
                } else if (modelElement instanceof MetadataTable) {
                    imgName = ImageLib.TABLE;
                }
                if (imgName != null) {
                    modelElementImage = ImageLib.getImage(imgName);
                }
                // add lock icon on the image
                if (modelElementImage != null) {
                    if (modelElement != null) {
                        Property property = PropertyHelper.getProperty(modelElement);
                        if (property != null) {
                            Item item = property.getItem();
                            if (item != null) {
                                if (ProxyRepositoryManager.getInstance().isLockByUserOwn(item)) {
                                    modelElementImage = ImageLib.createLockedByOwnIcon(imgName);
                                } else if (ProxyRepositoryManager.getInstance().isLockByOthers(item)) {
                                    modelElementImage = ImageLib.createLockedByOtherIcon(imgName);
                                }
                            }
                        }
                    }
                    return modelElementImage;
                }
                return super.getImage(obj);
            }
        };
    }
    return labelProvider;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) IFile(org.eclipse.core.resources.IFile) ImpactNode(org.talend.dataprofiler.core.ui.dialog.message.DeleteModelElementConfirmDialog.ImpactNode) TdReport(org.talend.dataquality.reports.TdReport) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) Image(org.eclipse.swt.graphics.Image) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) DQRule(org.talend.dataquality.rules.DQRule) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Item(org.talend.core.model.properties.Item) Analysis(org.talend.dataquality.analysis.Analysis) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) LabelProvider(org.eclipse.jface.viewers.LabelProvider) Property(org.talend.core.model.properties.Property) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 69 with IndicatorDefinition

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

the class IndicatorDuplicateHandle method duplicateModelElement.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.action.actions.handle.EMFResourceHandle#duplicate(java.lang.String)
     */
@Override
public ModelElement duplicateModelElement(ModelElement oldModelElement, String newName) {
    ModelElement duplicateModelElement = super.duplicateModelElement(oldModelElement, newName);
    IndicatorDefinition definition = (IndicatorDefinition) duplicateModelElement;
    // MOD klliu 2010-09-25 bug 15530 when duplicate the system indicator ,the definition must be reset the
    // category and the label name
    isUserDefCategory = IndicatorCategoryHelper.isUserDefCategory(UDIHelper.getUDICategory(definition));
    if (!isUserDefCategory) {
        updateCategory(duplicateModelElement, definition);
    }
    TaggedValueHelper.setValidStatus(true, definition);
    definition.setLabel(definition.getName());
    return definition;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)

Example 70 with IndicatorDefinition

use of org.talend.dataquality.indicators.definition.IndicatorDefinition 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)

Aggregations

IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)141 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)37 Test (org.junit.Test)35 ArrayList (java.util.ArrayList)34 TdExpression (org.talend.cwm.relational.TdExpression)31 File (java.io.File)22 Analysis (org.talend.dataquality.analysis.Analysis)16 IFile (org.eclipse.core.resources.IFile)15 Property (org.talend.core.model.properties.Property)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)14 PersistenceException (org.talend.commons.exception.PersistenceException)13 Indicator (org.talend.dataquality.indicators.Indicator)12 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)12 Path (org.eclipse.core.runtime.Path)10 IFolder (org.eclipse.core.resources.IFolder)9 BasicEList (org.eclipse.emf.common.util.BasicEList)9 TdColumn (org.talend.cwm.relational.TdColumn)9 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)7 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)7