Search in sources :

Example 1 with ProcessDescription

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;
}
Also used : ProcessDescription(org.talend.metadata.managment.ui.preview.ProcessDescription)

Example 2 with 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;
}
Also used : ProcessDescription(org.talend.metadata.managment.ui.preview.ProcessDescription) JSONFileConnection(org.talend.repository.model.json.JSONFileConnection)

Example 3 with 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;
}
Also used : ProcessDescription(org.talend.metadata.managment.ui.preview.ProcessDescription) JSONFileConnection(org.talend.repository.model.json.JSONFileConnection)

Example 4 with 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;
}
Also used : ProcessDescription(org.talend.metadata.managment.ui.preview.ProcessDescription) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) SchemaTarget(org.talend.repository.model.json.SchemaTarget)

Example 5 with 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());
}
Also used : ProcessDescription(org.talend.metadata.managment.ui.preview.ProcessDescription) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) CsvArray(org.talend.core.utils.CsvArray) ArrayList(java.util.ArrayList) File(java.io.File) HDFSFile(org.talend.designer.hdfsbrowse.model.HDFSFile)

Aggregations

ProcessDescription (org.talend.metadata.managment.ui.preview.ProcessDescription)7 ArrayList (java.util.ArrayList)3 JSONFileConnection (org.talend.repository.model.json.JSONFileConnection)3 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 CsvArray (org.talend.core.utils.CsvArray)2 File (java.io.File)1 Charset (java.nio.charset.Charset)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CoreException (org.eclipse.core.runtime.CoreException)1 EList (org.eclipse.emf.common.util.EList)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 IDesignerCoreUIService (org.talend.core.ui.services.IDesignerCoreUIService)1 ContextType (org.talend.designer.core.model.utils.emf.talendfile.ContextType)1 HDFSFile (org.talend.designer.hdfsbrowse.model.HDFSFile)1 SchemaTarget (org.talend.repository.model.json.SchemaTarget)1