Search in sources :

Example 36 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)36 JSONException (org.talend.utils.json.JSONException)21 JSONArray (org.talend.utils.json.JSONArray)19 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)4 NoSQLConnection (org.talend.repository.model.nosql.NoSQLConnection)4 Iterator (java.util.Iterator)3 List (java.util.List)3 Map (java.util.Map)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 EHadoopParamName (org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)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