added task related db code and refactored matrixgenerationjob