Search in sources :

Example 1 with InputTable

use of org.talend.designer.mapper.model.emf.mapper.InputTable in project tdi-studio-se by Talend.

the class MapperHelper method saveDataToEmf.

public static void saveDataToEmf(ExternalMapperData externalData, MapperData emfMapperData) {
    if (externalData == null || externalData == null) {
        return;
    }
    // input
    if (externalData.getInputTables() != null && !externalData.getInputTables().isEmpty()) {
        for (ExternalMapperTable table : externalData.getInputTables()) {
            final InputTable persistentTable = MapperFactory.eINSTANCE.createInputTable();
            setInOutPersistentTable(persistentTable, table);
            persistentTable.setLookupMode(table.getLookupMode());
            persistentTable.setMatchingMode(table.getMatchingMode());
            persistentTable.setInnerJoin(table.isInnerJoin());
            persistentTable.setPersistent(table.isPersistent());
            persistentTable.setId(table.getId());
            if (table.getGlobalMapKeysValues() != null && !table.getGlobalMapKeysValues().isEmpty()) {
                persistentTable.getGlobalMapKeysValues().addAll(getPersistentTableEntitys(table.getGlobalMapKeysValues()));
            }
            emfMapperData.getInputTables().add(persistentTable);
        }
    }
    // output
    if (externalData.getOutputTables() != null && !externalData.getOutputTables().isEmpty()) {
        for (ExternalMapperTable table : externalData.getOutputTables()) {
            final OutputTable persistentTable = MapperFactory.eINSTANCE.createOutputTable();
            setInOutPersistentTable(persistentTable, table);
            persistentTable.setReject(table.isReject());
            persistentTable.setRejectInnerJoin(table.isRejectInnerJoin());
            persistentTable.setIsErrorRejectTable(table.isErrorRejectTable());
            persistentTable.setIsJoinTableOf(table.getIsJoinTableOf());
            persistentTable.setId(table.getId());
            emfMapperData.getOutputTables().add(persistentTable);
        }
    }
    // var
    if (externalData.getVarsTables() != null && !externalData.getVarsTables().isEmpty()) {
        for (ExternalMapperTable table : externalData.getVarsTables()) {
            final VarTable persistentVarTable = MapperFactory.eINSTANCE.createVarTable();
            persistentVarTable.setMinimized(table.isMinimized());
            persistentVarTable.setName(table.getName());
            persistentVarTable.setSizeState(getSizeState(table.getSizeState()));
            if (table.getMetadataTableEntries() != null && !table.getMetadataTableEntries().isEmpty()) {
                persistentVarTable.getMapperTableEntries().addAll(getPersistentTableEntitys(table.getMetadataTableEntries()));
            }
            emfMapperData.getVarTables().add(persistentVarTable);
        }
    }
    // ui properties
    if (externalData.getUiProperties() != null) {
        final UiProperties createUiProperties = MapperFactory.eINSTANCE.createUiProperties();
        createUiProperties.setShellMaximized(externalData.getUiProperties().isShellMaximized());
        emfMapperData.setUiProperties(createUiProperties);
    }
}
Also used : VarTable(org.talend.designer.mapper.model.emf.mapper.VarTable) InputTable(org.talend.designer.mapper.model.emf.mapper.InputTable) ExternalMapperTable(org.talend.designer.mapper.external.data.ExternalMapperTable) OutputTable(org.talend.designer.mapper.model.emf.mapper.OutputTable) UiProperties(org.talend.designer.mapper.model.emf.mapper.UiProperties)

Example 2 with InputTable

use of org.talend.designer.mapper.model.emf.mapper.InputTable in project tdi-studio-se by Talend.

the class DesignerMapperService method createAutoMappedNode.

public void createAutoMappedNode(INode node, IConnection inputConnection, IConnection outputConnection) {
    MapperData data = (MapperData) node.getExternalNode().getExternalEmfData();
    data.setUiProperties(MapperFactory.eINSTANCE.createUiProperties());
    data.getUiProperties().setShellMaximized(true);
    data.getInputTables().clear();
    InputTable inputTable = MapperFactory.eINSTANCE.createInputTable();
    data.getInputTables().add(inputTable);
    inputTable.setName(inputConnection.getName());
    for (IMetadataColumn column : inputConnection.getMetadataTable().getListColumns()) {
        MapperTableEntry tableEntry = MapperFactory.eINSTANCE.createMapperTableEntry();
        tableEntry.setName(column.getLabel());
        tableEntry.setType(column.getTalendType());
        tableEntry.setNullable(column.isNullable());
        inputTable.getMapperTableEntries().add(tableEntry);
    }
    data.getOutputTables().clear();
    OutputTable outputTable = MapperFactory.eINSTANCE.createOutputTable();
    data.getOutputTables().add(outputTable);
    outputTable.setName(outputConnection.getName());
    for (IMetadataColumn column : outputConnection.getMetadataTable().getListColumns()) {
        MapperTableEntry tableEntry = MapperFactory.eINSTANCE.createMapperTableEntry();
        tableEntry.setName(column.getLabel());
        tableEntry.setType(column.getTalendType());
        tableEntry.setNullable(column.isNullable());
        tableEntry.setExpression(inputConnection.getName() + "." + column.getLabel());
        outputTable.getMapperTableEntries().add(tableEntry);
    }
    ((MapperComponent) node.getExternalNode()).buildExternalData(data);
}
Also used : InputTable(org.talend.designer.mapper.model.emf.mapper.InputTable) MapperTableEntry(org.talend.designer.mapper.model.emf.mapper.MapperTableEntry) ExternalMapperTableEntry(org.talend.designer.mapper.external.data.ExternalMapperTableEntry) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) MapperData(org.talend.designer.mapper.model.emf.mapper.MapperData) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) OutputTable(org.talend.designer.mapper.model.emf.mapper.OutputTable)

Example 3 with InputTable

use of org.talend.designer.mapper.model.emf.mapper.InputTable in project tdi-studio-se by Talend.

the class DesignerMapperService method getRepositorySchemaIds.

public List<String> getRepositorySchemaIds(AbstractExternalData nodeData) {
    List<String> schemaIds = new ArrayList<String>();
    if (nodeData != null && nodeData instanceof MapperData) {
        MapperData mapperData = (MapperData) nodeData;
        EList<InputTable> inputTables = mapperData.getInputTables();
        if (inputTables != null && inputTables.size() > 0) {
            for (InputTable inputTable : inputTables) {
                String id = inputTable.getId();
                if (id != null && !schemaIds.contains(id)) {
                    schemaIds.add(id);
                }
            }
        }
        EList<OutputTable> outputTables = mapperData.getOutputTables();
        if (outputTables != null && outputTables.size() > 0) {
            for (OutputTable outputTable : outputTables) {
                String id = outputTable.getId();
                if (id != null && !schemaIds.contains(id)) {
                    schemaIds.add(id);
                }
            }
        }
    }
    return schemaIds;
}
Also used : InputTable(org.talend.designer.mapper.model.emf.mapper.InputTable) ArrayList(java.util.ArrayList) ExternalMapperData(org.talend.designer.mapper.external.data.ExternalMapperData) MapperData(org.talend.designer.mapper.model.emf.mapper.MapperData) OutputTable(org.talend.designer.mapper.model.emf.mapper.OutputTable)

Example 4 with InputTable

use of org.talend.designer.mapper.model.emf.mapper.InputTable 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 5 with InputTable

use of org.talend.designer.mapper.model.emf.mapper.InputTable in project tdi-studio-se by Talend.

the class MapperDataImplTest method test1.

private void test1() {
    MapperDataImpl mapData1 = new MapperDataImpl();
    MapperDataImpl mapData2 = new MapperDataImpl();
    assertTrue(mapData1.equals(mapData2));
    final InputTable persistentTable = MapperFactory.eINSTANCE.createInputTable();
    persistentTable.setActivateCondensedTool(true);
    persistentTable.setActivateExpressionFilter(true);
    persistentTable.setActivateColumnNameFilter(true);
    persistentTable.setExpressionFilter("expressionFilter1");
    persistentTable.setMinimized(false);
    persistentTable.setName("tableName");
    persistentTable.setSizeState(SizeState.MAXIMIZED);
    persistentTable.setLookupMode("LookupMode");
    persistentTable.setMatchingMode("MatchingMode");
    persistentTable.setInnerJoin(true);
    persistentTable.setPersistent(false);
    persistentTable.setId("id1");
    final MapperTableEntry emfMapperTableEntry = MapperFactory.eINSTANCE.createMapperTableEntry();
    emfMapperTableEntry.setExpression("expression1");
    emfMapperTableEntry.setName("entityName");
    emfMapperTableEntry.setNullable(false);
    emfMapperTableEntry.setType("type1");
    emfMapperTableEntry.setOperator("operator1");
    persistentTable.getMapperTableEntries().add(emfMapperTableEntry);
    final MapperTableEntry mapperTableEntry = MapperFactory.eINSTANCE.createMapperTableEntry();
    mapperTableEntry.setExpression("expression1");
    mapperTableEntry.setName("entityName");
    mapperTableEntry.setNullable(true);
    mapperTableEntry.setType("type1");
    mapperTableEntry.setOperator("operator1");
    persistentTable.getGlobalMapKeysValues().add(emfMapperTableEntry);
    mapData1.getInputTables().add(persistentTable);
    final InputTable persistentTable2 = MapperFactory.eINSTANCE.createInputTable();
    persistentTable2.setActivateCondensedTool(true);
    persistentTable2.setActivateExpressionFilter(true);
    persistentTable2.setActivateColumnNameFilter(true);
    persistentTable2.setExpressionFilter("expressionFilter1");
    persistentTable2.setMinimized(false);
    persistentTable2.setName("tableName");
    persistentTable2.setSizeState(SizeState.MAXIMIZED);
    persistentTable2.setLookupMode("LookupMode");
    persistentTable2.setMatchingMode("MatchingMode");
    persistentTable2.setInnerJoin(true);
    persistentTable2.setPersistent(false);
    persistentTable2.setId("id1");
    final MapperTableEntry emfMapperTableEntry2 = MapperFactory.eINSTANCE.createMapperTableEntry();
    emfMapperTableEntry2.setExpression("expression1");
    emfMapperTableEntry2.setName("entityName");
    emfMapperTableEntry2.setNullable(false);
    emfMapperTableEntry2.setType("type1");
    emfMapperTableEntry2.setOperator("operator1");
    persistentTable2.getMapperTableEntries().add(emfMapperTableEntry2);
    final MapperTableEntry mapperTableEntry2 = MapperFactory.eINSTANCE.createMapperTableEntry();
    mapperTableEntry2.setExpression("expression1");
    mapperTableEntry2.setName("entityName");
    mapperTableEntry2.setNullable(true);
    mapperTableEntry2.setType("type1");
    mapperTableEntry2.setOperator("operator1");
    persistentTable2.getGlobalMapKeysValues().add(emfMapperTableEntry2);
    mapData2.getInputTables().add(persistentTable2);
    assertTrue(mapData1.equals(mapData2));
}
Also used : InputTable(org.talend.designer.mapper.model.emf.mapper.InputTable) MapperTableEntry(org.talend.designer.mapper.model.emf.mapper.MapperTableEntry)

Aggregations

InputTable (org.talend.designer.mapper.model.emf.mapper.InputTable)7 OutputTable (org.talend.designer.mapper.model.emf.mapper.OutputTable)5 ExternalMapperData (org.talend.designer.mapper.external.data.ExternalMapperData)3 MapperData (org.talend.designer.mapper.model.emf.mapper.MapperData)3 MapperTableEntry (org.talend.designer.mapper.model.emf.mapper.MapperTableEntry)3 VarTable (org.talend.designer.mapper.model.emf.mapper.VarTable)3 ArrayList (java.util.ArrayList)2 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)2 UiProperties (org.talend.designer.mapper.model.emf.mapper.UiProperties)2 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)1 ExternalMapperTableEntry (org.talend.designer.mapper.external.data.ExternalMapperTableEntry)1 ExternalMapperUiProperties (org.talend.designer.mapper.external.data.ExternalMapperUiProperties)1