Search in sources :

Example 36 with MetadataTable

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

the class DrillDownEditorInput method getDesignatedData.

/**
 * DOC zshen Comment method "getDesignatedData".
 *
 * @return make column mapping with data
 */
private List<Object[]> getDesignatedData(List<Object[]> dataList) {
    ModelElement analysisElement = currIndicator.getAnalyzedElement();
    List<Object[]> returnDataList = new ArrayList<Object[]>();
    if (dataList == null || dataList.size() < 0) {
        return returnDataList;
    }
    if (DrillDownUtils.judgeMenuType(this.getMenuType(), DrillDownUtils.MENU_VALUE_TYPE)) {
        int offset = 0;
        // MOD qiongli 2011-3-3 feature 19192 drill down for columnSet with jave engine.
        if (analysisElement == null && currIndicator.eContainer() instanceof SimpleStatIndicator) {
            returnDataList = dataList;
        } else {
            if (analysisElement instanceof MetadataColumn) {
                MetadataTable mTable = ColumnHelper.getColumnOwnerAsMetadataTable((MetadataColumn) analysisElement);
                List<MetadataColumn> columnElementList = mTable.getColumns();
                offset = columnElementList.indexOf(analysisElement);
            }
            // Added yyin 20120608 TDQ-3589
            if (currIndicator instanceof DuplicateCountIndicator) {
                for (Object obj : ((DuplicateCountIndicator) currIndicator).getDuplicateValues()) {
                    Object[] newObj = new Object[1];
                    newObj[0] = obj;
                    returnDataList.add(newObj);
                }
                return returnDataList;
            }
            // ~
            for (Object[] obj : dataList) {
                Object[] newObj = new Object[1];
                newObj[0] = obj[offset];
                returnDataList.add(newObj);
            }
        }
    } else {
        returnDataList = dataList;
    }
    return returnDataList;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) EObject(org.eclipse.emf.ecore.EObject) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator)

Example 37 with MetadataTable

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

the class DrillDownEditorInput method getColumnIndexArray.

/**
 * Get index of column whiche will be used on the dirll down. Note that One indicator only belong one column so that
 * the array of retrun value just contain one element.
 *
 * And if we create new map for view values menu rather than used same map with view rows menu then method can be
 * removed
 *
 * @return
 */
public Integer[] getColumnIndexArray() {
    if (!DrillDownUtils.judgeMenuType(this.getMenuType(), DrillDownUtils.MENU_VALUE_TYPE) || !UniqueCountIndicator.class.isInstance(currIndicator)) {
        return null;
    }
    List<Integer> indexArray = new ArrayList<Integer>();
    Indicator indicator = this.getCurrIndicator();
    ModelElement analysisElement = indicator.getAnalyzedElement();
    int index = 0;
    if (analysisElement instanceof TdColumn) {
        List<TdColumn> columns = getColumnsByTdColumn((TdColumn) analysisElement);
        for (TdColumn column : columns) {
            if (column.getName().equals(analysisElement.getName())) {
                indexArray.add(index);
                // break at here.
                break;
            }
            index++;
        }
    } else if (analysisElement instanceof MetadataColumn) {
        MetadataTable mTable = ColumnHelper.getColumnOwnerAsMetadataTable((MetadataColumn) analysisElement);
        for (MetadataColumn mColumn : mTable.getColumns()) {
            if (mColumn.getLabel().equals(analysisElement.getName())) {
                indexArray.add(index);
                // break at here.
                break;
            }
            index++;
        }
    }
    return indexArray.toArray(new Integer[indexArray.size()]);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) DatePatternFreqIndicator(org.talend.dataquality.indicators.DatePatternFreqIndicator) Indicator(org.talend.dataquality.indicators.Indicator) LengthIndicator(org.talend.dataquality.indicators.LengthIndicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Example 38 with MetadataTable

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

the class DrillDownEditorInput method filterAdaptColumnHeader.

/**
 * DOC zshen Comment method "filterAdaptColumnHeader".
 *
 * @returnget the name of column which will be displayed on the drill down editor.
 */
public List<String> filterAdaptColumnHeader() {
    // get columnHeader
    Indicator indicator = this.getCurrIndicator();
    ModelElement analysisElement = indicator.getAnalyzedElement();
    String menuType = this.getMenuType();
    List<String> columnElementList = new ArrayList<String>();
    // MOD qiongli 2011-3-3,feature 19192 ,drill down for columnSet with java engine .
    if (analysisElement == null && indicator.eContainer() instanceof SimpleStatIndicator) {
        columnElementList = columnHeaderForColumnSet((SimpleStatIndicator) indicator.eContainer());
    } else {
        // MOD qiongli 2011-1-9 feature 16796
        if (DrillDownUtils.judgeMenuType(menuType, DrillDownUtils.MENU_VALUE_TYPE)) {
            columnElementList.add(ModelElementHelper.getName(indicator.getAnalyzedElement()));
        } else if (analysisElement instanceof TdColumn) {
            for (TdColumn column : getColumnsByTdColumn((TdColumn) analysisElement)) {
                columnElementList.add(column.getName());
            }
        } else if (analysisElement instanceof MetadataColumn) {
            MetadataTable mTable = ColumnHelper.getColumnOwnerAsMetadataTable((MetadataColumn) analysisElement);
            for (MetadataColumn mColumn : mTable.getColumns()) {
                columnElementList.add(mColumn.getLabel());
            }
        }
    }
    return columnElementList;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) DatePatternFreqIndicator(org.talend.dataquality.indicators.DatePatternFreqIndicator) Indicator(org.talend.dataquality.indicators.Indicator) LengthIndicator(org.talend.dataquality.indicators.LengthIndicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Example 39 with MetadataTable

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

the class RepositoryNodeHelper method getAnalyzeDataNames.

/**
 * Get selected names and split with "/". .e.g,onnection/catalog/schema/table.
 *
 * @param columnNode
 * @return
 */
public static String getAnalyzeDataNames(IRepositoryNode columnNode) {
    ModelElement mod = RepositoryNodeHelper.getModelElementFromRepositoryNode(columnNode);
    if (mod == null) {
        return PluginConstant.EMPTY_STRING;
    }
    MetadataColumn metadataColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(mod);
    if (metadataColumn == null) {
        return PluginConstant.EMPTY_STRING;
    }
    List<String> nameLs = new ArrayList<String>();
    EObject eContainer = metadataColumn.eContainer();
    MetadataTable mdTable = SwitchHelpers.METADATA_TABLE_SWITCH.doSwitch(eContainer);
    if (mdTable != null) {
        nameLs.add(mdTable.getLabel());
        Package parentCatalogOrSchema = ColumnSetHelper.getParentCatalogOrSchema(mdTable);
        Connection conn = null;
        // DelimitedFile conn doesn't have Catalog and Schema.
        if (parentCatalogOrSchema == null) {
            conn = ConnectionHelper.getTdDataProvider(mdTable);
        } else {
            conn = ConnectionHelper.getTdDataProvider(parentCatalogOrSchema);
            Schema schema = SwitchHelpers.SCHEMA_SWITCH.doSwitch(parentCatalogOrSchema);
            Catalog catalog = SwitchHelpers.CATALOG_SWITCH.doSwitch(parentCatalogOrSchema);
            if (schema != null) {
                nameLs.add(schema.getName());
                catalog = CatalogHelper.getParentCatalog(schema);
                if (catalog != null) {
                    nameLs.add(catalog.getName());
                }
            } else if (catalog != null) {
                nameLs.add(catalog.getName());
            }
        }
        if (conn != null) {
            nameLs.add(conn.getName());
        }
    }
    return sortNames(nameLs, PluginConstant.SLASH_STRING);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) EObject(org.eclipse.emf.ecore.EObject) Schema(orgomg.cwm.resource.relational.Schema) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) Package(orgomg.cwm.objectmodel.core.Package) Catalog(orgomg.cwm.resource.relational.Catalog)

Example 40 with MetadataTable

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

the class FileMetadataTableComparisonLevel method getTempTableFromOldFile.

/*
     * find the same name metadata in the old provider, and give the new columns to it.
     */
private EObject getTempTableFromOldFile() throws ReloadCompareException {
    MetadataTable[] metadataTables = ConnectionHelper.getTables(tempReloadProvider).toArray(new MetadataTable[0]);
    String tableName = ((MetadataTable) selectedObj).getLabel();
    for (MetadataTable table : metadataTables) {
        if (table.getLabel().equals(tableName)) {
            // the temp table is the old one in file connection before schema changed
            tempMetadataTable = table;
            // use this temp list to store the compared result.
            comparedColumns.addAll(table.getColumns());
            break;
        }
    }
    util.saveResource(tempMetadataTable.eResource());
    return tempMetadataTable;
}
Also used : MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

Aggregations

MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)153 ArrayList (java.util.ArrayList)53 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)51 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)25 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)23 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)22 List (java.util.List)18 Test (org.junit.Test)17 PersistenceException (org.talend.commons.exception.PersistenceException)17 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)15 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)14 TaggedValue (orgomg.cwm.objectmodel.core.TaggedValue)14 Connection (org.talend.core.model.metadata.builder.connection.Connection)12 RepositoryNode (org.talend.repository.model.RepositoryNode)12 ConnectionItem (org.talend.core.model.properties.ConnectionItem)10 TdColumn (org.talend.cwm.relational.TdColumn)9 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)9 IRepositoryNode (org.talend.repository.model.IRepositoryNode)9 DelimitedFileConnection (org.talend.core.model.metadata.builder.connection.DelimitedFileConnection)8 HashMap (java.util.HashMap)7