Search in sources :

Example 1 with DBColumnRepNode

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

the class FunctionalDependencyAnalysisDetailsPage method validator.

private ReturnCode validator(List<RepositoryNode> columnASet, List<RepositoryNode> columnBSet) {
    // MOD by gdbu 2011-3-21 bug 19179
    ReturnCode canModRetCode = super.canSave();
    if (!canModRetCode.isOk()) {
        return canModRetCode;
    }
    if (columnASet.isEmpty() || columnBSet.isEmpty()) {
        // $NON-NLS-1$
        return new ReturnCode(DefaultMessagesImpl.getString("ColumnDependencyMasterDetailsPage.columnsBlankMessag"), false);
    }
    if (columnASet.size() != columnBSet.size()) {
        // $NON-NLS-1$
        return new ReturnCode(DefaultMessagesImpl.getString("ColumnsComparisonMasterDetailsPage.columnsSameMessage"), false);
    }
    for (int i = 0; i < columnASet.size(); i++) {
        RepositoryNode columnANode = columnASet.get(i);
        RepositoryNode columnBNode = columnBSet.get(i);
        TdColumn tdColumnA = ((DBColumnRepNode) columnANode).getTdColumn();
        TdColumn tdColumnB = ((DBColumnRepNode) columnBNode).getTdColumn();
        ColumnSet ownerA = ColumnHelper.getColumnOwnerAsColumnSet(tdColumnA);
        ColumnSet ownerB = ColumnHelper.getColumnOwnerAsColumnSet(tdColumnB);
        String uuidA = ResourceHelper.getUUID(ownerA);
        String uuidB = ResourceHelper.getUUID(ownerB);
        if (!uuidA.equals(uuidB)) {
            // $NON-NLS-1$
            return new ReturnCode(DefaultMessagesImpl.getString("ColumnDependencyMasterDetailsPage.tableMessage"), false);
        }
    }
    return new ReturnCode(true);
}
Also used : TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) TdColumn(org.talend.cwm.relational.TdColumn) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 2 with DBColumnRepNode

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

the class RepositoryNodeHelperRealTest method testCreateOracleRepositoryNode.

/**
 * Test method for
 * {@link org.talend.dq.helper.RepositoryNodeHelper#createRepositoryNode(orgomg.cwm.objectmodel.core.ModelElement)}.
 * oracle case
 */
@Test
public void testCreateOracleRepositoryNode() {
    // $NON-NLS-1$
    DatabaseConnectionItem createConnectionItem = createDataBaseConnection("conn1", null, false);
    // $NON-NLS-1$
    Schema addSchema = this.addSchema(createConnectionItem.getConnection(), "catalog1");
    // $NON-NLS-1$
    TdTable addTable = this.addTable(addSchema, "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) Schema(orgomg.cwm.resource.relational.Schema) 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) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Test(org.junit.Test)

Example 3 with DBColumnRepNode

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

the class UnitTestBuildHelper method createModelElementIndicator.

public static ModelElementIndicator createModelElementIndicator() {
    TdColumn tdColumn = RelationalFactory.eINSTANCE.createTdColumn();
    TdTable createTdTable = RelationalFactory.eINSTANCE.createTdTable();
    tdColumn.setOwner(createTdTable);
    TdSqlDataType dataType = RelationalFactory.eINSTANCE.createTdSqlDataType();
    dataType.setJavaDataType(Types.VARCHAR);
    tdColumn.setSqlDataType(dataType);
    MetadataColumnRepositoryObject columnObject = new MetadataColumnRepositoryObject(null, tdColumn);
    IRepositoryNode columnRepNode = new DBColumnRepNode(columnObject, new RepositoryNode(null, null, null), ENodeType.REPOSITORY_ELEMENT, null);
    ModelElementIndicator modelElementIndicator = new ColumnIndicatorImpl(columnRepNode);
    return modelElementIndicator;
}
Also used : ColumnIndicatorImpl(org.talend.dataprofiler.core.model.impl.ColumnIndicatorImpl) TdColumn(org.talend.cwm.relational.TdColumn) TdTable(org.talend.cwm.relational.TdTable) IRepositoryNode(org.talend.repository.model.IRepositoryNode) 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) TdSqlDataType(org.talend.cwm.relational.TdSqlDataType) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 4 with DBColumnRepNode

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

the class SemanticDiscoveryActionProviderTest method createNewColumnRepNode.

/**
 * DOC zshen Comment method "createNewColumnRepNode".
 */
private IRepositoryNode createNewColumnRepNode() {
    // TODO怀create real connection with eresource
    TdColumn tdColumn = RelationalFactory.eINSTANCE.createTdColumn();
    TdTable createTdTable = RelationalFactory.eINSTANCE.createTdTable();
    tdColumn.setOwner(createTdTable);
    TdSqlDataType dataType = RelationalFactory.eINSTANCE.createTdSqlDataType();
    dataType.setJavaDataType(Types.VARCHAR);
    tdColumn.setSqlDataType(dataType);
    MetadataColumnRepositoryObject columnObject = new MetadataColumnRepositoryObject(null, tdColumn);
    IRepositoryNode columnRepNode = new DBColumnRepNode(columnObject, new RepositoryNode(null, null, null), ENodeType.REPOSITORY_ELEMENT, null);
    return columnRepNode;
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) TdTable(org.talend.cwm.relational.TdTable) IRepositoryNode(org.talend.repository.model.IRepositoryNode) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) TdSqlDataType(org.talend.cwm.relational.TdSqlDataType)

Example 5 with DBColumnRepNode

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

the class SelectedCompareUIProvider method fillContextMenu.

@Override
public void fillContextMenu(IMenuManager menu) {
    // TDQ-9394 hide all "Reload" menu.
    if (!isShowMenu()) {
        return;
    }
    if (isShowMenu()) {
        return;
    }
    Iterator<?> iter = ((TreeSelection) this.getContext().getSelection()).iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (!(obj instanceof RepositoryNode)) {
            return;
        }
    }
    TreeSelection treeSelection = (TreeSelection) getContext().getSelection();
    if (treeSelection == null) {
        return;
    }
    Object firstElement = treeSelection.getFirstElement();
    RepositoryNode rNode = (RepositoryNode) firstElement;
    IFolder folder = WorkbenchUtils.getFolder(rNode);
    IFolder metadataFolder = ResourceManager.getMetadataFolder();
    if (!folder.getFullPath().toOSString().startsWith(metadataFolder.getFullPath().toOSString())) {
        return;
    }
    Object[] selectedObj = treeSelection.toArray();
    if (selectedObj.length < 2) {
        return;
    }
    List<Object> objects = new ArrayList<Object>();
    for (Object obj : selectedObj) {
        Connection conn = getConnection(obj);
        if (!MetadataConnectionUtils.isTDQSupportDBTemplate(conn)) {
            return;
        }
        RepositoryNode node = (RepositoryNode) obj;
        if (node instanceof DBConnectionRepNode) {
            Property property = ((DBConnectionRepNode) node).getObject().getProperty();
            DatabaseConnectionItem databaseConnectionItem = (DatabaseConnectionItem) property.getItem();
            Connection databaseConnection = databaseConnectionItem.getConnection();
            objects.add(databaseConnection);
        } else if (node instanceof DBCatalogRepNode) {
            Catalog catalog = ((DBCatalogRepNode) node).getCatalog();
            objects.add(catalog);
        } else if (node instanceof DBSchemaRepNode) {
            Schema schema = ((DBSchemaRepNode) node).getSchema();
            objects.add(schema);
        } else if (node instanceof DBTableRepNode) {
            TdTable tdTable = ((DBTableRepNode) node).getTdTable();
            objects.add(tdTable);
        } else if (node instanceof DBColumnRepNode) {
            TdColumn tdColumn = ((DBColumnRepNode) node).getTdColumn();
            objects.add(tdColumn);
        }
    }
    // MOD yyi 2011-03-22 17871:hide compare action for flat file column
    if (2 == objects.size()) {
        selectionCompareAction.refreshSelectedObj(objects.get(0), objects.get(1));
        menu.add(selectionCompareAction);
    }
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) TdTable(org.talend.cwm.relational.TdTable) Schema(orgomg.cwm.resource.relational.Schema) ArrayList(java.util.ArrayList) Connection(org.talend.core.model.metadata.builder.connection.Connection) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) Catalog(orgomg.cwm.resource.relational.Catalog) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TdColumn(org.talend.cwm.relational.TdColumn) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Property(org.talend.core.model.properties.Property) IFolder(org.eclipse.core.resources.IFolder)

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