use of org.talend.metadata.managment.ui.preview.ProcessDescription in project tdi-studio-se by Talend.
the class MultiSchemasUI method getProcessDescription.
public ProcessDescription getProcessDescription() {
ProcessDescription processDescription = ShadowProcessHelper.getProcessDescription(getConnection());
processDescription.setHeaderRow(-1);
processDescription.setFooterRow(0);
processDescription.setLimitRows(maximumRowsToPreview);
processDescription.setSplitRecord(getConnection().isSplitRecord());
processDescription.setCSVOption(getConnection().isCsvOption());
// add by wzhang to fix 8039.
processDescription.setFilepath(PathUtils.getPortablePath(getConnection().getFilePath()));
String curFilePath = processDescription.getFilepath();
String orignalPath;
if (curFilePath != null) {
orignalPath = multiSchemaManager.getOriginalValue(curFilePath);
processDescription.setFilepath(orignalPath);
}
processDescription.setFieldSeparator(multiSchemaManager.getOriginalValue(processDescription.getFieldSeparator()));
processDescription.setRowSeparator(multiSchemaManager.getOriginalValue(processDescription.getRowSeparator()));
return processDescription;
}
use of org.talend.metadata.managment.ui.preview.ProcessDescription in project tdi-studio-se by Talend.
the class JSONFileStep2Form method getProcessDescription.
/**
* create ProcessDescription and set it.
*
* WARNING ::field FieldSeparator, RowSeparator, EscapeChar and TextEnclosure are surround by double quote.
*
* @param getConnection()
*
* @return processDescription
*/
private ProcessDescription getProcessDescription(boolean defaultContext) {
JSONFileConnection connection2 = JSONConnectionContextUtils.getJSONOriginalValueConnection(getConnection(), this.connectionItem, isContextMode(), defaultContext);
ProcessDescription processDescription = JSONShadowProcessHelper.getProcessDescription(connection2, wizard.getTempJsonPath());
return processDescription;
}
use of org.talend.metadata.managment.ui.preview.ProcessDescription in project tdi-studio-se by Talend.
the class JSONFileStep3Form method getProcessDescription.
/**
* create ProcessDescription and set it.
*
* WARNING ::field FieldSeparator, RowSeparator, EscapeChar and TextEnclosure are surround by double quote.
*
*
* @return processDescription
*/
private ProcessDescription getProcessDescription(boolean defaultContext) {
JSONFileConnection connection2 = JSONConnectionContextUtils.getJSONOriginalValueConnection(getConnection(), this.connectionItem, isContextMode(), defaultContext);
ProcessDescription processDescription = null;
if (wizard != null) {
processDescription = JSONShadowProcessHelper.getProcessDescription(connection2, wizard.getTempJsonPath());
} else {
if (EJsonReadbyMode.JSONPATH.getValue().equals(connection2.getReadbyMode())) {
processDescription = JSONShadowProcessHelper.getProcessDescription(connection2, connection2.getJSONFilePath());
} else {
processDescription = JSONShadowProcessHelper.getProcessDescription(connection2, JSONUtil.changeJsonToXml(connection2.getJSONFilePath()));
}
}
return processDescription;
}
use of org.talend.metadata.managment.ui.preview.ProcessDescription in project tdi-studio-se by Talend.
the class JSONShadowProcessHelper method getProcessDescription.
/**
* Create a ProcessDescription and set it width the value of JSONFileConnection.
*
* This method is usefull to adapt a processDescription before run the shadow process.
*
* @param JSONFileConnection
*
* @return ProcessDescription
*/
public static ProcessDescription getProcessDescription(final JSONFileConnection connection, String tempJsonFile) {
ProcessDescription processDescription = new ProcessDescription();
processDescription.setFilepath(TalendQuoteUtils.addQuotes(PathUtils.getPortablePath(tempJsonFile)));
processDescription.setLoopQuery(TalendQuoteUtils.addQuotes(connection.getSchema().get(0).getAbsoluteXPathQuery()));
if (connection.getSchema().get(0).getLimitBoucle() != null && //$NON-NLS-1$
!("").equals(connection.getSchema().get(0).getLimitBoucle()) && (connection.getSchema().get(0).getLimitBoucle().intValue()) != 0) {
processDescription.setLoopLimit(connection.getSchema().get(0).getLimitBoucle());
}
List<Map<String, String>> mapping = new ArrayList<Map<String, String>>();
List<SchemaTarget> schemaTargets = connection.getSchema().get(0).getSchemaTargets();
if (schemaTargets != null && !schemaTargets.isEmpty()) {
Iterator<SchemaTarget> iterate = schemaTargets.iterator();
while (iterate.hasNext()) {
SchemaTarget schemaTarget = iterate.next();
Map<String, String> lineMapping = new HashMap<String, String>();
//$NON-NLS-1$
lineMapping.put("QUERY", TalendQuoteUtils.addQuotes(schemaTarget.getRelativeXPathQuery()));
mapping.add(lineMapping);
}
}
processDescription.setReadbyMode(connection.getReadbyMode());
processDescription.setMapping(mapping);
if (connection.getEncoding() != null && !("").equals(connection.getEncoding())) {
//$NON-NLS-1$
processDescription.setEncoding(TalendQuoteUtils.addQuotes(connection.getEncoding()));
} else {
//$NON-NLS-1$
processDescription.setEncoding(TalendQuoteUtils.addQuotes("UTF-8"));
}
return processDescription;
}
use of org.talend.metadata.managment.ui.preview.ProcessDescription in project tbd-studio-se by Talend.
the class ExtractTextFileSchemaService method extractColumns.
private List<MetadataColumn> extractColumns(HDFSConnection connection, InputStream inputStream, String tmpFileName) throws CoreException, IOException {
List<MetadataColumn> columns = new ArrayList<MetadataColumn>();
if (connection == null || inputStream == null || tmpFileName == null) {
return columns;
}
File tmpFile = createTmpFile(inputStream, tmpFileName);
ProcessDescription processDescription = getProcessDescription(connection, tmpFile);
CsvArray csvArray = ShadowProcessHelper.getCsvArray(processDescription, DEFAULT_SHADOW_TYPE, true);
return guessSchemaFromArray(csvArray, connection.isFirstLineCaption(), processDescription.getHeaderRow());
}
Aggregations