Search in sources :

Example 11 with JSONObject

use of org.talend.utils.json.JSONObject in project tdi-studio-se by Talend.

the class LoginHelper method getLocation.

private String getLocation(String url) throws JSONException {
    JSONObject jsonObject = new JSONObject(url);
    //$NON-NLS-1$
    String location = "";
    if (jsonObject.has("location")) {
        //$NON-NLS-1$
        location = jsonObject.getString("location");
    }
    return location;
}
Also used : JSONObject(org.talend.utils.json.JSONObject)

Example 12 with JSONObject

use of org.talend.utils.json.JSONObject in project tdi-studio-se by Talend.

the class LoginProjectPage method getStorage.

private String getStorage(Project project) throws JSONException {
    if (project == null) {
        return "";
    }
    String storage = "";
    if (project != null) {
        String url = project.getEmfProject().getUrl();
        if (url == null) {
            return "";
        }
        JSONObject jsonObj = new JSONObject(url);
        storage = jsonObj.getString("storage");
    }
    return storage;
}
Also used : JSONObject(org.talend.utils.json.JSONObject)

Example 13 with JSONObject

use of org.talend.utils.json.JSONObject in project tdi-studio-se by Talend.

the class ColumnListController method reUsedColumnFunctionArrayCheck.

private static void reUsedColumnFunctionArrayCheck(Map<String, Object> newLine, IElement element, String[] codes) {
    if (element instanceof INode && ((INode) element).getMetadataList().size() > 0 && ((INode) element).getComponent().getName().equals("tRowGenerator")) {
        IMetadataTable table = ((INode) element).getMetadataList().get(0);
        //$NON-NLS-1$
        String lineName = (String) newLine.get("SCHEMA_COLUMN");
        for (IMetadataColumn column : table.getListColumns()) {
            if (lineName != null && lineName.equals(column.getLabel()) && "".equals(newLine.get("ARRAY"))) {
                Map<String, String> columnFunction = column.getAdditionalField();
                String functionInfo = columnFunction.get(FUNCTION_INFO);
                if (functionInfo != null) {
                    try {
                        JSONObject functionInfoObj = new JSONObject(functionInfo);
                        String functionExpression = "";
                        String functionName = functionInfoObj.getString(Function.NAME);
                        if (!functionName.equals("...")) {
                            String className = functionInfoObj.getString(Function.PARAMETER_CLASS_NAME);
                            String parmValueApend = "";
                            functionExpression = className + '.' + functionName + "(";
                            JSONArray parametersArray = functionInfoObj.getJSONArray(Function.PARAMETERS);
                            if (parametersArray != null) {
                                for (int i = 0; i < parametersArray.length(); i++) {
                                    JSONObject parameterObj = parametersArray.getJSONObject(i);
                                    String paramValue = parameterObj.getString(Function.PARAMETER_VALUE);
                                    parmValueApend = parmValueApend + paramValue.trim() + ',';
                                }
                            }
                            if (parmValueApend.endsWith(",")) {
                                parmValueApend = parmValueApend.substring(0, parmValueApend.lastIndexOf(","));
                            }
                            functionExpression = functionExpression + parmValueApend + ')';
                            newLine.put("ARRAY", functionExpression);
                        }
                    } catch (JSONException e) {
                        ExceptionHandler.process(e);
                    }
                }
            }
        }
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) INode(org.talend.core.model.process.INode) JSONObject(org.talend.utils.json.JSONObject) JSONArray(org.talend.utils.json.JSONArray) JSONException(org.talend.utils.json.JSONException) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) Point(org.eclipse.swt.graphics.Point)

Example 14 with JSONObject

use of org.talend.utils.json.JSONObject in project tdi-studio-se by Talend.

the class MyExtensionAction method setValuesForExension.

private void setValuesForExension(ComponentExtension componentExtension, String values, List<VersionRevision> versionRevisions) throws JSONException {
    JSONObject jsObject = new JSONObject(values);
    if (jsObject.has(ContentConstants.EXTENSION_VALUE_LABEL)) {
        componentExtension.setLabel(jsObject.getString(ContentConstants.EXTENSION_VALUE_LABEL));
    }
    if (jsObject.has(ContentConstants.EXTENSION_VALUE_LASTVERSIONAVAILABLE)) {
        componentExtension.setLastVersionAvailable(jsObject.getString(ContentConstants.EXTENSION_VALUE_LASTVERSIONAVAILABLE));
    }
    if (jsObject.has(ContentConstants.EXTENSION_VALUE_DESCRIPTION)) {
        componentExtension.setDescription(jsObject.getString(ContentConstants.EXTENSION_VALUE_DESCRIPTION));
    }
    if (jsObject.has(ContentConstants.EXTENSION_VALUE_COMPATIBLES)) {
        String compatibles = jsObject.getString(ContentConstants.EXTENSION_VALUE_COMPATIBLES);
        String filter = null;
        if (jsObject.has(ContentConstants.EXTENSION_VALUE_Filter)) {
            filter = jsObject.getString(ContentConstants.EXTENSION_VALUE_Filter);
        }
        String revision = filterVersionRevisionsToString(compatibles, filter, versionRevisions);
        componentExtension.setListVersionCompatibles(revision);
    }
    if (jsObject.has(ContentConstants.EXTENSION_VALUE_FILENAME)) {
        componentExtension.setFilename(jsObject.getString(ContentConstants.EXTENSION_VALUE_FILENAME));
    }
}
Also used : JSONObject(org.talend.utils.json.JSONObject)

Aggregations

JSONObject (org.talend.utils.json.JSONObject)14 JSONException (org.talend.utils.json.JSONException)8 JSONArray (org.talend.utils.json.JSONArray)5 PersistenceException (org.talend.commons.exception.PersistenceException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Test (org.junit.Test)2 SystemException (org.talend.commons.exception.SystemException)2 Context (org.talend.core.context.Context)2 RepositoryContext (org.talend.core.context.RepositoryContext)2 ConnectionBean (org.talend.core.model.general.ConnectionBean)2 Project (org.talend.core.model.general.Project)2 PreferenceManipulator (org.talend.core.prefs.PreferenceManipulator)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 IProject (org.eclipse.core.resources.IProject)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1