Changes between Version 14 and Version 15 of S3XRC/ResourceReport


Ignore:
Timestamp:
08/28/10 19:32:51 (11 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • S3XRC/ResourceReport

    v14 v15  
    44== Report Function for your Resource ==
    55
    6 === The Idea ===
     6=== The idea ===
    77
    88You have a module {{{xxx}}} and within it a resource {{{yyy}}}, which has a number of components. You're providing CRUD functions for the resource and its components using {{{shn_rest_controller()}}}.
     
    1212This tutorial shows you how this can be integrated in the REST interface of your resource.
    1313
    14 === Creating a Custom Method Handler ===
    15 
    16 The reporting function shall be added as a custom method handler.
    17 Add this function to your model file and add it as a method to your resource, like:
     14=== Techniques to use ===
     15
     16==== Creating a custom method handler ====
     17
     18Reporting is a method of your resource, the reporting function will therefore be implemented as a custom method handler.
     19
     20Add the reporting function to your model file, and add it as a method to your resource, like:
    1821
    1922{{{
     
    4649meaning, it already implements a RESTful API for your reporting function, e.g. does the parsing/validating of the URL for you, implements the full range of URL queries for your resource and so forth. Nothing you need to care about now.
    4750
    48 === Providing different Report Formats ===
    49 
    50 As mentioned before, you want to provide the report in various formats.
    51 To know which format has been requested, use r.representation inside the method handler:
     51==== Providing different Report Formats ====
     52
     53You want to provide the report in various formats, hence you need to know what format the user has requested. The best way is to check for the format that has been specified in the URL.
     54
     55To know which format has been specified, simply use r.representation inside the method handler:
    5256
    5357{{{
     
    9599}}}
    96100
    97 === How to get at the data ===
     101==== How to get at the data ====
    98102
    99103How can you find out which data have to be processed by your reporting function, and yet more important: how can you get at them?
     
    101105{{{r}}} (the {{{S3Request}}} object) contains an interface to your resource as {{{S3Resource}}} object in: {{{r.resource}}}
    102106
    103 And this is what you can use to access your data. Some examples:
     107And this is what you can use to easily access the resource data. Some examples:
    104108
    105109{{{
     
    145149
    146150
    147 === The sum of all values in a field... ===
    148 
    149 The case:
     151=== The concrete case: Total costs within a time interval ===
     152
    150153Your resource contains a "timestmp" field (type datetime) and a field "cost" (type double), and now the user shall select a time interval in aform, and your report function shall provide the sum of all "cost" for those records with a timestmp within the selected time interval.
    151154
    152155Let's go:
    153 
    154156First of all, we implement our method handler as before:
    155157