Search in sources :

Example 21 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 22 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 23 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)

Example 24 with ExternalMapperTable

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

the class ExternalDataConverter method loadInExternalData.

private void loadInExternalData(Collection<? extends AbstractDataMapTable> tables) {
    for (IDataMapTable table : tables) {
        ExternalMapperTable externalMapperTable = new ExternalMapperTable();
        fillExternalTable(table, externalMapperTable);
        ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
        boolean isVarTable = table instanceof VarsTable;
        boolean isInputTable = table instanceof InputTable;
        for (ITableEntry dataMapTableEntry : table.getColumnEntries()) {
            ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
            externalMapperTableEntry.setExpression(dataMapTableEntry.getExpression());
            externalMapperTableEntry.setName(dataMapTableEntry.getName());
            if (isVarTable) {
                externalMapperTableEntry.setType(((VarTableEntry) dataMapTableEntry).getType());
                externalMapperTableEntry.setNullable(((VarTableEntry) dataMapTableEntry).isNullable());
            } else {
                externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
                externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
            }
            if (isInputTable) {
                externalMapperTableEntry.setOperator(((InputColumnTableEntry) dataMapTableEntry).getOperator());
            }
            perTableEntries.add(externalMapperTableEntry);
        }
        externalMapperTable.setMetadataTableEntries(perTableEntries);
    }
}
Also used : InputTable(org.talend.designer.mapper.model.table.InputTable) VarsTable(org.talend.designer.mapper.model.table.VarsTable) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) AbstractInOutTableEntry(org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)

Example 25 with ExternalMapperTable

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

the class ExternalDataConverter method setTMapMess.

public ExternalMapperData setTMapMess(MapperModel mapperModel, ExternalMapperUiProperties uiProperties) {
    ExternalMapperData externalData = new ExternalMapperData();
    inputTables = new ArrayList<ExternalMapperTable>();
    externalData.setInputTables(inputTables);
    outputTables = new ArrayList<ExternalMapperTable>();
    externalData.setOutputTables(outputTables);
    varsTables = new ArrayList<ExternalMapperTable>();
    externalData.setVarsTables(varsTables);
    loadInExternalData(mapperModel.getInputDataMapTables());
    loadInExternalData(mapperModel.getVarsDataMapTables());
    loadInExternalData(mapperModel.getOutputDataMapTables(), mapperModel.getInputDataMapTables());
    externalData.setUiProperties(uiProperties);
    return externalData;
}
Also used : ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData)

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