Search in sources :

Example 6 with JSONFileConnection

use of org.talend.repository.model.json.JSONFileConnection in project tdi-studio-se by Talend.

the class JSONConnectionContextHelper method revertPropertiesForContextMode.

public static void revertPropertiesForContextMode(ConnectionItem connItem, ContextType contextType) {
    if (connItem == null || contextType == null) {
        return;
    }
    Connection conn = connItem.getConnection();
    if (conn instanceof JSONFileConnection) {
        revertJSONFilePropertiesForContextMode((JSONFileConnection) conn, contextType);
    }
    // set connection for context mode
    conn.setContextMode(false);
    conn.setContextId(EMPTY);
}
Also used : JSONFileConnection(org.talend.repository.model.json.JSONFileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) JSONFileConnection(org.talend.repository.model.json.JSONFileConnection)

Example 7 with JSONFileConnection

use of org.talend.repository.model.json.JSONFileConnection 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 8 with JSONFileConnection

use of org.talend.repository.model.json.JSONFileConnection 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 9 with JSONFileConnection

use of org.talend.repository.model.json.JSONFileConnection in project tdi-studio-se by Talend.

the class JSONDragAndDropHandler method isValidForDataViewer.

@Override
public boolean isValidForDataViewer(Connection connection, IMetadataTable metadataTable) {
    if (!canHandle(connection)) {
        return false;
    }
    boolean isValid = false;
    JSONFileConnection jsonFileConnection = (JSONFileConnection) connection;
    if (jsonFileConnection.isInputModel()) {
        isValid = true;
    } else {
        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        MessageDialog.openWarning(shell, Messages.JSONDragAndDropHandler_dataViewer_warning_title, Messages.JSONDragAndDropHandler_dataViewer_warning_message);
    }
    return isValid;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) JSONFileConnection(org.talend.repository.model.json.JSONFileConnection)

Example 10 with JSONFileConnection

use of org.talend.repository.model.json.JSONFileConnection in project tdi-studio-se by Talend.

the class JSONFileStep3Form method runShadowProcess.

/**
     * run a ShadowProcess to determined the Metadata.
     */
protected void runShadowProcess(Boolean flag) {
    // getConnection().getXsdFilePath() != null && !getConnection().getXsdFilePath().equals("") &&
    JSONFileConnection connection2 = getConnection();
    String tempJSONFilePath = getContextJSONPath(connection2);
    try {
        informationLabel.setText("   " + "Guess in progress...");
        CsvArray csvArray = null;
        if (EJsonReadbyMode.JSONPATH.getValue().equals(connection2.getReadbyMode())) {
            //$NON-NLS-1$
            csvArray = JSONShadowProcessHelper.getCsvArray(getProcessDescription(false), "FILE_JSON");
        } else {
            //$NON-NLS-1$
            csvArray = JSONShadowProcessHelper.getCsvArray(getProcessDescription(false), "FILE_XML");
        }
        if (csvArray == null) {
            informationLabel.setText("   " + "Guess failure");
        } else {
            refreshMetaDataTable(csvArray, connection2.getSchema().get(0).getSchemaTargets(), flag);
        }
    } catch (CoreException e) {
        if (getParent().getChildren().length == 1) {
            new ErrorDialogWidthDetailArea(getShell(), PID, "Guess failure" + "\n" + "Guess based on preview to step 2", e.getMessage());
        } else {
            new ErrorDialogWidthDetailArea(getShell(), PID, "Guess failure", e.getMessage());
        }
        log.error("Guess failure" + " " + e.getMessage());
    }
    checkFieldsValue();
}
Also used : JSONFileConnection(org.talend.repository.model.json.JSONFileConnection) CsvArray(org.talend.core.utils.CsvArray) CoreException(org.eclipse.core.runtime.CoreException) ErrorDialogWidthDetailArea(org.talend.commons.ui.swt.dialogs.ErrorDialogWidthDetailArea)

Aggregations

JSONFileConnection (org.talend.repository.model.json.JSONFileConnection)21 Connection (org.talend.core.model.metadata.builder.connection.Connection)6 ArrayList (java.util.ArrayList)4 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)4 EList (org.eclipse.emf.common.util.EList)3 ProcessDescription (org.talend.metadata.managment.ui.preview.ProcessDescription)3 AbstractForm (org.talend.metadata.managment.ui.wizard.AbstractForm)3 JSONFileConnectionItem (org.talend.repository.model.json.JSONFileConnectionItem)3 List (java.util.List)2 CoreException (org.eclipse.core.runtime.CoreException)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 Composite (org.eclipse.swt.widgets.Composite)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 IDesignerCoreUIService (org.talend.core.ui.services.IDesignerCoreUIService)2 CsvArray (org.talend.core.utils.CsvArray)2 ContextType (org.talend.designer.core.model.utils.emf.talendfile.ContextType)2 JSONXPathLoopDescriptor (org.talend.repository.model.json.JSONXPathLoopDescriptor)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GridData (org.eclipse.swt.layout.GridData)1