use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSDataSourceNode method removeMethod.
/**
* Removes the foundset method specified by name.
*
* @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]);
* }
*
* @param name the name of the method to be removed
*
* @return true if the removal was successful, false otherwise
*/
@JSFunction
public boolean removeMethod(String name) {
try {
FlattenedSolution fs = application.getFlattenedSolution();
TableNode tablenode = fs.getSolutionCopyTableNode(dataSource);
ScriptMethod sc = tablenode.getFoundsetMethod(name);
if (sc != null) {
tablenode.removeChild(sc);
return true;
}
// it is a design time method, therefore we "hide" it
sc = fs.getFoundsetMethod(name, dataSource);
if (sc != null) {
fs.addToRemovedPersists(sc);
if (application.getFormManager() instanceof FormManager)
((FormManager) application.getFormManager()).fillScriptMenu();
return true;
}
// not found
return false;
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSValueList method getFallbackValueList.
/**
* Gets or sets the fallback valuelist.
*
* @sample
* var myValueList = solutionModel.getValueList('myValueListHere')
* //get fallback value list
* var fallbackValueList = myValueList.fallbackValueList
*/
@JSGetter
public JSValueList getFallbackValueList() {
FlattenedSolution fs = application.getFlattenedSolution();
int fallbackVLID = valuelist.getFallbackValueListID();
ValueList fallbackVL = fs.getValueList(fallbackVLID);
if (fallbackVL != null) {
return new JSValueList(fallbackVL, application, false);
} else {
return null;
}
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class LookupValueList method deregister.
public void deregister() {
clear();
if (tableListener != null && table != null) {
FlattenedSolution fs = application.getFlattenedSolution();
((FoundSetManager) application.getFoundSetManager()).removeTableListener(table, tableListener);
Relation[] relations = application.getFlattenedSolution().getRelationSequence(valueList.getRelationName());
for (int i = 0; relations != null && i < relations.length - 1; i++) {
((FoundSetManager) application.getFoundSetManager()).removeTableListener(fs.getTable(relations[i].getForeignDataSource()), tableListener);
}
tableListener = null;
}
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method getFormsInternal.
private JSForm[] getFormsInternal(String datasource) {
FlattenedSolution fs = application.getFlattenedSolution();
Iterator<Form> forms = fs.getForms(datasource, true);
ArrayList<JSForm> list = new ArrayList<JSForm>();
while (forms.hasNext()) {
list.add(instantiateForm(forms.next(), false));
}
return list.toArray(new JSForm[list.size()]);
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class JSSolutionModel method getValueLists.
/**
* Gets an array of all valuelists for the currently active solution.
*
* NOTE: Changes to valuelist should be done before showing any form that has component using the valuelist.
*
* @sample
* var valueLists = solutionModel.getValueLists();
* if (valueLists != null && valueLists.length != 0)
* for (var i in valueLists)
* application.output(valueLists[i].name);
*
* @return an array of JSValueList objects
*/
@JSFunction
public JSValueList[] getValueLists() {
FlattenedSolution fs = application.getFlattenedSolution();
ArrayList<JSValueList> valuelists = new ArrayList<JSValueList>();
Iterator<ValueList> iterator = fs.getValueLists(true);
while (iterator.hasNext()) {
valuelists.add(new JSValueList(iterator.next(), application, false));
}
return valuelists.toArray(new JSValueList[valuelists.size()]);
}
Aggregations