Search in sources :

Example 1 with TdView

use of org.talend.cwm.relational.TdView in project tdq-studio-se by Talend.

the class ViewFolderNode method loadChildren.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.model.nodes.AbstractFolderNode#loadChildren()
     */
@Override
public void loadChildren() {
    // MODSCA 2008-03-14 load children also when no catalog is given, but a schema exists (e.g. for DB2 database)
    Catalog catalog = SwitchHelpers.CATALOG_SWITCH.doSwitch((EObject) getParent());
    if (catalog != null) {
        loadChildrenLow(catalog, catalog, null, new ArrayList<TdView>());
    } else {
        Schema schema = SwitchHelpers.SCHEMA_SWITCH.doSwitch((EObject) getParent());
        if (schema != null) {
            loadChildrenLow(schema, null, schema, new ArrayList<TdView>());
        }
    }
    super.loadChildren();
}
Also used : TdView(org.talend.cwm.relational.TdView) Schema(orgomg.cwm.resource.relational.Schema) Catalog(orgomg.cwm.resource.relational.Catalog)

Example 2 with TdView

use of org.talend.cwm.relational.TdView in project tdq-studio-se by Talend.

the class RepositoryNodeHelperRealTest method addView.

public TdView addView(Catalog catalog, String tableName) {
    TdView createTdView = RelationalFactory.eINSTANCE.createTdView();
    createTdView.setName(tableName);
    List<TdView> tables = new ArrayList<TdView>();
    tables.add(createTdView);
    CatalogHelper.addViews(tables, catalog);
    return createTdView;
}
Also used : TdView(org.talend.cwm.relational.TdView) ArrayList(java.util.ArrayList)

Example 3 with TdView

use of org.talend.cwm.relational.TdView in project tdq-studio-se by Talend.

the class DrillDownEditorInputRealTest method testGetColumnsByTdColumnCase2.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.ui.editor.analysis.drilldown.DrillDownEditorInput#getColumnsByTdColumn(org.talend.cwm.relational.TdColumn)}
 * . case2 :for view case
 */
@Test
public void testGetColumnsByTdColumnCase2() {
    TdColumn currentTdColumn = RelationalFactory.eINSTANCE.createTdColumn();
    TdColumn secondTdColumn = RelationalFactory.eINSTANCE.createTdColumn();
    TdView createTdView = RelationalFactory.eINSTANCE.createTdView();
    List<TdColumn> tdColumns = new ArrayList<TdColumn>();
    tdColumns.add(currentTdColumn);
    tdColumns.add(secondTdColumn);
    ViewHelper.addColumns(createTdView, tdColumns);
    DrillDownEditorInput drillDownEditorInput = new DrillDownEditorInput();
    List<TdColumn> allofTdColumn = drillDownEditorInput.getColumnsByTdColumn(currentTdColumn);
    Assert.assertEquals(createTdView.getColumns().size(), allofTdColumn.size());
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) TdView(org.talend.cwm.relational.TdView) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with TdView

use of org.talend.cwm.relational.TdView in project tdq-studio-se by Talend.

the class ChartTableFactoryTest method testIsDqRule_5.

// test for the analyzed element is not a table
@Test
public void testIsDqRule_5() {
    TdView createTdView = RelationalFactory.eINSTANCE.createTdView();
    dqRule.setAnalyzedElement(createTdView);
    Assert.assertFalse(ChartTableFactory.isDqRule(dqRule));
}
Also used : TdView(org.talend.cwm.relational.TdView) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with TdView

use of org.talend.cwm.relational.TdView in project tdq-studio-se by Talend.

the class ReadItemConnectionFile method test.

@Test
public void test() {
    EMFUtil emfUtil = new EMFUtil();
    File file = new File("data/my_0.1.item");
    System.out.println("Loading file " + file.getAbsolutePath());
    ResourceSet rs = emfUtil.getResourceSet();
    Resource r = rs.getResource(URI.createFileURI(file.getAbsolutePath()), true);
    // TreeIterator<EObject> allContents = r.getAllContents();
    // while (allContents.hasNext()) {
    // EObject metadata = allContents.next();
    // System.out.println(metadata);
    // }
    // should contain the connection, then catalog/schema, then tables, then columns
    EList<EObject> contents = r.getContents();
    // switch class that returns a connection when it finds one.
    ConnectionSwitch<Connection> connectionFinder = new ConnectionSwitch<Connection>() {

        /*
             * (non-Javadoc)
             * 
             * @see
             * org.talend.core.model.metadata.builder.connection.util.ConnectionSwitch#caseConnection(org.talend.core
             * .model.metadata.builder.connection.Connection)
             */
        @Override
        public Connection caseConnection(Connection object) {
            return object;
        }
    };
    // loop on all the content of the resource
    for (EObject eObject : contents) {
        Connection connection = connectionFinder.doSwitch(eObject);
        if (connection != null) {
            Set<Catalog> allCatalogs = ConnectionHelper.getAllCatalogs(connection);
            for (Catalog catalog : allCatalogs) {
                System.out.println("## Catalog: " + catalog.getName());
                System.out.println("\t## Tables");
                List<TdTable> tables = CatalogHelper.getTables(catalog);
                for (TdTable tdTable : tables) {
                    System.out.println("\t\t" + tdTable.getName());
                    List<TdColumn> columns = TableHelper.getColumns(tdTable);
                    if (!columns.isEmpty()) {
                        System.out.println("\t\t\t## Columns");
                    }
                    for (TdColumn tdColumn : columns) {
                        System.out.println("\t\t\t\t" + tdColumn.getName());
                    }
                }
                System.out.println("\t## Views");
                List<TdView> views = CatalogHelper.getViews(catalog);
                for (TdView tdView : views) {
                    System.out.println("\t\t" + tdView.getName());
                    List<TdColumn> columns = ViewHelper.getColumns(tdView);
                    if (!columns.isEmpty()) {
                        System.out.println("\t\t\t## Columns");
                    }
                    for (TdColumn tdColumn : columns) {
                        System.out.println("\t\t\t\t" + tdColumn.getName());
                    }
                }
            }
        }
    }
}
Also used : TdTable(org.talend.cwm.relational.TdTable) Resource(org.eclipse.emf.ecore.resource.Resource) Connection(org.talend.core.model.metadata.builder.connection.Connection) ConnectionSwitch(org.talend.core.model.metadata.builder.connection.util.ConnectionSwitch) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) Catalog(orgomg.cwm.resource.relational.Catalog) TdColumn(org.talend.cwm.relational.TdColumn) EMFUtil(org.talend.commons.emf.EMFUtil) TdView(org.talend.cwm.relational.TdView) EObject(org.eclipse.emf.ecore.EObject) File(java.io.File) Test(org.junit.Test)

Aggregations

TdView (org.talend.cwm.relational.TdView)26 TdTable (org.talend.cwm.relational.TdTable)15 ArrayList (java.util.ArrayList)9 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 TdColumn (org.talend.cwm.relational.TdColumn)8 IRepositoryNode (org.talend.repository.model.IRepositoryNode)7 RepositoryNode (org.talend.repository.model.RepositoryNode)7 Catalog (orgomg.cwm.resource.relational.Catalog)7 Test (org.junit.Test)5 TdViewRepositoryObject (org.talend.core.repository.model.repositoryObject.TdViewRepositoryObject)5 Schema (orgomg.cwm.resource.relational.Schema)5 Connection (org.talend.core.model.metadata.builder.connection.Connection)4 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)4 DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)4 Package (orgomg.cwm.objectmodel.core.Package)4 EObject (org.eclipse.emf.ecore.EObject)3 MetadataCatalogRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataCatalogRepositoryObject)3 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)3 TdTableRepositoryObject (org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject)3 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)3