use of org.zkoss.json.JSONArray in project adempiere by adempiere.
the class DrillCommand method service.
public boolean service(AuRequest request, boolean everError) {
if (!DrillEvent.ON_DRILL_ACROSS.equals(request.getCommand()) && !DrillEvent.ON_DRILL_DOWN.equals(request.getCommand()))
return false;
final Map<?, ?> map = request.getData();
JSONArray data = (JSONArray) map.get("data");
final Component comp = request.getComponent();
if (comp == null)
throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED, this);
if (data == null || data.size() < 2)
throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA, new Object[] { Objects.toString(data), this });
String columnName = (String) data.get(0);
String tableName = MQuery.getZoomTableName(columnName);
String code = (String) data.get(1);
//
MQuery query = new MQuery(tableName);
query.addRestriction(columnName, MQuery.EQUAL, code);
Events.postEvent(new DrillEvent(request.getCommand(), comp, query));
return true;
}
use of org.zkoss.json.JSONArray in project adempiere by adempiere.
the class ZoomCommand method service.
public boolean service(AuRequest request, boolean everError) {
if (!ZoomEvent.EVENT_NAME.equals(request.getCommand()))
return false;
Map<?, ?> map = request.getData();
JSONArray data = (JSONArray) map.get("data");
final Component comp = request.getComponent();
if (comp == null)
throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED, this);
if (data == null || data.size() < 2)
throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA, new Object[] { Objects.toString(data), this });
String columnName = (String) data.get(0);
String tableName = MQuery.getZoomTableName(columnName);
Object code = null;
if (columnName.endsWith("_ID")) {
try {
code = Integer.parseInt((String) data.get(1));
} catch (Exception e) {
code = data.get(1);
}
} else {
code = data.get(1);
}
//
MQuery query = new MQuery(tableName);
query.addRestriction(columnName, MQuery.EQUAL, code);
query.setRecordCount(1);
Events.postEvent(new ZoomEvent(comp, query));
return true;
}
Aggregations