Package org.openbravo.service.datasource
Class ReadOnlyDataSourceService
- java.lang.Object
-
- org.openbravo.service.datasource.BaseDataSourceService
-
- org.openbravo.service.datasource.DefaultDataSourceService
-
- org.openbravo.service.datasource.ReadOnlyDataSourceService
-
- All Implemented Interfaces:
DataSourceService
- Direct Known Subclasses:
CustomQuerySelectorDatasource
,HQLDataSourceService
,LogDatasource
,ManageVariantsDS
,QueryListDataSource
,StockReservationPickAndEditDataSource
,TimezoneDatasource
public abstract class ReadOnlyDataSourceService extends DefaultDataSourceService
The SimpleDataSourceService provides a simple way of returning data in the correct format for a client side component using a datasource.- Author:
- mtaal
-
-
Constructor Summary
Constructors Constructor Description ReadOnlyDataSourceService()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
add(Map<String,String> parameters, String content)
Execute an insert action.String
fetch(Map<String,String> parameters)
Execute a query request and return the result as a json string.void
fetch(Map<String,String> parameters, DefaultJsonDataService.QueryResultWriter writer)
protected abstract int
getCount(Map<String,String> parameters)
Returns the count of objects based on the passed parameters.protected abstract List<Map<String,Object>>
getData(Map<String,String> parameters, int startRow, int endRow)
Read/create the set of data as a list of Maps with key-value pairs.String
remove(Map<String,String> parameters)
Execute a delete action.protected void
sort(String sortBy, List<Map<String,Object>> data)
Sorts the data list by the value of the passed in sortBy keyString
update(Map<String,String> parameters, String content)
Execute an update action.-
Methods inherited from class org.openbravo.service.datasource.DefaultDataSourceService
add, addFetchParameters, fetch, getDataSourceProperties, getInitialProperties, remove
-
Methods inherited from class org.openbravo.service.datasource.BaseDataSourceService
checkEditDatasourceAccess, checkFetchDatasourceAccess, getDataSource, getDataUrl, getEntity, getName, getTemplate, getWhereAndFilterClause, getWhereClause, handleExceptionUnsecuredDSAccess, setDataSource, setDataUrl, setEntity, setName, setWhereClause
-
-
-
-
Method Detail
-
fetch
public String fetch(Map<String,String> parameters)
Description copied from interface:DataSourceService
Execute a query request and return the result as a json string.- Specified by:
fetch
in interfaceDataSourceService
- Overrides:
fetch
in classDefaultDataSourceService
- Parameters:
parameters
- the parameters often coming from the HTTP request- Returns:
- the json result string
-
fetch
public void fetch(Map<String,String> parameters, DefaultJsonDataService.QueryResultWriter writer)
- Overrides:
fetch
in classDefaultDataSourceService
-
getCount
protected abstract int getCount(Map<String,String> parameters)
Returns the count of objects based on the passed parameters.- Parameters:
parameters
- the parameters passed in from the request- Returns:
- the total number of objects
-
getData
protected abstract List<Map<String,Object>> getData(Map<String,String> parameters, int startRow, int endRow)
Read/create the set of data as a list of Maps with key-value pairs.- Parameters:
parameters
- the parameters passed in from the requeststartRow
- the first row to read (maybe -1 to indicate no startrow)endRow
- the last row to read (maybe -1 to indicate no endrow- Returns:
- the number of objects read, note that this maybe more than endRow - startRow + 1. The startRow parameter should be strictly followed though.
-
remove
public String remove(Map<String,String> parameters)
Description copied from interface:DataSourceService
Execute a delete action. The id of the deleted record is present in the parameters.- Specified by:
remove
in interfaceDataSourceService
- Overrides:
remove
in classDefaultDataSourceService
- Parameters:
parameters
- the parameters often coming from the HTTP request- Returns:
- the result message as a json string
-
add
public String add(Map<String,String> parameters, String content)
Description copied from interface:DataSourceService
Execute an insert action.- Specified by:
add
in interfaceDataSourceService
- Overrides:
add
in classDefaultDataSourceService
- 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
public String update(Map<String,String> parameters, String content)
Description copied from interface:DataSourceService
Execute an update action.- Specified by:
update
in interfaceDataSourceService
- Overrides:
update
in classDefaultDataSourceService
- 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
-
-