Lost in external enumeration space (frontend/backend)

For our AASH application we import data from MS Access databases. In order to make data editable, we’d like to import some common data in to specific document models. This data then shall be used in other document models and entries shall be selectable via drop down (exactly like “enumerations”.
I started to implement this in a generic way using “external enumerations”. A specific “ExternalEnumerationLoader” checks whether a document model qualifies for external enumeration (is tagged by an annotation) and extracts key/value pairs (also tagged in the document model via annotation). This was the easy part.

Now, I naively assumed that in the front the drop down is rendered from an URL given in the form model data configuration. (see GetA12) However, I can try any URL there and only get error messages that the external enums cannot be retrieved. Seems like this approach simply does not work.

Other people appear to have implemented things for specific enums, but I honestly have got no clue how to tackle this in a generic way. Any ideas (or a front end developer) appreciated.

Hi @juergen-smooth-ice,

I hope i understood correctly what you are searching for.

From my understanding you

Assuming my list of your prerequisites is complete

The part missing here is the implementation of an external enumeration provider that will take the given source url and will do a request for the enums and map them to the frontend.

Todo:

The providers must be implemented synchronously. Asynchronous operations will result in misbehavior of the application.
GetA12 Login

  • to circumstance that best to do is to create an additional custom Data Holder (see Data Reducers) for your Activity
  • in both cases you should utilize your instance of ServerConnector used in your project to resolve the enum data from the sourceUrl
  • once you have the data accessable inside your activity you can use a redux selector for receiving it from Store (please see cavets) inside your ExternalEnumProvider. A12 provides dataHolderByDescriptor selector for receiving a dataholder from activity.

Cavets
For proper implementation of extern enum provider it is necessary to hand over the provider at two places:

This lead to the problem that the Redux state is not available on time the for engine middlewares are created (since this happens before app setup was intialized). To circumstance that problem you have to export the Redux Store after AppSetup creation so you can use the state also in the middleware.

HINT there are some further discourse topics regarding the implementation of external enums in the frontend, have a look if they will help you for understanding

We ended up building a solution similar to Stephen’s: Here's how to implement a server-backed External Enumeration! Comments?

The main difference is that we’re loading all required external enums from the backend (custom operation) and store them in a map. Whenever an external enum is requested, it is taken from said map by the enum’s document model name (which is referenced in the form model).

With a set of annotations we now can import “basic/common data” from tables in access databases and reference them from the “main” document model while storing the numerical value in the document and showing the display value in the UI.

Edit: We totally failed to use the endpoint in ExternalEnumerationControllerImpl, whatever we tried, it did not work. Apart from performance considerations, this was the reason to use a custom operation.

Edit 2: Our solution so far works for form models, we haven’t even tried overview models, yet.

Edit 3 / caveat: Even though the documentation suggests that you only have to refer to the proper backend endpoint from your form model, this is vastly misleading: You need to to take care of data retrieval, data storage and data provisioning in the frontend using your own custom implementation.