Skip to content

Latest commit

 

History

History
107 lines (80 loc) · 7.54 KB

exercise-2.md

File metadata and controls

107 lines (80 loc) · 7.54 KB

PrerequisitesExercise 0Exercise 1Exercise 1.1Exercise 2Exercise 3Exercise 4Exercise 5Exercise 6Exercise 7


Exercise 2 - Environment Variables and Input Parameters

BPMN processes might require additional information during execution, e.g. for configuration purposes. We will take a look at two possibilities on how to pass additional information to a BPMN process: Environment Variables and Input Parameters.
The goal of this exercise is to enhance the dsfdev_dicProcess by trying them both. In both cases the information will be available in the doExecute method of your service class.

In order to solve this exercise, you should have solved the first exercise and read the topics on Environment Variables, Task Input Parameters, Accessing Task Resources During Execution, Placeholders and Read Access Tag.

Solutions to this exercise are found on the branch solutions/exercise-2.

Exercise Tasks

  1. Add a new boolean variable to the TutorialConfig class. It will enable/disable logging and have its value injected from an environment variable. Add the annotation and specify the default value as false. You may freely choose a name for your environment variable here. Just make sure you follow the naming convention explained in Environment Variables.

  2. Modify the constructor of the DicTask class to use the newly created variable. Don't forget to change the DicTask bean in TutorialConfig.

  3. Use the value of the environment variable in the DicTask class to decide whether the log message from exercise 1 should be printed.

  4. Add the new environment variable to the dic-bpe service in dev-setup/docker-compose.yml and set the value to "true".

  5. Create a new CodeSystem with url http://dsf.dev/fhir/CodeSystem/tutorial having a concept with code tutorial-input. Don't forget to add the read-access-tag.

    Don't how to create a CodeSystem?

    Check out this guide.

    Don't know where to put the CodeSystem?

    tutorial-process/src/main/resources/fhir/CodeSystem.

  6. Create a new ValueSet with url http://dsf.dev/fhir/ValueSet/tutorial that includes all concepts from the CodeSystem. Don't forget to add the read-access-tag.

    Don't how to create a ValueSet?

    Check out this guide.

    Don't know where to put the ValueSet?

    tutorial-process/src/main/resources/fhir/ValueSet.

  7. Add a new input parameter of type tutorial-input with Task.input.value[x] as a string to the task-start-dic-process.xml Task profile.

    Don't how to add a new input parameter?

    Check out this guide.

  8. task-start-dic-process and by extension the process dsfdev_dicProcess now require additional FHIR resources. Make sure the return value for TutorialProcessPluginDefinition#getFhirResourcesByProcessId also includes the new CodeSystem and ValueSet resources for the dsfdev_dicProcess.

  9. Read the new input parameter in the DicTask class from the start Task and add the value to the log message from exercise 1.

    Don't know how to get the input parameter?

    The TaskHelper instance will prove useful here. Use it in conjunction with variables to get the right Task resource from the BPMN process execution.

  10. We just changed the elements a Task resource has to include. So you need to change example-task.xml for cURL or Task/task-start-dic-process.xml, if you want to use the web interface, to include the new input parameter. The actual value may be any arbitrary string. This also means that we need to change the plugin version, since a Task made according to the old StructureDefinition won't be valid for processes still expecting the old StructureDefinition. The new resource version shall be 1.1.

Solution Verification

Maven Build and Automated Tests

Execute a maven build of the dsf-process-tutorial parent module via:

mvn clean install -Pexercise-2

Verify that the build was successful and no test failures occurred.

Process Execution and Manual Tests

To verify the dsfdev_dicProcess can be executed successfully, we need to deploy it into a DSF instance and execute the process. The maven install build is configured to create a process jar file with all necessary resources and copy the jar to the appropriate locations of the docker dev setup.

  1. Start the DSF FHIR server for the dic.dsf.test organization in a console at location .../dsf-process-tutorial/dev-setup:

    docker-compose up dic-fhir
    

    Verify the DSF FHIR server started successfully at https://dic/fhir.

  2. Start the DSF BPE server for the dic.dsf.test organization in second console at location .../dsf-process-tutorial/dev-setup:

    docker-compose up dic-bpe
    

    Verify the DSF BPE server started successfully and deployed the dsfdev_dicProcess.

  3. Start the dsfdev_dicProcess by posting an appropriate FHIR Task resource to the DSF FHIR server of the dic.dsf.test organization using either cURL or the DSF FHIR server's web interface. Check out Starting A Process Via Task Resources again if you are unsure.

    Verify that the dsfdev_dicProcess was executed by the DSF BPE server. The BPE server should:

    • Print a message showing that the process was started.
    • If logging is enabled - print the log message and the value of the input parameter you added to the DicTask implementation.
    • Print a message showing that the process finished.

Check that you can disable logging of your message by modifying the docker-compose.yml file and configuring your environment variable with the value "false" or removing the environment variable.
Note: Changes to environment variable require recreating the docker container.

Also check that modification to the Task input parameter specified in the TutorialExampleStarter class, have the appropriate effect on your log message.


PrerequisitesExercise 0Exercise 1Exercise 1.1Exercise 2Exercise 3Exercise 4Exercise 5Exercise 6Exercise 7