Search in sources :

Example 16 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.

the class DesignerMapperService method renameMapperTable.

public void renameMapperTable(IExternalNode externalNode, String schemaId, String newSchemaId, IMetadataTable metadataTable) {
    if (externalNode == null || schemaId == null || metadataTable == null) {
        return;
    }
    if (externalNode instanceof MapperComponent) {
        MapperComponent component = (MapperComponent) externalNode;
        IExternalData nodeData = externalNode.getExternalData();
        if (nodeData != null && nodeData instanceof ExternalMapperData) {
            ExternalMapperData mapperData = (ExternalMapperData) nodeData;
            List<ExternalMapperTable> outputTables = mapperData.getOutputTables();
            if (outputTables != null && outputTables.size() > 0) {
                for (ExternalMapperTable outputTable : outputTables) {
                    if (!schemaId.equals(outputTable.getId())) {
                        continue;
                    }
                    outputTable.setId(newSchemaId);
                    updateEntriesByMetaColumns(newSchemaId, metadataTable, outputTable, component);
                }
            }
        }
    }
}
Also used : IExternalData(org.talend.core.model.process.IExternalData) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData)

Example 17 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.

the class DesignerMapperService method updateMapperTableEntries.

public void updateMapperTableEntries(IExternalNode externalNode, String schemaId, IMetadataTable metadataTable) {
    if (externalNode == null || schemaId == null || metadataTable == null) {
        return;
    }
    if (externalNode instanceof MapperComponent) {
        MapperComponent component = (MapperComponent) externalNode;
        IExternalData nodeData = externalNode.getExternalData();
        if (nodeData != null && nodeData instanceof ExternalMapperData) {
            ExternalMapperData mapperData = (ExternalMapperData) nodeData;
            List<ExternalMapperTable> outputTables = mapperData.getOutputTables();
            if (outputTables != null && outputTables.size() > 0) {
                for (ExternalMapperTable outputTable : outputTables) {
                    updateEntriesByMetaColumns(schemaId, metadataTable, outputTable, component);
                }
            }
        }
    }
}
Also used : IExternalData(org.talend.core.model.process.IExternalData) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData)

Example 18 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.

the class DesignerMapperService method getJoinTableNames.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.mapper.IDesignerMapperService#getJoinTableNames(org.talend.core.model.process.IExternalData)
     */
public List<String> getJoinTableNames(IExternalData data) {
    List<String> namesList = new ArrayList<String>();
    if (data instanceof ExternalMapperData) {
        ExternalMapperData extenalData = (ExternalMapperData) data;
        final List<ExternalMapperTable> outputTables = extenalData.getOutputTables();
        if (outputTables != null) {
            for (ExternalMapperTable table : outputTables) {
                if (table.getIsJoinTableOf() != null && !"".equals(table.getIsJoinTableOf())) {
                    namesList.add(table.getName());
                }
            }
        }
    }
    return namesList;
}
Also used : ArrayList(java.util.ArrayList) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData)

Example 19 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable 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)

Example 20 with ExternalMapperTable

use of org.talend.designer.mapper.external.data.ExternalMapperTable in project tdi-studio-se by Talend.

the class MapperComponent method buildExternalData.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.process.AbstractExternalNode#setExternalXmlData(java.io.InputStream)
     */
// public void loadDataIn(InputStream in, Reader stringReader) throws IOException, ClassNotFoundException {
//
// if (stringReader != null) {
// Unmarshaller unmarshaller = new Unmarshaller(ExternalMapperData.class);
// unmarshaller.setWhitespacePreserve(true);
// try {
// externalData = (ExternalMapperData) unmarshaller.unmarshal(stringReader);
// } catch (MarshalException e) {
// ExceptionHandler.process(e);
// } catch (ValidationException e) {
// ExceptionHandler.process(e);
// } finally {
// if (stringReader != null) {
// stringReader.close();
// }
// }
// }
//
// }
/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.process.IExternalNode#loadDataOut(java.io.OutputStream, java.io.Writer)
     */
// public void loadDataOut(final OutputStream out, Writer writer) throws IOException {
// // System.out.println("loadDataOut");
//
// initMapperMain(false);
//
// mapperMain.createModelFromExternalData(getIncomingConnections(), getOutgoingConnections(), externalData,
// getMetadataList(), false);
// ExternalMapperData data = mapperMain.buildExternalData();
// if (mapperMain != null && data != null) {
//
// try {
// Marshaller marshaller = new Marshaller(writer);
// marshaller.marshal(externalData);
//
// } catch (MarshalException e) {
// ExceptionHandler.process(e);
// } catch (ValidationException e) {
// ExceptionHandler.process(e);
// } catch (IOException e) {
// ExceptionHandler.process(e);
// } finally {
// if (writer != null) {
// writer.close();
// }
// }
//
// // ObjectOutputStream objectOut = null;
// // try {
// // objectOut = new ObjectOutputStream(out);
// // objectOut.writeObject(data);
// // } catch (IOException e) {
// // ExceptionHandler.process(e);
// // } finally {
// // if (objectOut != null) {
// // objectOut.close();
// // }
// // }
// }
// }
@Override
public void buildExternalData(AbstractExternalData abstractData) {
    externalData = new ExternalMapperData();
    if (abstractData instanceof MapperData) {
        MapperData mapperData = (MapperData) abstractData;
        List<ExternalMapperTable> externalTables = new ArrayList<ExternalMapperTable>();
        // input
        for (InputTable pTable : mapperData.getInputTables()) {
            ExternalMapperTable externalTable = new ExternalMapperTable();
            setExternalTable(externalTable, pTable);
            externalTable.setLookupMode(pTable.getLookupMode());
            externalTable.setMatchingMode(pTable.getMatchingMode());
            externalTable.setInnerJoin(pTable.isInnerJoin());
            externalTable.setPersistent(pTable.isPersistent());
            externalTable.setGlobalMapKeysValues(getExternalEntities(pTable.getGlobalMapKeysValues()));
            externalTables.add(externalTable);
        }
        externalData.setInputTables(externalTables);
        // output
        externalTables = new ArrayList<ExternalMapperTable>();
        for (OutputTable pTable : mapperData.getOutputTables()) {
            ExternalMapperTable externalTable = new ExternalMapperTable();
            setExternalTable(externalTable, pTable);
            externalTable.setReject(pTable.isReject());
            externalTable.setRejectInnerJoin(pTable.isRejectInnerJoin());
            externalTable.setErrorRejectTable(pTable.isIsErrorRejectTable());
            externalTable.setIsJoinTableOf(pTable.getIsJoinTableOf());
            externalTables.add(externalTable);
        }
        externalData.setOutputTables(externalTables);
        // var tables
        externalTables = new ArrayList<ExternalMapperTable>();
        for (VarTable varTable : mapperData.getVarTables()) {
            ExternalMapperTable externalTable = new ExternalMapperTable();
            externalTable.setSizeState(varTable.getSizeState().getLiteral());
            externalTable.setMinimized(varTable.isMinimized());
            externalTable.setName(varTable.getName());
            externalTable.setMetadataTableEntries(getExternalEntities(varTable.getMapperTableEntries()));
            externalTables.add(externalTable);
        }
        externalData.setVarsTables(externalTables);
        ExternalMapperUiProperties uiProperties = new ExternalMapperUiProperties();
        UiProperties uiPro = mapperData.getUiProperties();
        if (uiPro != null) {
            uiProperties.setShellMaximized(uiPro.isShellMaximized());
        }
    }
    this.setExternalData(externalData);
}
Also used : VarTable(org.talend.designer.mapper.model.emf.mapper.VarTable) InputTable(org.talend.designer.mapper.model.emf.mapper.InputTable) ExternalMapperUiProperties(org.talend.designer.mapper.external.data.ExternalMapperUiProperties) ArrayList(java.util.ArrayList) MapperData(org.talend.designer.mapper.model.emf.mapper.MapperData) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) OutputTable(org.talend.designer.mapper.model.emf.mapper.OutputTable) UiProperties(org.talend.designer.mapper.model.emf.mapper.UiProperties) ExternalMapperUiProperties(org.talend.designer.mapper.external.data.ExternalMapperUiProperties)

Aggregations

ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)34 ArrayList (java.util.ArrayList)20 ExternalMapperData (org.talend.designer.mapper.external.data.ExternalMapperData)13 ExternalMapperTableEntry (org.talend.designer.mapper.external.data.ExternalMapperTableEntry)11 List (java.util.List)5 HashMap (java.util.HashMap)4 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)4 IExternalData (org.talend.core.model.process.IExternalData)4 IOConnection (org.talend.designer.mapper.external.connection.IOConnection)4 IConnection (org.talend.core.model.process.IConnection)3 Problem (org.talend.core.model.process.Problem)3 MapperComponent (org.talend.designer.mapper.MapperComponent)3 OutputTable (org.talend.designer.mapper.model.table.OutputTable)3 Element (org.dom4j.Element)2 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)2 InputTable (org.talend.designer.mapper.model.emf.mapper.InputTable)2 OutputTable (org.talend.designer.mapper.model.emf.mapper.OutputTable)2 UiProperties (org.talend.designer.mapper.model.emf.mapper.UiProperties)2