use of com.genexus.internet.IGxJSONAble in project JavaClasses by genexuslabs.
the class EnterpriseConnect method setValue.
public void setValue(String parameterName, GXSimpleCollection value, Boolean inOut) {
JCoTable jTable = function.getTableParameterList().getTable(parameterName);
Boolean setValues = false;
try {
for (int i = 1; i <= value.getItemCount(); i++) {
IGxJSONAble item = (IGxJSONAble) value.item(i);
if (item != null) {
setValues = true;
JSONObject jObj = (JSONObject) item.GetJSONObject();
jTable.appendRow();
jTable.lastRow();
Iterator<?> keys = jObj.keys();
while (keys.hasNext()) {
String key = (String) keys.next();
int jcoType = jTable.getRecordMetaData().getType(key);
if (jObj.get(key) instanceof String) {
jTable.setValue(key, jObj.getString(key));
} else if (jcoType == JCoMetaData.TYPE_NUM || jcoType == JCoMetaData.TYPE_INT) {
jTable.setValue(key, jObj.getLong(key));
} else if (jcoType == JCoMetaData.TYPE_FLOAT || jcoType == JCoMetaData.TYPE_BCD) {
jTable.setValue(key, jObj.getDouble(key));
} else if (jcoType == JCoMetaData.TYPE_DATE) {
jTable.setValue(key, jObj.getString(key));
} else if (jcoType == JCoMetaData.TYPE_INT2 || jcoType == JCoMetaData.TYPE_INT1 || jcoType == JCoMetaData.TYPE_BYTE) {
jTable.setValue(key, jObj.getInt(key));
} else {
System.out.println(key + " Invalid Type " + Integer.toString(jcoType));
}
}
}
}
} catch (JSONException ex) {
throw new RuntimeException(ex.toString());
}
if (setValues) {
function.getTableParameterList().setActive(parameterName, true);
} else {
function.getTableParameterList().setActive(parameterName, inOut);
}
}
use of com.genexus.internet.IGxJSONAble in project JavaClasses by genexuslabs.
the class GXXMLSerializable method collectionFromJSONArray.
private void collectionFromJSONArray(JSONArray jsonArray, GXSimpleCollection gxColl) {
try {
gxColl.clear();
for (int i = 0; i < jsonArray.length(); i++) {
Object currObj = jsonArray.get(i);
if (currObj instanceof JSONObject || !gxColl.IsSimpleCollection()) {
Class<?> innerClass = gxColl.getElementsType();
IGxJSONAble innerObj;
if (GxSilentTrnSdt.class.isAssignableFrom(innerClass)) {
innerObj = (IGxJSONAble) innerClass.getConstructor(new Class[] { int.class }).newInstance(new Object[] { new Integer(-1) });
} else {
innerObj = (IGxJSONAble) innerClass.getConstructor(new Class[] { SpecificImplementation.Application.getModelContextClass() }).newInstance(new Object[] { context });
}
innerObj.FromJSONObject((IJsonFormattable) currObj);
gxColl.addBase(innerObj);
} else {
gxColl.addBase(currObj);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
Aggregations