use of org.talend.utils.json.JSONObject in project tbd-studio-se by Talend.
the class HCatalogForm method initHadoopProperties.
// private void addHadoopPropertiesFields() {
// // table view
// Composite compositeTable = Form.startNewDimensionnedGridLayout(this, 1, this.getBorderWidth(), 150);
// GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
// gridData.horizontalSpan = 4;
// compositeTable.setLayoutData(gridData);
// CommandStackForComposite commandStack = new CommandStackForComposite(compositeTable);
// properties = new ArrayList<HashMap<String, Object>>();
// initHadoopProperties();
// HadoopPropertiesFieldModel model = new HadoopPropertiesFieldModel(properties, "Hadoop Properties");
// propertiesTableView = new HadoopPropertiesTableView(model, compositeTable);
// propertiesTableView.getExtendedTableViewer().setCommandStack(commandStack);
// final Composite fieldTableEditorComposite = propertiesTableView.getMainComposite();
// gridData = new GridData(GridData.FILL_HORIZONTAL);
// gridData.heightHint = 180;
// fieldTableEditorComposite.setLayoutData(gridData);
// fieldTableEditorComposite.setBackground(null);
// }
private void initHadoopProperties() {
String hadoopProperties = getConnection().getHadoopProperties();
try {
if (StringUtils.isNotEmpty(hadoopProperties)) {
JSONArray jsonArr = new JSONArray(hadoopProperties);
for (int i = 0; i < jsonArr.length(); i++) {
HashMap<String, Object> map = new HashMap();
JSONObject object = jsonArr.getJSONObject(i);
Iterator it = object.keys();
while (it.hasNext()) {
String key = (String) it.next();
map.put(key, object.get(key));
}
properties.add(map);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
use of org.talend.utils.json.JSONObject in project tbd-studio-se by Talend.
the class HDFSForm method initHadoopProperties.
private void initHadoopProperties() {
String hadoopProperties = getConnection().getHadoopProperties();
try {
if (StringUtils.isNotEmpty(hadoopProperties)) {
JSONArray jsonArr = new JSONArray(hadoopProperties);
for (int i = 0; i < jsonArr.length(); i++) {
HashMap<String, Object> map = new HashMap();
JSONObject object = jsonArr.getJSONObject(i);
Iterator it = object.keys();
while (it.hasNext()) {
String key = (String) it.next();
map.put(key, object.get(key));
}
properties.add(map);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
use of org.talend.utils.json.JSONObject in project tbd-studio-se by Talend.
the class MongoDBConnectionUtil method getReplicaSetList.
public static List<HashMap<String, Object>> getReplicaSetList(String replicaSetJsonStr, boolean includeQuotes) throws JSONException {
List<HashMap<String, Object>> replicaSet = new ArrayList<HashMap<String, Object>>();
if (StringUtils.isNotEmpty(replicaSetJsonStr)) {
JSONArray jsonArr = new JSONArray(replicaSetJsonStr);
for (int i = 0; i < jsonArr.length(); i++) {
HashMap<String, Object> map = new HashMap<String, Object>();
JSONObject object = jsonArr.getJSONObject(i);
Iterator<String> it = object.keys();
while (it.hasNext()) {
String key = StringUtils.trimToNull(it.next());
String value = StringUtils.trimToNull(String.valueOf(object.get(key)));
if (includeQuotes) {
value = TalendQuoteUtils.addQuotesIfNotExist(value);
} else {
value = TalendQuoteUtils.removeQuotesIfExist(value);
}
if (IMongoConstants.REPLICA_PORT_KEY.equals(key)) {
value = TalendQuoteUtils.removeQuotesIfExist(value);
}
map.put(key, value);
}
replicaSet.add(map);
}
}
return replicaSet;
}
use of org.talend.utils.json.JSONObject in project tbd-studio-se by Talend.
the class MongoDBReplicaFieldModel method getBeanListString.
public String getBeanListString() throws JSONException {
JSONArray jsonArr = new JSONArray();
for (HashMap<String, Object> map : getBeansList()) {
JSONObject object = new JSONObject();
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
object.put(key, map.get(key));
}
jsonArr.put(object);
}
return jsonArr.toString();
}
use of org.talend.utils.json.JSONObject in project tbd-studio-se by Talend.
the class DefaultConfigurationManagerTest method testGetValue_Null.
@Test
public void testGetValue_Null() {
assertNull(DefaultConfigurationManager.getValue(null));
assertNull(DefaultConfigurationManager.getValue(null, new String[0]));
JSONObject json = new JSONObject();
assertNull(DefaultConfigurationManager.getValue(json, new String[0]));
}
Aggregations