Package org.openbravo.service.datasource
Interface DataSourceService
-
- All Known Implementing Classes:
AccountTreeDatasourceService
,ADAlertDatasourceService
,ADTreeDatasourceService
,BaseDataSourceService
,ComboTableDatasourceService
,CustomQuerySelectorDatasource
,DataSourceServiceProviderTest.ExtendedDataSource
,DefaultDataSourceService
,HQLDataSourceService
,LinkToParentTreeDatasourceService
,LogDatasource
,ManageVariantsDS
,ModelDataSourceService
,NoteDataSource
,ProductCharacteristicsDS
,QueryListDataSource
,ReadOnlyDataSourceService
,SelectorFieldPropertyDataSource
,StockReservationPickAndEditDataSource
,TimezoneDatasource
,TreeDatasourceService
public interface DataSourceService
Represents a data source as it is present on the client. It provides both the javascript to create the datasource on the client as well as the runtime handling code of the client datasource calls to the server. Is the base class which can both query and return data as json as well as handle update, delete and insert requests with json data as an input. This is the base class for implementations of this service. Several methods have specific parameters or the content of the request (normally a json string). This class is cached so one instance is shared by multiple threads. Local caching of information should take this into account! NOTE: another (not-yet-implemented) thought is to cache datasources in session-scope. This allows for additional caching of information.- Author:
- mtaal
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description String
add(Map<String,String> parameters, String content)
Execute an insert action.void
checkEditDatasourceAccess(Map<String,String> parameter)
This method allows to implement a security access to a DataSource when it is used add(), update() or remove() methods.void
checkFetchDatasourceAccess(Map<String,String> parameter)
This method allows to implement a security access to a DataSource when it is used fetch() method.String
fetch(Map<String,String> parameters)
Execute a query request and return the result as a json string.DataSource
getDataSource()
This method allows to implement a security access to a DataSource when it is used add(), update() or remove() methods.List<DataSourceProperty>
getDataSourceProperties(Map<String,Object> parameters)
Create the properties used in the template.String
getDataUrl()
Entity
getEntity()
String
getName()
The name of this service, in the default implementation this is the entityname of theEntity
to get/insert/update/delete.Template
getTemplate()
String
getWhereClause()
String
remove(Map<String,String> parameters)
Execute a delete action.void
setDataSource(DataSource dataSource)
Passes in the data source read from the database.void
setDataUrl(String dataUrl)
void
setEntity(Entity entity)
void
setName(String name)
void
setWhereClause(String whereClause)
String
update(Map<String,String> parameters, String content)
Execute an update action.
-
-
-
Method Detail
-
getTemplate
Template getTemplate()
- Returns:
- the Template used to render the data source
-
getDataSourceProperties
List<DataSourceProperty> getDataSourceProperties(Map<String,Object> parameters)
Create the properties used in the template.- Parameters:
parameters
- parameters used for this request- Returns:
- the list of DataSourceProperty instances to use in the template
-
fetch
String fetch(Map<String,String> parameters)
Execute a query request and return the result as a json string.- Parameters:
parameters
- the parameters often coming from the HTTP request- Returns:
- the json result string
-
remove
String remove(Map<String,String> parameters)
Execute a delete action. The id of the deleted record is present in the parameters.- Parameters:
parameters
- the parameters often coming from the HTTP request- Returns:
- the result message as a json string
-
add
String add(Map<String,String> parameters, String content)
Execute an insert action.- Parameters:
parameters
- the parameters often coming from the HTTP requestcontent
- , the request content, is assumed to be a json string- Returns:
- the result message as a json string
-
update
String update(Map<String,String> parameters, String content)
Execute an update action.- Parameters:
parameters
- the parameters often coming from the HTTP requestcontent
- , the request content, is assumed to be a json string- Returns:
- the result message as a json string
-
getName
String getName()
The name of this service, in the default implementation this is the entityname of theEntity
to get/insert/update/delete.- Returns:
- the name of the service
-
setName
void setName(String name)
-
getDataUrl
String getDataUrl()
-
setDataUrl
void setDataUrl(String dataUrl)
-
getEntity
Entity getEntity()
-
setEntity
void setEntity(Entity entity)
-
checkFetchDatasourceAccess
void checkFetchDatasourceAccess(Map<String,String> parameter) throws OBSecurityException
This method allows to implement a security access to a DataSource when it is used fetch() method. It can be overridden in specific DataSources to apply a particular security mechanism.- Throws:
OBSecurityException
- is thrown if current role does not have access.
-
checkEditDatasourceAccess
void checkEditDatasourceAccess(Map<String,String> parameter) throws OBSecurityException
This method allows to implement a security access to a DataSource when it is used add(), update() or remove() methods. It can be overridden in specific DataSources to apply a particular security mechanism.- Throws:
OBSecurityException
- is thrown if current role does not have access.
-
getWhereClause
String getWhereClause()
-
setWhereClause
void setWhereClause(String whereClause)
-
getDataSource
DataSource getDataSource()
This method allows to implement a security access to a DataSource when it is used add(), update() or remove() methods. It can be overridden in specific DataSources to apply a particular security mechanism.- Returns:
- the data source read from the database. Note: can be null for data sources which are created in-memory on request.
-
setDataSource
void setDataSource(DataSource dataSource)
Passes in the data source read from the database. Is the place to initialize the data in the service class- Parameters:
dataSource
- the data source read from the database.
-
-