Search in sources :

Example 16 with ItemRecord

use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.

the class ExportWizardPage method getElements.

/**
 * DOC bZhou Comment method "getElements".
 *
 * @return
 */
public ItemRecord[] getElements() {
    List<ItemRecord> itemRecords = new ArrayList<ItemRecord>();
    boolean sumIndicatorAdded = false;
    Object[] checkedElements = repositoryTree.getCheckedElements();
    for (Object obj : checkedElements) {
        if (obj instanceof ItemRecord) {
            ItemRecord record = (ItemRecord) obj;
            // MOD qiongli 2012-4-20,add related subreport jrxml/jasper file to elements.
            File file = record.getFile();
            if (file.isFile()) {
                itemRecords.add(record);
                if (file.getName().endsWith(FactoriesUtil.JRXML)) {
                    addSubRepToElements(record, itemRecords);
                }
                // if it is Mean Indicator, add it's dependency Sum Indicator
                if (!sumIndicatorAdded) {
                    // $NON-NLS-1$
                    String meanIndicatorUuid = "_ccI48RF2Ed2PKb6nEJEvhw";
                    // $NON-NLS-1$
                    String sumIndicatorLabel = "Sum";
                    ModelElement element = record.getElement();
                    if (element != null && element instanceof IndicatorDefinition && meanIndicatorUuid.equals(ResourceHelper.getUUID(element))) {
                        IndicatorDefinition sumIndicator = DefinitionHandler.getInstance().getIndicatorDefinition(sumIndicatorLabel);
                        if (sumIndicator != null) {
                            IFile sumIndicatorIFile = IndicatorResourceFileHelper.findCorrespondingFile(sumIndicator);
                            if (sumIndicatorIFile != null) {
                                File sumIndicatorFile = WorkspaceUtils.ifileToFile(sumIndicatorIFile);
                                if (sumIndicatorFile != null) {
                                    itemRecords.add(new ItemRecord(sumIndicatorFile));
                                    sumIndicatorAdded = true;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return itemRecords.toArray(new ItemRecord[itemRecords.size()]);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IFile(org.eclipse.core.resources.IFile) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) ArrayList(java.util.ArrayList) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 17 with ItemRecord

use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.

the class ExportWizardPage method checkForErrors.

/**
 * this check that the folder entered in the target export location exist otherwhise set an erro message and disable
 * export.
 */
protected void checkForErrors() {
    List<String> errors = new ArrayList<String>();
    errors.addAll(writer.check());
    ItemRecord[] elements = getElements();
    for (ItemRecord record : elements) {
        errors.addAll(record.getErrors());
        for (File depFile : record.getDependencySet()) {
            // ignore it(means not export it).
            if (!DqFileUtils.isLocalProjectFile(depFile)) {
                continue;
            }
            // TDQ-12245~
            ItemRecord findRecord = ItemRecord.findRecord(depFile);
            if (findRecord == null || !repositoryTree.getChecked(findRecord)) {
                ModelElement element = ItemRecord.getElement(depFile);
                // Indicator, don't add it into errors even if it is not exist
                if (element instanceof IndicatorDefinition) {
                    String uuid = ResourceHelper.getUUID(element);
                    if (IndicatorDefinitionFileHelper.isTechnialIndicator(uuid)) {
                        continue;
                    }
                }
                // MOD qiongli 2012-12-13 TDQ-5356 use itself file name for jrxml
                boolean isJrxmlDepFile = depFile.getName().endsWith(FactoriesUtil.JRXML);
                // MOD msjian TDQ-5909: modify to displayName
                String dptLabel = element != null && !isJrxmlDepFile && PropertyHelper.getProperty(element) != null ? PropertyHelper.getProperty(element).getDisplayName() : depFile.getName();
                // TDQ-5909~
                // $NON-NLS-1$ //$NON-NLS-2$
                errors.add("\"" + record.getName() + "\" miss dependency : " + dptLabel);
            }
        }
    }
    if (!errors.isEmpty()) {
        setErrorMessage(errors.get(0));
    } else {
        setErrorMessage(null);
    }
    updatePageStatus();
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ArrayList(java.util.ArrayList) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 18 with ItemRecord

use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord 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)

Example 19 with ItemRecord

use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.

the class FileTreeLabelProvider method getText.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
     */
@Override
public String getText(Object element) {
    if (element instanceof ItemRecord) {
        ItemRecord record = (ItemRecord) element;
        String label = record.getName();
        // make the display text the same as dq repository view
        if (label.equals(EResourceConstant.DATA_PROFILING.getName()) || label.equals(EResourceConstant.LIBRARIES.getName())) {
            return label.substring(4, label.length());
        } else if (label.equals(EResourceConstant.METADATA.getName())) {
            return label.substring(0, 1).toUpperCase() + label.substring(1);
        }
        return label;
    }
    return super.getText(element);
}
Also used : ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord)

Example 20 with ItemRecord

use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.

the class FileTreeLabelProvider method getImage.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
     */
@Override
public Image getImage(Object element) {
    Image image = null;
    if (element instanceof ItemRecord) {
        ItemRecord record = (ItemRecord) element;
        File file = record.getFile();
        String fileName = file.getName();
        if (file.isDirectory()) {
            image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
            EResourceConstant constant = resolveResourceConstant(fileName);
            if (constant != null) {
                switch(constant) {
                    case DATA_PROFILING:
                        image = ImageLib.getImage(ImageLib.DATA_PROFILING);
                        break;
                    case METADATA:
                        image = ImageLib.getImage(ImageLib.METADATA);
                        break;
                    case LIBRARIES:
                        image = ImageLib.getImage(ImageLib.LIBRARIES);
                        break;
                    case ANALYSIS:
                        break;
                    case REPORTS:
                        break;
                    case EXCHANGE:
                        image = ImageLib.getImage(ImageLib.EXCHANGE);
                        break;
                    case DB_CONNECTIONS:
                        image = ImageLib.getImage(ImageLib.CONNECTION);
                        break;
                    case FILEDELIMITED:
                        image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
                        break;
                    case HADOOP_CLUSTER:
                        image = ImageLib.getImage(ImageLib.HADOOP_CLUSTER);
                        break;
                    case CONTEXT:
                        image = ImageLib.getImage(ImageLib.CONTEXT);
                        break;
                    default:
                        break;
                }
            }
        } else {
            if (fileName.endsWith(FactoriesUtil.ANA)) {
                image = ImageLib.getImage(ImageLib.ANALYSIS_OBJECT);
            } else if (fileName.endsWith(FactoriesUtil.REP)) {
                image = ImageLib.getImage(ImageLib.REPORT_OBJECT);
            } else if (fileName.endsWith(FactoriesUtil.PATTERN)) {
                image = ImageLib.getImage(ImageLib.PATTERN_REG);
            } else if (fileName.endsWith(FactoriesUtil.DQRULE)) {
                if (record.getElement() instanceof MatchRuleDefinition) {
                    image = ImageLib.getImage(ImageLib.MATCH_RULE_ICON);
                } else {
                    image = ImageLib.getImage(ImageLib.DQ_RULE);
                }
            } else if (fileName.endsWith(FactoriesUtil.ITEM_EXTENSION)) {
                if (record.getElement() instanceof DelimitedFileConnection) {
                    image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
                } else if (record.getElement() instanceof DatabaseConnection) {
                    image = ImageLib.getImage(ImageLib.TD_DATAPROVIDER);
                } else {
                    image = ImageLib.getImage(ImageLib.CONTEXT);
                }
            } else if (fileName.endsWith(FactoriesUtil.DEFINITION)) {
                image = ImageLib.getImage(ImageLib.IND_DEFINITION);
            } else if (fileName.endsWith(FactoriesUtil.SQL)) {
                image = ImageLib.getImage(ImageLib.SOURCE_FILE);
            } else if (fileName.endsWith(FactoriesUtil.JAR)) {
                image = ImageLib.getImage(ImageLib.JAR_FILE);
            } else if (fileName.endsWith(FactoriesUtil.JRXML)) {
                image = ImageLib.getImage(ImageLib.JRXML_ICON);
            }
        }
    }
    return image != null ? image : super.getImage(element);
}
Also used : EResourceConstant(org.talend.resource.EResourceConstant) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Image(org.eclipse.swt.graphics.Image) File(java.io.File)

Aggregations

ItemRecord (org.talend.dataprofiler.core.ui.imex.model.ItemRecord)26 File (java.io.File)15 ArrayList (java.util.ArrayList)14 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)10 IFile (org.eclipse.core.resources.IFile)6 Path (org.eclipse.core.runtime.Path)6 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)5 List (java.util.List)4 Image (org.eclipse.swt.graphics.Image)4 TreeItem (org.eclipse.swt.widgets.TreeItem)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 IPath (org.eclipse.core.runtime.IPath)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Test (org.junit.Test)3 Property (org.talend.core.model.properties.Property)3 HashMap (java.util.HashMap)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2