-load 'application'
-
 #------------------ BEGIN REQUIRE ------------------
 #instanciate Databrowser classes (datasystem, searchengine)
-ds = require './db/dataSystem'
-se = require('./db/searchEngine')(ds)
+dataSystem = require './db/dataSystem'
+searchEngine = require('./db/searchEngine')(dataSystem)
 
 #instanciate Noesis helpers
 oObjectHelper = require './noesis-tools/oObjectHelper'

                                        console.log error
                                        res.send {'no_result' : 'Error : Server error occurred while retrieving data.'}
                                    else
                                        se.doBasicSearch(res, tabDoctypes, pageParams)
                            else
                                res.send {'no_result' : 'Error : Server error occurred while retrieving data.'}

            else 
                se.doBasicSearch(res, tabDoctypes, pageParams)

                    
        else
            res.send {'no_result' : 'Error : Unknown research parameters'}


    if req.params.id?
        requests = []
        requests.push (callback) -> #0 -> delete
                dataSystem.deleteById callback, req.params.id
        async.parallel requests, (error, results) ->
            if error
                res.send('error', 'Server error occurred while trying to remove data.')
