Search in sources :

Example 1 with JSONArray

use of us.monoid.json.JSONArray in project tdi-studio-se by Talend.

the class JobVMArgumentsUtil method writeString.

public String writeString(List<String> items) {
    JSONObject root = new JSONObject();
    JSONArray args = new JSONArray();
    int size = items.size();
    for (int i = 0; i < size; i++) {
        String vm = items.get(i).trim();
        args.put(vm);
    }
    try {
        //$NON-NLS-1$
        root.put("JOB_RUN_VM_ARGUMENTS", args);
    } catch (JSONException e) {
        ExceptionHandler.process(e);
    }
    return root.toString();
}
Also used : JSONObject(us.monoid.json.JSONObject) JSONArray(us.monoid.json.JSONArray) JSONException(us.monoid.json.JSONException)

Example 2 with JSONArray

use of us.monoid.json.JSONArray in project tdi-studio-se by Talend.

the class RunProcessPreferenceInitializer method defaultVM.

private String defaultVM() {
    JSONObject root = new JSONObject();
    try {
        JSONArray args = new JSONArray();
        //$NON-NLS-1$
        args.put("-Xms256M");
        //$NON-NLS-1$
        args.put("-Xmx1024M");
        //$NON-NLS-1$
        root.put("JOB_RUN_VM_ARGUMENTS", args);
    } catch (JSONException e) {
        ExceptionHandler.process(e);
    }
    return root.toString();
}
Also used : JSONObject(us.monoid.json.JSONObject) JSONArray(us.monoid.json.JSONArray) JSONException(us.monoid.json.JSONException)

Example 3 with JSONArray

use of us.monoid.json.JSONArray in project tdi-studio-se by Talend.

the class ResetVMArgumentMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    ProcessType processType = getProcessType(item);
    if (processType == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    ParametersType parameters = processType.getParameters();
    if (parameters == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        EList listParamType = parameters.getElementParameter();
        for (int j = 0; j < listParamType.size(); j++) {
            ElementParameterType pType = (ElementParameterType) listParamType.get(j);
            if (pType.getName().equals("JOB_RUN_VM_ARGUMENTS")) {
                //$NON-NLS-1$
                String value = pType.getValue().trim();
                if (value != null && value.length() > 0 && !isJson(value)) {
                    try {
                        JSONObject root = new JSONObject();
                        JSONArray args = new JSONArray();
                        //$NON-NLS-1$
                        String[] vms = value.split(" ");
                        for (String vm : vms) {
                            args.put(vm);
                        }
                        //$NON-NLS-1$
                        root.put("JOB_RUN_VM_ARGUMENTS", args);
                        pType.setValue(root.toString());
                        factory.save(item, true);
                        break;
                    } catch (JSONException e) {
                        ExceptionHandler.process(e);
                        return ExecutionResult.FAILURE;
                    }
                }
            }
        }
        return ExecutionResult.SUCCESS_WITH_ALERT;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return ExecutionResult.FAILURE;
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) EList(org.eclipse.emf.common.util.EList) JSONObject(us.monoid.json.JSONObject) JSONArray(us.monoid.json.JSONArray) JSONException(us.monoid.json.JSONException) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType) JSONException(us.monoid.json.JSONException)

Example 4 with JSONArray

use of us.monoid.json.JSONArray in project tdi-studio-se by Talend.

the class ExchangeWebService method searchExtensionJSONArray.

/**
     * 
     * DOC hcyi Comment method "searchExtensionJSONArray".
     * 
     * @return
     */
public static JSONArray searchExtensionJSONArray(String typeExtension, String versionStudio, String category) {
    JSONObject tokenMessage = new JSONObject();
    JSONArray o = null;
    try {
        tokenMessage.put("typeExtension", typeExtension);
        tokenMessage.put("versionStudio", versionStudio);
        tokenMessage.put("search", category);
        JSONObject token = new us.monoid.json.JSONObject();
        token.put("searchExtension", tokenMessage);
        String u = exchangeWSServer + "availableExtension.php?data=" + token;
        JSONObject answer = readJsonFromUrl(u);
        if (answer != null) {
            JSONObject p = (JSONObject) answer.get("resultSearch");
            o = p.getJSONArray("extensions");
        }
    } catch (JSONException e) {
    //
    } catch (IOException e) {
        e.printStackTrace();
    }
    return o;
}
Also used : JSONObject(us.monoid.json.JSONObject) JSONArray(us.monoid.json.JSONArray) JSONException(us.monoid.json.JSONException) IOException(java.io.IOException)

Example 5 with JSONArray

use of us.monoid.json.JSONArray in project tdi-studio-se by Talend.

the class ExchangeWebService method searchCategoryExtensionJSONArray.

/**
     * 
     * DOC hcyi Comment method "searchCategoryExtensionJSONArray".
     * 
     * @param typeExtension
     * @return
     */
public static List<Category> searchCategoryExtensionJSONArray(String typeExtension) {
    List<Category> fCategorys = new ArrayList<Category>();
    JSONObject tokenMessage = new JSONObject();
    try {
        tokenMessage.put("typeExtension", typeExtension);
        JSONObject token = new us.monoid.json.JSONObject();
        token.put("extension", tokenMessage);
        String u = exchangeWSServer + "listCategoryExtension.php?data=" + token;
        JSONObject resultObj = readJsonFromUrl(u);
        if (resultObj != null) {
            JSONObject p = (JSONObject) resultObj.get("listCategory");
            JSONArray resultArry = p.getJSONArray("category");
            if (resultArry != null) {
                for (int i = 0; i < resultArry.length(); i++) {
                    JSONObject extensionObj = resultArry.getJSONObject(i);
                    if (extensionObj != null) {
                        Category fCategory = ExchangeFactory.eINSTANCE.createCategory();
                        fCategory.setCategoryId(extensionObj.getString("id_category"));
                        fCategory.setCategoryName(extensionObj.getString("name"));
                        fCategorys.add(fCategory);
                    }
                }
            }
        }
    } catch (JSONException e) {
    //
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return fCategorys;
}
Also used : Category(org.talend.designer.components.exchange.model.Category) JSONObject(us.monoid.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(us.monoid.json.JSONArray) JSONException(us.monoid.json.JSONException) IOException(java.io.IOException) JSONException(us.monoid.json.JSONException) IOException(java.io.IOException)

Aggregations

JSONArray (us.monoid.json.JSONArray)15 JSONObject (us.monoid.json.JSONObject)15 JSONException (us.monoid.json.JSONException)9 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)5 HashMap (java.util.HashMap)4 ComponentExtension (org.talend.designer.components.exchange.model.ComponentExtension)4 EList (org.eclipse.emf.common.util.EList)2 AvailableExtensionViewDetail (org.talend.designer.components.exchange.model.AvailableExtensionViewDetail)2 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)2 Date (java.util.Date)1 HashSet (java.util.HashSet)1 List (java.util.List)1 IEditorReference (org.eclipse.ui.IEditorReference)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 IComponent (org.talend.core.model.components.IComponent)1 IProcess2 (org.talend.core.model.process.IProcess2)1 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)1 FolderItem (org.talend.core.model.properties.FolderItem)1