readDataset()

This object provides read access to data from DataSet

List<Row> readDataset(Integer id)

Returns list of rows from dataset id

List<Row> readDataset(Integer id, int limit)

Returns list of rows from dataset id , where count of value is limit

List<Row> readDataset(Integer id, int limit, Filter filter)

Returns list of rows from dataset id , where count of value is limit, filtered by filter

List<Row> readDataset(Integer id, int limit, contextFilter())

Returns list of rows from dataset id , where count of value is limit, filtered with set filter in report

List<Row> readDataset(Integer id, int limit, Filter filter, Sort sort)

Returns list of rows from dataset id , where count of value is limit, filtered by filter, sorted by belladatiSortObject

e.g. def rows = readDataset(123, 1, filter, com.belladati.common.sort.Sort.descending('row_uid'))

List<Row> readDataset(String datasetCode)

Returns list of rows from dataset code

List<Row> readDataset(String datasetCode, int limit)

Returns list of rows from dataset code, where count of value is limit

List<Row> readDataset(String datasetCode, int limit, Filter filter)

Returns list of rows from dataset code, where count of value is limit, filtered by filter

List<Row> readDataset(String id, int limit, IFilter contextFilter)

Returns list of rows from dataset id , where count of value is limit, filtered with set filter in report

List<Row> readDataset(String datasetCode, int limit, Filter filter, Sort sort)

Returns list of rows from dataset idcode, where count of value is limit, filtered by filter, sorted by belladatiSortObject

e.g. def rows = readDataset(123, 1, filter, com.belladati.common.sort.Sort.descending('row_uid'))

Void readDataset(Integer id, Closure<Object> closure)

You can pass Closure to readDataset

 readDataset(123,  filter) {
// defined variables for closure are row, index, columns
row.getValues()['L_NAME']

}

Void readDataset(Integer id, int limit, Closure<Object> closure)

You can pass Closure to readDataset

readDataset(123, -1) {row.getValues()['L_NAME']}

Void readDataset(Integer id, int limit, Filter filter, Closure<Object> closure)

You can pass Closure to readDataset

readDataset(123, -1, filter) {row.getValues()['L_NAME']}

Void readDataset(Integer id, int limit, Filter filter, Sort sort, Closure<Object> closure)

You can pass Closure to readDataset

readDataset(123, -1, filter,ascSort('L_ATT')) {row.getValues()['L_NAME']}

def conf.interval = contextFilter().filterValues[0]?.values[0] 

Returns selected filter value

Sort()

This object returns sort ordering

Sort ascSort(final String column)
Returns ascending sorting according to column
Sort descSort(final String column)
Returns descending sorting according to column

Row()

This function returns value of column from row

String row.getValues()[String column]
getValues function returns value of a row from selected column

storeDataset()

This object provide write and update access to DataSet

void storeDataset(Integer datasetId, List<Map<String, Object>> rows)

Stores List of Maps that contains <columnCode,value> into dataset datasetId

[['L_ID':'A','M_VAL':5],['L_ID':'B','M_VAL':9]]
void storeDataset(String datasetCode, List<Map<String, Object>> rows)

Stores List of Maps that contains <columnCode,value> into dataset datasetCode

[['L_ID':'A','M_VAL':5],['L_ID':'B','M_VAL':9]]

updateDataset()

This object provide update to DataSet

void updateDataset(Integer datasetId, List<Map<String, Object>> rows, List<String> column)

Updates list of Maps that contains <columnCode,value> into dataset datasetId where column value matches inserted value

[['L_ID':'A','M_VAL':5],['L_ID':'B','M_VAL':9]]
void updateDataset(String datasetCode, List<Map<String, Object>> rows, List <String> columns)

Update list of Maps that contains <columnCode,value> into dataset datasetCode where column value matches inserted value

[['L_ID':'A','M_VAL':5],['L_ID':'B','M_VAL':9]]

deleteData()

This function deletes data from dataset according to specified filter. When filter is null, it will erase all data from dataset

Void deleteData(Integer id, Filter filter)
Deletes data from dataset's id according to specified filter

Void deleteData(String code, Filter filter)
Deletes data from dataset's code according to specified filter

createUser()

This object provide possibility to create new user.

Response createUser(JSONObject data)

Creates new user from  JSONObject user and returns its id

downloadFile()

This object provide possibility to create new user.

Response downloadFile(Integer id)

Returns file from mediaGalery when id is provided

Response downloadFile(Integer id, String desiredFileName)Returns renamed file from mediaGalery according to desiredFileName when id is provided


other functions

public static Object executeMlProjectWithResult(Integer projectId, Map<String, Object> variables)

Executes ML project and waits for it returns value

void importJson(String code, File file)

Import data from defined file to dataset. See how to define file here

See example of whole code

def i = [overwrite:[policy:"DELETE_BY_MEMBERS",attributes:['L_TIME'],"attributesAll": false],columns:[[code:'L_DATE',format:'yyyy-MM-dd'],[code:'L_VALUE']],data:[['2024-07-01','TODAY'],['2024-06-30','YESTERDAY']]]
def js = JSON.mapToJSONString(i,false)
importJson('DATE_AND_VALUE', js)
return Response.ok().build()  
  • No labels