Search in sources :

Example 1 with IHashConfiguration

use of org.talend.core.model.process.IHashConfiguration in project tdi-studio-se by Talend.

the class XmlMapComponent method getHashConfiguration.

@Override
public IHashConfiguration getHashConfiguration(String connectionName) {
    IHashConfiguration hashConfigurationForMapper = null;
    XmlMapData externalData = (XmlMapData) getExternalEmfData();
    List<InputXmlTree> inputTables = externalData.getInputTrees();
    List<IHashableColumn> hashableColumns = new ArrayList<IHashableColumn>();
    for (InputXmlTree inputTable : inputTables) {
        if (inputTable.getName().equals(connectionName)) {
            List<TreeNode> metadataTableEntries = inputTable.getNodes();
            if (metadataTableEntries != null) {
                int metadataTableEntriesListSize = metadataTableEntries.size();
                for (int i = 0; i < metadataTableEntriesListSize; i++) {
                    TreeNode entry = metadataTableEntries.get(i);
                    if (entry.getExpression() != null && !entry.getExpression().trim().equals("")) {
                        //$NON-NLS-1$
                        hashableColumns.add(new HashableColumn(entry.getName(), i));
                    }
                }
            }
            IMatchingMode matchingMode = MATCHING_MODE.parse(inputTable.getMatchingMode());
            if (matchingMode == null) {
                matchingMode = MATCHING_MODE.UNIQUE_MATCH;
            }
            ILookupMode lookupMode = org.talend.designer.xmlmap.model.tree.LOOKUP_MODE.parse(inputTable.getLookupMode());
            if (lookupMode == null) {
                lookupMode = org.talend.designer.xmlmap.model.tree.LOOKUP_MODE.LOAD_ONCE;
            }
            //$NON-NLS-1$
            IElementParameter tempFolderElem = getElementParameter("TEMPORARY_DATA_DIRECTORY");
            String tempFolder = null;
            if (tempFolderElem != null) {
                tempFolder = (String) tempFolderElem.getValue();
            }
            if (("").equals(tempFolder)) {
                //$NON-NLS-1$ //$NON-NLS-2$
                tempFolder = (String) this.getProcess().getElementParameter("COMP_DEFAULT_FILE_DIR").getValue() + "/temp";
                tempFolder = TalendTextUtils.addQuotes(tempFolder);
            }
            //$NON-NLS-1$
            IElementParameter rowsBufferSizeElem = getElementParameter("ROWS_BUFFER_SIZE");
            String rowsBufferSize = null;
            if (rowsBufferSizeElem != null) {
                rowsBufferSize = (String) rowsBufferSizeElem.getValue();
            }
            hashConfigurationForMapper = new HashConfiguration(hashableColumns, matchingMode, inputTable.isPersistent(), tempFolder, rowsBufferSize);
            break;
        }
    }
    return hashConfigurationForMapper;
}
Also used : HashConfiguration(org.talend.core.model.process.HashConfiguration) IHashConfiguration(org.talend.core.model.process.IHashConfiguration) IHashableColumn(org.talend.core.model.process.IHashableColumn) HashableColumn(org.talend.core.model.process.HashableColumn) ILookupMode(org.talend.core.model.process.ILookupMode) ArrayList(java.util.ArrayList) IHashableColumn(org.talend.core.model.process.IHashableColumn) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) IMatchingMode(org.talend.core.model.process.IMatchingMode) IElementParameter(org.talend.core.model.process.IElementParameter) IHashConfiguration(org.talend.core.model.process.IHashConfiguration) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 2 with IHashConfiguration

use of org.talend.core.model.process.IHashConfiguration in project tdi-studio-se by Talend.

the class MapperComponent method getHashConfiguration.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.process.IHashableInputConnections#getHashConfiguration(java.lang.String)
     */
public IHashConfiguration getHashConfiguration(String connectionName) {
    IHashConfiguration hashConfigurationForMapper = null;
    ExternalMapperData externalData = (ExternalMapperData) getExternalData();
    List<ExternalMapperTable> inputTables = externalData.getInputTables();
    List<IHashableColumn> hashableColumns = new ArrayList<IHashableColumn>();
    for (ExternalMapperTable inputTable : inputTables) {
        if (inputTable.getName().equals(connectionName)) {
            List<ExternalMapperTableEntry> metadataTableEntries = inputTable.getMetadataTableEntries();
            if (metadataTableEntries != null) {
                int metadataTableEntriesListSize = metadataTableEntries.size();
                for (int i = 0; i < metadataTableEntriesListSize; i++) {
                    ExternalMapperTableEntry entry = metadataTableEntries.get(i);
                    if (entry.getExpression() != null && !entry.getExpression().trim().equals("")) {
                        //$NON-NLS-1$
                        hashableColumns.add(new HashableColumn(entry.getName(), i));
                    }
                }
            }
            IMatchingMode matchingMode = MATCHING_MODE.parse(inputTable.getMatchingMode());
            if (matchingMode == null) {
                matchingMode = MATCHING_MODE.UNIQUE_MATCH;
            }
            ILookupMode lookupMode = LOOKUP_MODE.parse(inputTable.getLookupMode());
            if (lookupMode == null) {
                lookupMode = LOOKUP_MODE.LOAD_ONCE;
            }
            //$NON-NLS-1$
            IElementParameter tempFolderElem = getElementParameter("TEMPORARY_DATA_DIRECTORY");
            // modified by wzhang to fix 7824
            String tempFolder = null;
            if (tempFolderElem != null) {
                tempFolder = (String) tempFolderElem.getValue();
            }
            if (("").equals(tempFolder)) {
                //$NON-NLS-1$ //$NON-NLS-2$
                tempFolder = (String) this.getProcess().getElementParameter("COMP_DEFAULT_FILE_DIR").getValue() + "/temp";
                tempFolder = TalendTextUtils.addQuotes(tempFolder);
            }
            //$NON-NLS-1$
            IElementParameter rowsBufferSizeElem = getElementParameter("ROWS_BUFFER_SIZE");
            String rowsBufferSize = null;
            if (rowsBufferSizeElem != null) {
                rowsBufferSize = (String) rowsBufferSizeElem.getValue();
            }
            hashConfigurationForMapper = new HashConfiguration(hashableColumns, matchingMode, inputTable.isPersistent(), tempFolder, rowsBufferSize);
            break;
        }
    }
    return hashConfigurationForMapper;
}
Also used : HashConfiguration(org.talend.core.model.process.HashConfiguration) IHashConfiguration(org.talend.core.model.process.IHashConfiguration) IHashableColumn(org.talend.core.model.process.IHashableColumn) HashableColumn(org.talend.core.model.process.HashableColumn) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ILookupMode(org.talend.core.model.process.ILookupMode) ArrayList(java.util.ArrayList) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) IHashableColumn(org.talend.core.model.process.IHashableColumn) IMatchingMode(org.talend.core.model.process.IMatchingMode) IElementParameter(org.talend.core.model.process.IElementParameter) IHashConfiguration(org.talend.core.model.process.IHashConfiguration)

Aggregations

ArrayList (java.util.ArrayList)2 HashConfiguration (org.talend.core.model.process.HashConfiguration)2 HashableColumn (org.talend.core.model.process.HashableColumn)2 IElementParameter (org.talend.core.model.process.IElementParameter)2 IHashConfiguration (org.talend.core.model.process.IHashConfiguration)2 IHashableColumn (org.talend.core.model.process.IHashableColumn)2 ILookupMode (org.talend.core.model.process.ILookupMode)2 IMatchingMode (org.talend.core.model.process.IMatchingMode)2 ExternalMapperData (org.talend.designer.mapper.external.data.ExternalMapperData)1 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)1 ExternalMapperTableEntry (org.talend.designer.mapper.external.data.ExternalMapperTableEntry)1 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)1 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)1 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)1 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)1