Refactored datasourcedefinition building

Introduced DataSourceDefinition* classes to mimic the workings of
smart-client server. This a work in progress commit.