REST and Components
BigSense is a RESTful web service. To this end, the individual components that get called can often been seen in the URL itself. Take for example the following request:
From this URL we can see the AggergateAction class is called. All the other path elements of the URL such as Sum, DateRange, 20120501, 20120502 and 60 are placed in an ActionRequest object and sent to that action. Everything after the first period indicates the FormateTrait to be used. In this case it's the tab delimited format (txt). Then, two additional ConverterTraits are applied: TimezoneConverter and UnitsConverter. There are other components that are used behind the scene such as ValidatorTraits and the DatabaseHandler.
Actions use the naming format <Action Name>Action for their class names. The name doesn't actually matter as they are glued into the framework using Spring as we'll see later. The actions do not preform any validation on their inputs. Those are taken care of by ValidationTraits. They simply assume the arguments are correctly formatted and of the right type and do what the call requires. This typically involves either reading or writing data to the database. The inputs to an actions runAction() method is an ActionRequest object and the action returns an ActionResponse.
Validatros are called before the appropriate action. If two actions have the same input requirements, they can share the same validator. If the validator returns something other than the Scala None type, the error message is processed and sent to the end user without the action being run. If the validation passes, the action is then called.