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