REST Implementation for Scheduler in Legacy UI Module

Tags: #<Tag:0x00007f076bedb1c8> #<Tag:0x00007f076bedb038>

I am working on RESTWS-674 ticket to implement REST for Scheduler in LegacyUI module.

In the dashboard, Scheduler contains a list of task definitions. Here I wanted to follow two classes from OpenMRS Core

Here I am going to expose this following details through the REST serveices,

TaskDefinition - GET /rest/v1/taskdefinition/

  1. uuid
  2. name
  3. descriptio
  4. taskClass
  5. startTime
  6. lastExecutionTime
  7. repeatInterval
  8. startOnStartup
  9. started
  10. properties

@dkayiwa Is it ok with the implementation ?

Looks like a good start! :slight_smile:

I don’t think Schedule is really part of the public API, in fact don’t think it’s used anywhere, I’d say just ignore it.

@wyclif Here I wanted to implement Manage Scheduler functionalities in OWA, So I need to implement REST services for TaskDefinitions to complete that task.

@dkayiwa Can you review it please

You need to add some tests.

@dkayiwa I have added some test cases, but getting some errors. Can you take a look at here, Test class : Error trace :

When you fetch that task with getTaskByName, does it actually exist?

Yah, I can get it through the REST Request, But can’t through the Test Case

You can mock it, or else add a test dataset

Finally, I have implemented two resources for this purpose and all are working as expected :slight_smile:

TaskDefinition - /openmrs/ws/rest/v1/taskdefinition

  • GET - return all the registered tasks

  • POST - Create new definition

  • POST/{taskName} - update the task definition

TaskAction - /openmrs/ws/rest/v1/taskaction

  • POST - post the action, task information to do Action types : SCHEDULETASK, SHUTDOWNTASK, RESCHEDULETASK, RESCHEDULEALLTASK, DELETE, ONSTARTUP, ONSHUTDOWN Post Body : {“action” : “scheduletask”, “tasks” : [“sample”], “allTasks” : true }

cc : @dkayiwa

@dkayiwa I have updated the PR but failed in Travis.

I could get success with my local project but Travis check was failed. Can you please take a look on this error?

Did you look at the failure log?

@dkayiwa It showed me the COMPILATION ERROR in the Travis check. But I can compile and build it locally without any errors.

[INFO] -------------------------------------------------------------
[ERROR] /home/travis/build/openmrs/
is not abstract and does not override abstract method getCREATEModel( in

Did you pull the latest upstream changes into your local version?


Yah, with in a short time, the code has been changed in the master due to the other PRs :joy:. Thanks for the advice!

Now It is working without any problem :smiley: