Script Data Sources
Creating data
There are situations that require certain data that does not exist in any data source or electronic form. Most of the time the solution to this problem involves creating a text file with the data or even a table in a database and adjust the model to read this new information. However, sometimes this solution can prove somewhat wrong or hard to maintain. Dificulties such as the location of the file or the availability of a database with update privileges could render the solution hard to implement.
O3 Designer includes a special type of data source that proves to be an excelent solution to this kind of situations.
These new data sources are defined in the Design Tree under the Scripts branch. Script data sources require no further configuration since they only rely on the code and there is no need to indicate any driver or connection parameters.
What follows is a list of examples of different scripts that are used to create data for very common situations.
Simple catalog data source
ArrayList list = new ArrayList(); list.add(new Object[]{0, "Activos"}); list.add(new Object[]{1, "Pasivos"}); iterator = list.iterator();
This code generates a data source with the following values:
0 |
Activos |
1 |
Pasivos |
Make sure to uncheck the "Verify before construction" checkbox to avoid error messages.
Date values
ArrayList list = new ArrayList(); list.add(new Object[]{new Date(2008-1900, 0, 1)}); iterator = list.iterator();
This code generates a data source with the following values:
01/01/2008 |
The base year is 1900, the base month is 0 (0 corresponds to january, 1 to february, and so on) and the day is specified as is.
The syntax of the Date function is year, month, day.
The use of scripts further extends the capabilities of O3 Designer allowing developers to satisfy more complex requirements.