Sources
In the file douidefinition.xml, the source is defined through the <source>
element, under the <sources> element, and its class is defined through the attributes type
(in the case of standard sources) and className
(in the case of non-standard sources) of the <source>
element. Therefore, the <sources>
element lists the available data sources for the service, identifying them by the id attribute.
At the service level (under the <service>
element), the source must define all its fields that may be used in the interfaces. Each interface, at its definition level (that is, under the <interface>
element), defines which fields it will use, avoiding querying more fields than necessary. If not defined, all fields defined at the source level will be used.
Each source has a unique identifier in the interface, defined through the id attribute.
An alternative for retrieving data from a table or file is the use of data providers, whose implementation must be referenced in the <dataProviderclassName>
element. To define the class of a data provider, the <dataProviderClassName>
element is used under the <source>
element. The type attribute of a source definition defines not only a source class but also a data provider class. Therefore, if both the type attribute and the <dataProviderClassName>
element are defined, the latter takes precedence over the former.
Generally, each data source has at least the following elements: <table>
, <fields>
, and <field>
.
The <table>
element is primarily used when the source is of table type, that is, attribute type="table"
.
The <fields>
element contains the list of fields that are part of the table and will be used by the service, each specified in the <field>
tag.
Most commonly used attributes by the <field> tag Check lumisdata/def/lumis/doui/douidefinition.xsd |
|
---|---|
id |
This is the name of the field of the table or an SQL query. |
name |
Field name. |
dataType |
Used to define the data type. Possible data types are:
In a field whose
Examples: “#, ##0.00”: Money The value 1234.567890 applied to the pattern below for English US #,##0.##”: “1,234.57” #,##0.#########”: “1,234.56789” #,##0.000000000”: “1,234.567890000” “000,000”:”001,235” “0”:”12345” |
display |
Whether the field will be displayed in the interface. |
Required |
Determines if the field will be “not null”. |
isSearchable |
Determines if the field will be part of the search index. |
isPrimarykey |
A field when defined with the attribute |
isPrimaryName |
A field when defined with the attribute
Additionally, the value of this field will be used in the tag |
isIntroduction |
A field when defined with the attribute Additionally, the value of this field will be used in the meta-tag >description to be displayed in the header html of the details page. |
isKeywords |
A field can be defined as keyword so that its value is used in the meta-tag keywords in the header html of a details page. |
In the example below, the data repository has tabular characteristics defined by the attribute type="table" and the data is being provided both by the table "lum_sample" and by the data provider that is retrieving data from another source through the class lumis.sample.testDataProvider
.
In the interface, the sources that will be available to it are specified. The id of the source must correspond to the id of a source defined in service. The first source listed is considered the default source of the interface. In the interface, the definition of a source can be changed. The specifications in the definition of the source in the interface take precedence over those defined in the source in service. When an item is not specified in the interface definition, the specification defined in service will be used.
When two sources of type table have a relationship and both are used in an interface, in the sql to be generated to obtain their data, a join is performed between the tables of the sources as defined in their relationship.
Access to External Databases
To configure other connections in the portal, just create a folder named connection in the lumisdata/config folder and create xml files similar to lumishibernate.cfg.xml. The name of the file will serve as an identifier for the application to use.
Suppose a service that displays data from a “Region” table from an external database. To do this, the service was implemented to have a list interface that displays the registered regions.
A file must be created with the name of the database (e.g., sqlnorthwind.xml) in /lumisdata/config/connection (create this directory). This file contains the configuration of hibernate. This configuration defines how the connection with the database is made.
To create this file, copy the content of the lumishibernate.cfg.xml file and save it under the name of the database with the .XML extension.
Ensure that the copied file has the following code:
The specified class will allow the hibernate cache to be correctly synchronized in a multi-server environment.
In the source of the douidefinition.xml, there must be the connectionId element containing such connection file.
If the connectionId element is not used, by default the service will use the connection configurations defined in lumisdata/config/lumishibernate.cfg.xml.
Here is an example of the doudefinition.xml file for the mentioned service that displays a list of regions, with these regions belonging to a table from an external database.
It is recommended to create an xml file for each datasource that will be available to the application using the same name as the datasource as the file name.
```