use of com.servoy.j2db.dataprocessing.IFoundSet in project servoy-client by Servoy.
the class FormController method selectPrevRecord.
public void selectPrevRecord() {
if (form.getOnPreviousRecordCmdMethodID() == 0) {
int edittingStoppedFlag = application.getFoundSetManager().getEditRecordList().stopEditing(false);
if (ISaveConstants.STOPPED != edittingStoppedFlag && ISaveConstants.AUTO_SAVE_BLOCKED != edittingStoppedFlag) {
return;
}
IFoundSet fs = getFoundSet();
int nextIndex = fs.getSelectedIndex() - 1;
if (nextIndex >= 0) {
final Component comp = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
fs.setSelectedIndex(nextIndex);
application.invokeLater(new Runnable() {
public void run() {
if (getView() == IForm.LOCKED_RECORD_VIEW || getView() == IForm.RECORD_VIEW) {
if (comp != null)
comp.requestFocus();
} else {
requestFocus();
}
}
});
}
} else {
executeFormMethod(StaticContentSpecLoader.PROPERTY_ONPREVIOUSRECORDCMDMETHODID, null, Boolean.TRUE, true, true);
}
}
use of com.servoy.j2db.dataprocessing.IFoundSet in project servoy-client by Servoy.
the class FormController method selectNextRecord.
public void selectNextRecord() {
if (form.getOnNextRecordCmdMethodID() == 0) {
if ((application.getFoundSetManager().getEditRecordList().stopEditing(false) & (ISaveConstants.STOPPED + ISaveConstants.AUTO_SAVE_BLOCKED)) == 0) {
return;
}
IFoundSet fs = getFoundSet();
int nextIndex = fs.getSelectedIndex() + 1;
if (nextIndex >= 0 && nextIndex < fs.getSize()) {
final Component comp = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
fs.setSelectedIndex(nextIndex);
application.invokeLater(new Runnable() {
public void run() {
if (getView() == IForm.LOCKED_RECORD_VIEW || getView() == IForm.RECORD_VIEW) {
if (comp != null)
comp.requestFocus();
} else {
requestFocus();
}
}
});
}
} else {
executeFormMethod(StaticContentSpecLoader.PROPERTY_ONNEXTRECORDCMDMETHODID, null, Boolean.TRUE, true, true);
}
}
use of com.servoy.j2db.dataprocessing.IFoundSet in project servoy-client by Servoy.
the class JSDataSource method loadRecords.
/**
* get a new foundset containing records based on a QBSelect query.
*
* @sample
* var qb = datasources.db.example_data.orders.createSelect();
* qb.result.add(qb.columns.orderid);
* var fs = datasources.db.example_data.orders.loadRecords(qb);
*
* @param qbSelect a query builder object
* @return a new JSFoundset
* @throws ServoyException
*/
@JSFunction
public IFoundSet loadRecords(QBSelect qbSelect) throws ServoyException {
IFoundSet foundset = application.getFoundSetManager().getFoundSet(datasource);
foundset.loadByQuery(qbSelect);
return checkDataSourceEquality(foundset) ? foundset : null;
}
use of com.servoy.j2db.dataprocessing.IFoundSet in project servoy-client by Servoy.
the class JSDataSource method loadRecords.
/**
* get a new foundset containing records based on an SQL query string with parameters.
*
* @sample
* var query = "SELECT * FROM public.orders WHERE customerid = ? OR customerid = ? order by orderid asc";
* var args = ['ROMEY', 'BERGS'];
* var fs = datasources.db.example_data.orders.loadRecords(query, args);
*
* @param query an SQL query string with parameter placeholders
* @param args an array of arguments for the query string
* @return a new JSFoundset
* @throws ServoyException
*/
@JSFunction
public IFoundSet loadRecords(String query, Object[] args) throws ServoyException {
IFoundSet foundset = application.getFoundSetManager().getFoundSet(datasource);
((FoundSet) foundset).loadByQuery(query, args);
return checkDataSourceEquality(foundset) ? foundset : null;
}
use of com.servoy.j2db.dataprocessing.IFoundSet in project servoy-client by Servoy.
the class MapSerializer method convertToMap.
public static Map<String, Object> convertToMap(Object jsobj) {
Map<String, Object> retval = new HashMap<String, Object>();
if (jsobj == null || jsobj == Undefined.instance || jsobj instanceof IFoundSet || jsobj instanceof IRecord || !(jsobj instanceof NativeObject)) {
return retval;
}
IdScriptableObject no = (IdScriptableObject) jsobj;
Object[] noIDs = no.getIds();
String propertyKey;
Object propertyValue;
for (Object element : noIDs) {
// id can be Integer or String
if (element instanceof Integer) {
propertyKey = ((Integer) element).toString();
propertyValue = no.get(((Integer) element).intValue(), no);
} else if (element instanceof String) {
propertyKey = (String) element;
propertyValue = no.get((String) element, no);
} else {
// should not happen
continue;
}
if (// allow but ignore functions nested in objects
propertyValue instanceof Function) {
continue;
}
if (propertyValue instanceof NativeObject) {
propertyValue = convertToMap(propertyValue);
}
if (propertyValue instanceof Wrapper) {
propertyValue = ((Wrapper) propertyValue).unwrap();
}
retval.put(propertyKey, propertyValue);
}
return retval;
}
Aggregations