use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.
the class SQLSheet method processCopyValues.
void processCopyValues(IRecordInternal s) {
SQLDescription desc = getSQLDescription(SELECT);
if (desc == null) {
return;
}
List<?> list = desc.getDataProviderIDsDilivery();
for (int i = 0; i < list.size(); i++) {
try {
String id = (String) list.get(i);
Column c = table.getColumn(id);
if (c != null) {
ColumnInfo ci = c.getColumnInfo();
if (ci != null && ci.getAutoEnterType() == ColumnInfo.LOOKUP_VALUE_AUTO_ENTER) {
String lookupDataProviderID = ci.getLookupValue();
Object obj = s.getValue(lookupDataProviderID);
if (ScopesUtils.isVariableScope(lookupDataProviderID) && !s.has(lookupDataProviderID)) {
ScriptMethod globalScriptMethod = application.getFlattenedSolution().getScriptMethod(null, lookupDataProviderID);
if (globalScriptMethod != null) {
try {
IServer server = application.getSolution().getServer(table.getServerName());
obj = application.getScriptEngine().getScopesScope().executeGlobalFunction(globalScriptMethod.getScopeName(), globalScriptMethod.getName(), new Object[] { new JSColumn(c, server, table) }, false, false);
} catch (Exception e) {
Debug.error(e);
}
}
}
// Protect to writing null to null-protected columns. An exception gets written in the log.
if (!((obj == null) && !c.getAllowNull()))
s.setValue(id, obj, false);
}
}
} catch (Exception ex) {
Debug.error(ex);
}
}
}
use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.
the class FoundSetManager method getTriggerFunctions.
private List<TriggerFunction> getTriggerFunctions(ITable table, TypedProperty<Integer> property, Scriptable foundsetScope) {
FlattenedSolution solutionRoot = getApplication().getFlattenedSolution();
IExecutingEnviroment scriptEngine = getApplication().getScriptEngine();
return stream(solutionRoot.getTableNodes(table)).map(tableNode -> {
Object function = null;
Scriptable scope = null;
ScriptMethod scriptMethod = solutionRoot.getScriptMethod(((Integer) tableNode.getProperty(property.getPropertyName())).intValue());
if (scriptMethod != null) {
if (scriptMethod.getParent() instanceof Solution) {
// global method
GlobalScope gs = scriptEngine.getScopesScope().getGlobalScope(scriptMethod.getScopeName());
if (gs != null) {
scope = gs;
function = gs.get(scriptMethod.getName());
}
} else if (foundsetScope != null) {
// foundset method
scope = foundsetScope;
function = scope.getPrototype().get(scriptMethod.getName(), scope);
}
}
if (function instanceof Function) {
return new TriggerFunction((Function) function, scope, tableNode);
}
return null;
}).filter(Objects::nonNull).collect(toList());
}
use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.
the class JSForm method js_setOnShowAllRecordsCmdMethod.
/**
* @deprecated As of release 4.1, replaced by setOnShowAllRecordsCmd(JSMethod).
*/
@Deprecated
public void js_setOnShowAllRecordsCmdMethod(Object functionOrInteger) {
checkModification();
if (functionOrInteger instanceof Function) {
Function function = (Function) functionOrInteger;
ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
if (scriptMethod != null) {
getForm().setOnShowAllRecordsCmdMethodID(scriptMethod.getID());
} else {
getForm().setOnShowAllRecordsCmdMethodID(0);
}
} else if (functionOrInteger instanceof Number) {
getForm().setOnShowAllRecordsCmdMethodID(((Number) functionOrInteger).intValue());
}
}
use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.
the class JSForm method js_setOnOmitRecordCmdMethod.
/**
* @deprecated As of release 4.1, replaced by setOnOmitRecordCmd(JSMethod).
*/
@Deprecated
public void js_setOnOmitRecordCmdMethod(Object functionOrInteger) {
checkModification();
if (functionOrInteger instanceof Function) {
Function function = (Function) functionOrInteger;
ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
if (scriptMethod != null) {
getForm().setOnOmitRecordCmdMethodID(scriptMethod.getID());
} else {
getForm().setOnOmitRecordCmdMethodID(0);
}
} else if (functionOrInteger instanceof Number) {
getForm().setOnOmitRecordCmdMethodID(((Number) functionOrInteger).intValue());
}
}
use of com.servoy.j2db.persistence.ScriptMethod in project servoy-client by Servoy.
the class JSForm method js_setOnFindCmdMethod.
/**
* @deprecated As of release 4.1, replaced by setOnFindCmd(JSMethod).
*/
@Deprecated
public void js_setOnFindCmdMethod(Object functionOrInteger) {
checkModification();
if (functionOrInteger instanceof Function) {
Function function = (Function) functionOrInteger;
ScriptMethod scriptMethod = getScriptMethod(function, application.getFlattenedSolution());
if (scriptMethod != null) {
getForm().setOnFindCmdMethodID(scriptMethod.getID());
} else {
getForm().setOnFindCmdMethodID(0);
}
} else if (functionOrInteger instanceof Number) {
getForm().setOnFindCmdMethodID(((Number) functionOrInteger).intValue());
}
}
Aggregations