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;
}
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;
}
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);
}
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);
}
}
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;
}
Aggregations