Search in sources :

Example 11 with SysIndicatorDefinitionRepNode

use of org.talend.dq.nodes.SysIndicatorDefinitionRepNode in project tdq-studio-se by Talend.

the class ExportUDIWizard method performFinish.

@Override
public boolean performFinish() {
    String targetFile = page.getTargetFile();
    Object[] elements = page.getSelectedTree().getCheckedElements();
    List<IndicatorDefinition> seletedIndicators = new ArrayList<IndicatorDefinition>();
    for (Object element : elements) {
        if (element instanceof IFile) {
            IFile file = (IFile) element;
            if (FactoriesUtil.DEFINITION.equalsIgnoreCase(file.getFileExtension())) {
                seletedIndicators.add(IndicatorResourceFileHelper.getInstance().findIndDefinition(file));
            }
        } else if (element instanceof SysIndicatorDefinitionRepNode && !((SysIndicatorDefinitionRepNode) element).isSystemIndicator()) {
            SysIndicatorDefinitionRepNode udiElement = (SysIndicatorDefinitionRepNode) element;
            seletedIndicators.add(udiElement.getIndicatorDefinition());
        }
    }
    if ("".equals(targetFile)) {
        // $NON-NLS-1$
        MessageDialog.openError(getShell(), DefaultMessagesImpl.getString("ExportUDIWizard.Error"), // $NON-NLS-1$ //$NON-NLS-2$
        DefaultMessagesImpl.getString("ExportUDIWizard.SpecifyValidResource"));
        return false;
    } else {
        File resource = new File(targetFile);
        if (isForExchange) {
            ExportFactory.export(resource, folder, seletedIndicators.toArray(new IndicatorDefinition[seletedIndicators.size()]));
            for (Iterator<IndicatorDefinition> iterator = seletedIndicators.iterator(); iterator.hasNext(); ) {
                IndicatorDefinition id = iterator.next();
                // $NON-NLS-1$
                File idFile = new File(resource, id.getName() + ".csv");
                if (idFile.isFile() && idFile.exists()) {
                    try {
                        List<File> udiAndJarfiles = new ArrayList<File>();
                        udiAndJarfiles.add(idFile);
                        // MOD by zshen for bug 18724 2011.03.01
                        TaggedValue tv = TaggedValueHelper.getTaggedValue(TaggedValueHelper.JAR_FILE_PATH, id.getTaggedValue());
                        if (tv != null) {
                            for (IFile udiJarFile : UDIUtils.getLibJarFileList()) {
                                for (String jarName : tv.getValue().split("\\|\\|")) {
                                    // $NON-NLS-1$
                                    if (udiJarFile.getName().equals(jarName)) {
                                        udiAndJarfiles.add(udiJarFile.getLocation().toFile());
                                        break;
                                    }
                                }
                            }
                        }
                        // ~
                        // $NON-NLS-1$
                        FilesUtils.zips(udiAndJarfiles.toArray(new File[udiAndJarfiles.size()]), idFile.getPath() + ".zip");
                        idFile.delete();
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                    }
                }
            }
            return true;
        } else {
            boolean isContinue = true;
            if (resource.exists()) {
                isContinue = MessageDialogWithToggle.openConfirm(null, // $NON-NLS-1$
                DefaultMessagesImpl.getString("ExportPatternsWizard.waring"), // $NON-NLS-1$
                DefaultMessagesImpl.getString("ExportPatternsWizard.fileAlreadyExist"));
            }
            if (isContinue) {
                ExportFactory.export(resource, folder, seletedIndicators.toArray(new IndicatorDefinition[seletedIndicators.size()]));
                return true;
            }
            return false;
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) ArrayList(java.util.ArrayList) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) File(java.io.File) IFile(org.eclipse.core.resources.IFile)

Aggregations

SysIndicatorDefinitionRepNode (org.talend.dq.nodes.SysIndicatorDefinitionRepNode)11 PatternRepNode (org.talend.dq.nodes.PatternRepNode)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)5 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)5 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)4 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)4 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)4 DFConnectionRepNode (org.talend.dq.nodes.DFConnectionRepNode)4 ReportRepNode (org.talend.dq.nodes.ReportRepNode)4 RuleRepNode (org.talend.dq.nodes.RuleRepNode)4 MouseAdapter (org.eclipse.swt.events.MouseAdapter)3 MouseEvent (org.eclipse.swt.events.MouseEvent)3 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)3 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)3 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)3 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)3 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)3 DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)3 SourceFileRepNode (org.talend.dq.nodes.SourceFileRepNode)3