Search in sources :

Example 26 with DBColumnRepNode

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

the class RepositoryNodeHelperRealTest method testCreateMysqlColumnRepositoryNode.

/**
 * Test method for
 * {@link org.talend.dq.helper.RepositoryNodeHelper#createRepositoryNode(orgomg.cwm.objectmodel.core.ModelElement)}.
 * mysql case find column node
 */
@Test
public void testCreateMysqlColumnRepositoryNode() {
    // $NON-NLS-1$
    DatabaseConnectionItem createConnectionItem = createDataBaseConnection("conn1", null, false);
    // $NON-NLS-1$
    Catalog addCatalog = this.addCatalog(createConnectionItem.getConnection(), "catalog1");
    // $NON-NLS-1$
    TdTable addTable = this.addTable(addCatalog, "table1");
    // $NON-NLS-1$
    TdColumn addColumn = this.addColumn(addTable, "column1");
    try {
        ProxyRepositoryFactory.getInstance().save(createConnectionItem, null);
    } catch (PersistenceException e) {
        log.error(e, e);
        Assert.fail(e.getMessage());
    }
    RepositoryNode createRepositoryNode = RepositoryNodeHelper.createRepositoryNode(addColumn);
    if (createRepositoryNode != null) {
        IRepositoryViewObject object = createRepositoryNode.getObject();
        Assert.assertTrue(createRepositoryNode instanceof DBColumnRepNode);
        Assert.assertTrue(object != null);
        Assert.assertTrue(object instanceof MetadataColumnRepositoryObject);
        Assert.assertTrue(object.getId().equals(addColumn.getName()));
        Assert.assertTrue(object.getLabel().equals(addColumn.getName()));
        Assert.assertTrue(object.getRepositoryNode() != null);
        Assert.assertTrue(createRepositoryNode.getProperties(EProperties.LABEL).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
        Assert.assertTrue(createRepositoryNode.getProperties(EProperties.CONTENT_TYPE).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
        Assert.assertTrue(createRepositoryNode.getParent().getParent().getParent().getParent().getParent() != null);
    }
}
Also used : TdTable(org.talend.cwm.relational.TdTable) TdColumn(org.talend.cwm.relational.TdColumn) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Catalog(orgomg.cwm.resource.relational.Catalog) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Test(org.junit.Test)

Example 27 with DBColumnRepNode

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

the class AbstractColumnDropTree method translateSelectedNodeIntoIndicator.

// translate the selected nodes into related indicators, without set the values to this.modelElementIndicators
// directly
protected ModelElementIndicator[] translateSelectedNodeIntoIndicator(Object[] objs) {
    List<IRepositoryNode> reposList = RepNodeUtils.translateSelectedToStandardReposityoryNode(objs);
    if (reposList.size() == 0) {
        // this.modelElementIndicators = new ModelElementIndicator[0];
        return new ModelElementIndicator[0];
    }
    // MOD qiongli 2011-1-7 feature 16796.
    boolean isDelimitedFile = false;
    if (objs != null && objs.length != 0) {
        // MOD klliu 2011-02-16 feature 15387
        isDelimitedFile = RepNodeUtils.isDelimitedFile(objs[0]);
        if (!(reposList.get(0) instanceof DBColumnRepNode || isDelimitedFile)) {
            return null;
        }
    }
    List<ModelElementIndicator> modelElementIndicatorList = new ArrayList<ModelElementIndicator>();
    for (ModelElementIndicator modelElementIndicator : getAllTheElementIndicator()) {
        if (reposList.contains(modelElementIndicator.getModelElementRepositoryNode())) {
            modelElementIndicatorList.add(modelElementIndicator);
            reposList.remove(modelElementIndicator.getModelElementRepositoryNode());
        }
    }
    for (IRepositoryNode repObj : reposList) {
        ModelElementIndicator temp = isDelimitedFile ? ModelElementIndicatorHelper.createDFColumnIndicator(repObj) : ModelElementIndicatorHelper.createColumnIndicator(repObj);
        modelElementIndicatorList.add(temp);
    }
    return modelElementIndicatorList.toArray(new ModelElementIndicator[modelElementIndicatorList.size()]);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 28 with DBColumnRepNode

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

the class AnalysisColumnCompareTreeViewer method openColumnsSelectionDialog.

/**
 * MOD mzhao 2009-02-03,remove the first parameter, extract it to class property filed for the convenience of
 * invoking this method from cheat sheets.
 */
public void openColumnsSelectionDialog(TableViewer columnsElementViewer, List<RepositoryNode> columnsOfSectionPart, boolean isLeftPart) {
    RepositoryNode connNode = masterPage.getConnComboSelectNode();
    ColumnsSelectionDialog dialog = new ColumnsSelectionDialog(masterPage, null, // $NON-NLS-1$
    DefaultMessagesImpl.getString("ColumnMasterDetailsPage.columnSelection"), // $NON-NLS-1$
    columnsOfSectionPart, // $NON-NLS-1$
    connNode, // $NON-NLS-1$
    DefaultMessagesImpl.getString("ColumnMasterDetailsPage.columnSelections"));
    if (dialog.open() == Window.OK) {
        Object[] columns = dialog.getResult();
        List<RepositoryNode> columnSet = new ArrayList<RepositoryNode>();
        for (Object obj : columns) {
            if (obj instanceof DBColumnRepNode) {
                columnSet.add((RepositoryNode) obj);
            }
        }
        columnsElementViewer.setInput(columnSet);
        columnsOfSectionPart.clear();
        columnsOfSectionPart.addAll(columnSet);
        computeRefreshDataPreviewPart(isLeftPart, columnSet, columnsElementViewer);
        updateBindConnection(masterPage, tableViewerPosStack);
    }
}
Also used : ColumnsSelectionDialog(org.talend.dataprofiler.core.ui.dialog.ColumnsSelectionDialog) ArrayList(java.util.ArrayList) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 29 with DBColumnRepNode

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

the class AnalysisColumnNominalIntervalTreeViewer method columns2Nodes.

public static List<DBColumnRepNode> columns2Nodes(List<TdColumn> tdColumns) {
    List<DBColumnRepNode> nodes = new ArrayList<DBColumnRepNode>();
    for (TdColumn tdColumn : tdColumns) {
        RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(tdColumn);
        if (recursiveFind == null) {
            recursiveFind = RepositoryNodeHelper.createRepositoryNode(tdColumn);
        }
        RepositoryNode repNode = recursiveFind;
        if (repNode != null && repNode instanceof DBColumnRepNode) {
            nodes.add((DBColumnRepNode) repNode);
        }
    }
    return nodes;
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 30 with DBColumnRepNode

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

the class AnalyzeColumnCorrelationAction method checkSelectedColumn.

private void checkSelectedColumn() {
    if (!selection.isEmpty()) {
        Iterator it = selection.iterator();
        while (it.hasNext()) {
            Object theObject = it.next();
            TdColumn column = null;
            if (theObject instanceof DBColumnRepNode) {
                column = ((DBColumnRepNode) theObject).getTdColumn();
            }
            if (Java2SqlType.isNumbericInSQL(column.getSqlDataType().getJavaDataType())) {
                hasNumberColumn = true;
            } else if (Java2SqlType.isDateInSQL(column.getSqlDataType().getJavaDataType()) || Java2SqlType.isDateTimeSQL(column.getSqlDataType().getJavaDataType())) {
                hasDateColumn = true;
            }
        }
    }
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) Iterator(java.util.Iterator) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode)

Aggregations

DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)31 IRepositoryNode (org.talend.repository.model.IRepositoryNode)15 TdColumn (org.talend.cwm.relational.TdColumn)14 RepositoryNode (org.talend.repository.model.RepositoryNode)13 ArrayList (java.util.ArrayList)12 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)12 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)9 TdTable (org.talend.cwm.relational.TdTable)7 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)7 List (java.util.List)6 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)6 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)5 LocalSelectionTransfer (org.eclipse.jface.util.LocalSelectionTransfer)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 DropTarget (org.eclipse.swt.dnd.DropTarget)4 DropTargetEvent (org.eclipse.swt.dnd.DropTargetEvent)4 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)4 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)4 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)4