Child pages
  • JSDataSourceNode
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »


Method Summary
JSCalculation getCalculation(name)
Get an existing calculation for the datasource node.
JSCalculation[] getCalculations()
Gets all the calculations for the datasource node.
String getDataSource()
Get the data source for this node.
JSMethod getMethod(name)
Get an existing foundset method for the datasource node.
JSMethod[] getMethods()
Gets all the foundset methods for the datasource node.
JSCalculation newCalculation(code)
Creates a new calculation for the given code, the type will be the column where it could be build on (if name is a column name),
else it will default to JSVariable.
JSCalculation newCalculation(code, type)
Creates a new calculation for the given code and the type, if it builds on a column (name is a column name) then type will be ignored.
JSMethod newMethod(code)
Creates a new foundset method with the specified code.
Boolean removeCalculation(name)
Removes the calculation specified by name.
Boolean removeMethod(name)
Removes the foundset method specified by name.

Method Details
getCalculation
JSCalculation getCalculation (name)
Get an existing calculation for the datasource node.
Parameters
{String} name - The name of the calculation
Returns
Sample
var calc = solutionModel.getDataSourceNode("db:/example_data/customers").newCalculation("function myCalculation() { return 123; }", JSVariable.INTEGER);
var calc2 = solutionModel.getDataSourceNode("db:/example_data/customers").newCalculation("function myCalculation2() { return '20'; }");
var calc3 = solutionModel.getDataSourceNode("db:/example_data/employees").newCalculation("function myCalculation3() { return 'Hello World!'; }",	JSVariable.TEXT);

var c = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculation("myCalculation");
application.output("Name: " + c.getName() + ", Stored: " + c.isStored());

var allCalcs = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculations();
for (var i = 0; i < allCalcs.length; i++) {
	application.output(allCalcs[i]);
}
getCalculations
JSCalculation[] getCalculations ()
Gets all the calculations for the datasource node.
Returns
Sample
var calc = solutionModel.getDataSourceNode("db:/example_data/customers").newCalculation("function myCalculation() { return 123; }", JSVariable.INTEGER);
var calc2 = solutionModel.getDataSourceNode("db:/example_data/customers").newCalculation("function myCalculation2() { return '20'; }");
var calc3 = solutionModel.getDataSourceNode("db:/example_data/employees").newCalculation("function myCalculation3() { return 'Hello World!'; }",	JSVariable.TEXT);

var c = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculation("myCalculation");
application.output("Name: " + c.getName() + ", Stored: " + c.isStored());

var allCalcs = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculations();
for (var i = 0; i < allCalcs.length; i++) {
	application.output(allCalcs[i]);
}
getDataSource
String getDataSource ()
Get the data source for this node.
Returns
String - the dataSource
Sample
var nodeDataSource = solutionModel.getDataSourceNode("db:/example_data/customers").getDataSource();
getMethod
JSMethod getMethod (name)
Get an existing foundset method for the datasource node.
Parameters
{String} name - The name of the method
Returns
Sample
var method = solutionModel.getDataSourceNode("db:/example_data/orders").newMethod("function doubleSize() { return 2*getSize(); }");

application.output('Doubled orders for this customer: '+customers_to_orders.doubleSize())
getMethods
JSMethod[] getMethods ()
Gets all the foundset methods for the datasource node.
Returns
Sample
var method = solutionModel.getDataSourceNode("db:/example_data/orders").newMethod("function doubleSize() { return 2*getSize(); }");

application.output('Doubled orders for this customer: '+customers_to_orders.doubleSize())
newCalculation
JSCalculation newCalculation (code)
Creates a new calculation for the given code, the type will be the column where it could be build on (if name is a column name),
else it will default to JSVariable.TEXT;
Parameters
{String} code - The code of the calculation, this must be a full function declaration.
Returns
Sample
var calc = solutionModel.getDataSourceNode("db:/example_data/customers").newCalculation("function myCalculation() { return 123; }", JSVariable.INTEGER);
var calc2 = solutionModel.getDataSourceNode("db:/example_data/customers").newCalculation("function myCalculation2() { return '20'; }");
var calc3 = solutionModel.getDataSourceNode("db:/example_data/employees").newCalculation("function myCalculation3() { return 'Hello World!'; }",	JSVariable.TEXT);

var c = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculation("myCalculation");
application.output("Name: " + c.getName() + ", Stored: " + c.isStored());

var allCalcs = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculations();
for (var i = 0; i < allCalcs.length; i++) {
	application.output(allCalcs[i]);
}
newCalculation
JSCalculation newCalculation (code, type)
Creates a new calculation for the given code and the type, if it builds on a column (name is a column name) then type will be ignored.
Parameters
{String} code - The code of the calculation, this must be a full function declaration.
{Number} type - The type of the calculation, one of the JSVariable types.
Returns
Sample
var calc = solutionModel.getDataSourceNode("db:/example_data/customers").newCalculation("function myCalculation() { return 123; }", JSVariable.INTEGER);
var calc2 = solutionModel.getDataSourceNode("db:/example_data/customers").newCalculation("function myCalculation2() { return '20'; }");
var calc3 = solutionModel.getDataSourceNode("db:/example_data/employees").newCalculation("function myCalculation3() { return 'Hello World!'; }",	JSVariable.TEXT);

var c = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculation("myCalculation");
application.output("Name: " + c.getName() + ", Stored: " + c.isStored());

var allCalcs = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculations();
for (var i = 0; i < allCalcs.length; i++) {
	application.output(allCalcs[i]);
}
newMethod
JSMethod newMethod (code)
Creates a new foundset method with the specified code.
Parameters
{String} code - the specified code for the foundset method
Returns
JSMethod - a JSMethod object
Sample
var method = solutionModel.getDataSourceNode("db:/example_data/orders").newMethod("function doubleSize() { return 2*getSize(); }");

application.output('Doubled orders for this customer: '+customers_to_orders.doubleSize())
removeCalculation
Boolean removeCalculation (name)
Removes the calculation specified by name.
Parameters
{String} name - the name of the calculation to be removed
Returns
Boolean - true if the removal was successful, false otherwise
Sample
var calc1 = solutionModel.getDataSourceNode("db:/example_data/customers").newCalculation("function myCalculation1() { return 123; }", JSVariable.INTEGER);
var calc2 = solutionModel.getDataSourceNode("db:/example_data/customers").newCalculation("function myCalculation2() { return '20'; }");

var c = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculation("myCalculation1");
application.output("Name: " + c.getName() + ", Stored: " + c.isStored());

solutionModel.getDataSourceNode("db:/example_data/customers").removeCalculation("myCalculation1");
c = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculation("myCalculation1");
if (c != null) {
	application.output("myCalculation could not be removed.");
}

var allCalcs = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculations();
for (var i = 0; i < allCalcs.length; i++) {
	application.output(allCalcs[i]);
}
removeMethod
Boolean removeMethod (name)
Removes the foundset method specified by name.
Parameters
{String} name - the name of the method to be removed
Returns
Boolean - true if the removal was successful, false otherwise
Sample
var method1 = solutionModel.getDataSourceNode("db:/example_data/customers").newMethod("function myFoundsetMethod1() { return 123; }");
var method2 = solutionModel.getDataSourceNode("db:/example_data/customers").newCalculation("function myFoundsetMethod2() { return '20'; }");

var m = solutionModel.getDataSourceNode("db:/example_data/customers").getMethod("myFoundsetMethod1");
application.output("Name: " + m.getName());

solutionModel.getDataSourceNode("db:/example_data/customers").removeMethod("myFoundsetMethod1");
m = solutionModel.getDataSourceNode("db:/example_data/customers").getCalculation("myFoundsetMethod1");
if (m != null) { application.output("myFoundsetMethod1 could not be removed."); }

var allMethods = solutionModel.getDataSourceNode("db:/example_data/customers").getMethod();
for (var i = 0; i < allMethods; i++)
{
	application.output(allMethods[i]);
}

  • No labels