Search in sources :

Example 16 with DelimitedFileConnection

use of org.talend.core.model.metadata.builder.connection.DelimitedFileConnection in project tdq-studio-se by Talend.

the class DFConnectionRepNode method getDfConnection.

public DelimitedFileConnection getDfConnection() {
    DelimitedFileConnection dfConnection = null;
    Property property = getObject().getProperty();
    Item item = property.getItem();
    if (item instanceof DelimitedFileConnectionItem) {
        dfConnection = (DelimitedFileConnection) ((DelimitedFileConnectionItem) item).getConnection();
    }
    return dfConnection;
}
Also used : Item(org.talend.core.model.properties.Item) DelimitedFileConnectionItem(org.talend.core.model.properties.DelimitedFileConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) Property(org.talend.core.model.properties.Property) DelimitedFileConnectionItem(org.talend.core.model.properties.DelimitedFileConnectionItem)

Example 17 with DelimitedFileConnection

use of org.talend.core.model.metadata.builder.connection.DelimitedFileConnection in project tdq-studio-se by Talend.

the class MatchAnalysisDetailsPage method setSampleDataShowWayStatus.

/*
     * (non-Javadoc)
     *
     * @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#setSampleDataShowWayStatus()
     */
@Override
protected void setSampleDataShowWayStatus() {
    DataManager connection = analysisHandler.getConnection();
    boolean isNotSupportRandom = connection != null && (connection instanceof DelimitedFileConnection || ((connection instanceof DatabaseConnection) && (ConnectionHelper.isInformix((DatabaseConnection) connection) || ConnectionHelper.isSybase((DatabaseConnection) connection))));
    sampleDataShowWayCombo.setEnabled(!isNotSupportRandom);
}
Also used : DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection)

Example 18 with DelimitedFileConnection

use of org.talend.core.model.metadata.builder.connection.DelimitedFileConnection 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);
            if (ResourceManager.getWorskpacePath().toFile().equals(file)) {
                image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
            } else {
                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 = ImageProvider.getImage(ECoreImage.METADATA_CONNECTION_ICON);
                } 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) ECoreImage(org.talend.commons.ui.runtime.image.ECoreImage) File(java.io.File)

Example 19 with DelimitedFileConnection

use of org.talend.core.model.metadata.builder.connection.DelimitedFileConnection in project tdq-studio-se by Talend.

the class RespositoryDetailView method selectionChanged.

/*
     * (non-Javadoc)
     *
     * @seeorg.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui. IWorkbenchPart,
     * org.eclipse.jface.viewers.ISelection)
     */
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    clearContainer();
    boolean isNeedcreateDefault = true;
    try {
        if (part instanceof DQRespositoryView) {
            StructuredSelection sel = (StructuredSelection) selection;
            // MOD by zshen for bug 15750 TODO 39(13) make Detail View can be used.
            Object fe = sel.getFirstElement();
            // MOD klliu 2011-02-24 if choose diffirent node ,that will load diffirent child ,so that not use up.
            if (fe instanceof AnalysisRepNode || fe instanceof ReportRepNode || fe instanceof SysIndicatorDefinitionRepNode || fe instanceof PatternRepNode || fe instanceof RuleRepNode) {
                fe = ((IRepositoryNode) fe).getObject();
            }
            if (fe instanceof IFile) {
                IFile fe2 = (IFile) fe;
                isNeedcreateDefault = createFileDetail(isNeedcreateDefault, fe2);
            } else if (fe instanceof IRepositoryViewObject) {
                isNeedcreateDefault = createFileDetail(isNeedcreateDefault, (IRepositoryViewObject) fe);
            } else if (fe instanceof DBConnectionRepNode) {
                DBConnectionRepNode connNode = (DBConnectionRepNode) fe;
                // MOD sizhaoliu TDQ-6316
                ConnectionItem connectionItem = (ConnectionItem) connNode.getObject().getProperty().getItem();
                createDataProviderDetail(connectionItem);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBCatalogRepNode) {
                DBCatalogRepNode catalogNode = (DBCatalogRepNode) fe;
                Catalog catalog = catalogNode.getCatalog();
                createTdCatalogDetail(catalog);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBSchemaRepNode) {
                DBSchemaRepNode schemaNode = (DBSchemaRepNode) fe;
                Schema schema = schemaNode.getSchema();
                createTdSchemaDetail(schema);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBTableRepNode) {
                DBTableRepNode tableNode = (DBTableRepNode) fe;
                // MOD gdbu 2011-9-14 TDQ-3243
                if (!DQRepositoryNode.isOnFilterring()) {
                    tableNode.getChildren().get(0).getChildren();
                }
                // ~TDQ-3243
                TdTable tdTable = tableNode.getTdTable();
                createTableDetail(tdTable);
                isNeedcreateDefault = false;
            } else if (fe instanceof DBViewRepNode) {
                DBViewRepNode viewNode = (DBViewRepNode) fe;
                // MOD gdbu 2011-9-14 TDQ-3243
                if (!DQRepositoryNode.isOnFilterring()) {
                    viewNode.getChildren().get(0).getChildren();
                }
                // ~TDQ-3243
                createNameCommentDetail(viewNode.getTdView());
                isNeedcreateDefault = false;
            } else if (fe instanceof DBColumnRepNode) {
                DBColumnRepNode columnNode = (DBColumnRepNode) fe;
                TdColumn column = columnNode.getTdColumn();
                createTdColumn(column);
                isNeedcreateDefault = false;
            } else if (fe instanceof IEcosComponent) {
                IEcosComponent component = (IEcosComponent) fe;
                createEcosComponent(component);
                isNeedcreateDefault = false;
            } else if (fe instanceof RegularExpression) {
                // MOD mzhao 2009-04-20,Bug 6349.
                RegularExpression regularExpression = (RegularExpression) fe;
                createRegularExpression(regularExpression);
                isNeedcreateDefault = false;
            } else if (fe instanceof PatternLanguageRepNode) {
                // MOD mzhao 2012-08-15,feature TDQ-4037.
                PatternLanguageRepNode pattLangNode = (PatternLanguageRepNode) fe;
                createRegularExpression(pattLangNode.getRegularExpression());
                isNeedcreateDefault = false;
            } else if (fe instanceof SourceFileRepNode) {
                // MOD klliu 2001-02-28 bug 19154
                IPath filePath = WorkbenchUtils.getFilePath((SourceFileRepNode) fe);
                DQRepositoryNode node = (DQRepositoryNode) fe;
                IFile file = ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(filePath);
                createSqlFileDetail(file);
            } else if (fe instanceof ExchangeComponentRepNode) {
                // MOD klliu 2001-02-28 bug 19154
                IEcosComponent ecosComponent = ((ExchangeComponentRepNode) fe).getEcosComponent();
                IEcosComponent component = ecosComponent;
                createEcosComponent(component);
                isNeedcreateDefault = false;
            // ADD by msjian 2011-5-12 21186: don't check whether the selected object is "MDMConnectionRepNode"
            } else if (fe instanceof DFConnectionRepNode) {
                DFConnectionRepNode dfNode = (DFConnectionRepNode) fe;
                DelimitedFileConnection dfConnection = dfNode.getDfConnection();
                createDFconnectionName(dfNode.getObject().getLabel());
                createDataProviderDetail(dfConnection);
                isNeedcreateDefault = false;
            }
            if (PluginChecker.isTDQLoaded()) {
                if (fe instanceof EObject) {
                    createTechnicalDetail((EObject) fe);
                } else if (fe instanceof IFile) {
                    createTechnicalDetail((IFile) fe);
                } else if (fe instanceof IRepositoryViewObject) {
                    createTechnicalDetail((IRepositoryViewObject) fe);
                } else {
                    createExtDefault();
                }
            }
            if (!scomp.isDisposed()) {
                scomp.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
                composite.layout();
            }
        } else if (part instanceof CommonFormEditor) {
            CommonFormEditor editor = (CommonFormEditor) part;
            IEditorInput editorInput = editor.getEditorInput();
            if (editorInput instanceof IFileEditorInput) {
                IFileEditorInput input = (IFileEditorInput) editorInput;
                IFile file = input.getFile();
                isNeedcreateDefault = createFileDetail(isNeedcreateDefault, file);
            }
        }
        if (isNeedcreateDefault) {
            createDefault();
        }
        // feature 19053
        if (!gContainer.isDisposed()) {
            gContainer.layout();
            if (tContainer != null) {
                tContainer.layout();
            }
        }
    } catch (MissingDriverException e) {
        if (PluginChecker.isOnlyTopLoaded()) {
            MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), // $NON-NLS-1$
            DefaultMessagesImpl.getString("RespositoryDetailView.warning"), e.getErrorMessage());
        } else {
            log.error(e, e);
        }
    }
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) IFile(org.eclipse.core.resources.IFile) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Schema(orgomg.cwm.resource.relational.Schema) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) PatternLanguageRepNode(org.talend.dq.nodes.PatternLanguageRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) IFileEditorInput(org.eclipse.ui.IFileEditorInput) EObject(org.eclipse.emf.ecore.EObject) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) RegularExpression(org.talend.dataquality.domain.pattern.RegularExpression) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) TdTable(org.talend.cwm.relational.TdTable) IPath(org.eclipse.core.runtime.IPath) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) RuleRepNode(org.talend.dq.nodes.RuleRepNode) Catalog(orgomg.cwm.resource.relational.Catalog) CommonFormEditor(org.talend.dataprofiler.core.ui.editor.CommonFormEditor) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) MissingDriverException(org.talend.utils.exceptions.MissingDriverException) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) TdColumn(org.talend.cwm.relational.TdColumn) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEcosComponent(org.talend.dataprofiler.ecos.model.IEcosComponent) EObject(org.eclipse.emf.ecore.EObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEditorInput(org.eclipse.ui.IEditorInput)

Example 20 with DelimitedFileConnection

use of org.talend.core.model.metadata.builder.connection.DelimitedFileConnection in project tdq-studio-se by Talend.

the class FileCSVReaderTest method testNext.

/**
 * Test method for {@link org.talend.cwm.db.connection.file.FileCSVReader#next()}.
 */
@Test
public void testNext() {
    try {
        File file = new File("./file.txt");
        if (file.exists()) {
            file.delete();
        }
        if (file.createNewFile()) {
            PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(file)));
            out.println("id,name,email");
            out.println("1,tom,a@b.cn");
            out.println("2,jerry,x@b.cn");
            out.println("3,bob,top@b.cn");
            out.close();
            DelimitedFileConnection delimitedFileconnection = ConnectionFactory.eINSTANCE.createDelimitedFileConnection();
            delimitedFileconnection.setFilePath(file.getAbsolutePath());
            delimitedFileconnection.setLimitValue("0");
            delimitedFileconnection.setHeaderValue("1");
            delimitedFileconnection.setFieldSeparatorValue(",");
            List<ModelElement> analysisElementList = new ArrayList<ModelElement>();
            MetadataTable table = ConnectionFactory.eINSTANCE.createMetadataTable();
            table.setName("table");
            MetadataColumn id = ConnectionFactory.eINSTANCE.createMetadataColumn();
            id.setName("id");
            id.setLabel("id");
            id.setTable(table);
            MetadataColumn name = ConnectionFactory.eINSTANCE.createMetadataColumn();
            name.setName("name");
            name.setLabel("name");
            name.setTable(table);
            MetadataColumn email = ConnectionFactory.eINSTANCE.createMetadataColumn();
            email.setName("email");
            email.setLabel("email");
            email.setTable(table);
            analysisElementList.add(id);
            analysisElementList.add(name);
            analysisElementList.add(email);
            FileCSVReader fileCSVReader = new FileCSVReader(file, delimitedFileconnection, analysisElementList);
            String fileContent = "";
            int i = 0;
            while (fileCSVReader.hasNext()) {
                i++;
                Record record = fileCSVReader.next();
                List<Attribute> attributes = record.getAttributes();
                fileContent += i + ":";
                for (Attribute attribute : attributes) {
                    fileContent += "[" + attribute.getLabel() + "," + attribute.getValue() + "]";
                }
            }
            fileCSVReader.close();
            Assert.assertEquals("1:[id,1][name,tom][email,a@b.cn]2:[id,2][name,jerry][email,x@b.cn]3:[id,3][name,bob][email,top@b.cn]", fileContent);
        }
        // delete the temp file
        if (file.exists()) {
            file.delete();
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Attribute(org.talend.dataquality.matchmerge.Attribute) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Record(org.talend.dataquality.matchmerge.Record) File(java.io.File) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)22 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)10 File (java.io.File)9 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)9 IPath (org.eclipse.core.runtime.IPath)8 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)8 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)8 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 Property (org.talend.core.model.properties.Property)7 ConnectionItem (org.talend.core.model.properties.ConnectionItem)6 Analysis (org.talend.dataquality.analysis.Analysis)6 IFile (org.eclipse.core.resources.IFile)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 URL (java.net.URL)4 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)4 Indicator (org.talend.dataquality.indicators.Indicator)4 BufferedWriter (java.io.BufferedWriter)3 FileWriter (java.io.FileWriter)3 IOException (java.io.IOException)3