Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-3773

Global Properties are awkward to work with in the API

    XMLWordPrintable

    Details

    • Complexity:
      Low

      Description

      If I want to change the value of an existing global property in my module's activator, I need to write way too much code, like this:

      AdministrationService administrationService = Context.getAdministrationService();
      GlobalProperty gp = administrationService.getGlobalPropertyObject(OpenmrsConstants.GP_VISIT_ASSIGNMENT_HANDLER);
      if (gp == null) {
          gp = new GlobalProperty();
          gp.setProperty(OpenmrsConstants.GP_VISIT_ASSIGNMENT_HANDLER);
      }
      gp.setPropertyValue(EmrVisitAssignmentHandler.class.getName());
      administrationService.saveGlobalProperty(gp);
      

      I propose that:

      1. we un-deprecate the AdministrationService.setGlobalProperty(String, String) and change its behavior to match the code snippet above
      2. we add an AdministrationService.updateGlobalProperty(String, String) method that behaves like the above, but throws an IllegalStateException if it does not find an existing GP.

        Attachments

          Activity

            People

            Assignee:
            surangak Suranga Kasthurirathne
            Reporter:
            darius Darius Jazayeri [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 4 hours
                4h
                Remaining:
                Time Spent - 2 hours Remaining Estimate - 2 hours
                2h
                Logged:
                Time Spent - 2 hours Remaining Estimate - 2 hours
                2h