Select a user and store his ID

Hello guys !

I want to select a list of users in a form and store them in the database.

In my project the user wants to select some projects (create a video / create a website / create a poster / …), Each “project” has his own object in Database. For each project the user should be able to select a list of user who will be in charge of the project.

My first attempt was to only store the user ID, I create a list of Long in my database. But it does not realy fulfill my needs:
When I display my list in a page or for an export I don’t want to have to load the user name.

Then I choose to create an object wich consist of an ID and string (a “displayName”: firstname + lastname), then when I load my data I can have the name without extra steps. I created a “UserEntry” with the two variables, and I want to use this “Object” as an attribut of many other bdm objects (All the projects)

At first I have select the userEntry, with the relation type as a “Composition”, but I can’t have two differents object’s attributs that refers to my UserEntry.
I changed the relation type to “Association” but now I can’t create / update the “userEntry” if it’s not already created.

So my question is : Do you have a nice way to select a list of users and save it in the BDM ?

If you want to retrieve a set of information all in one single API call maybe creating a REST API extension is a good option. You can provide all required information when calling the API and inside the custom API code you can call the various Engine APIs (including Identity API and BDM API) to get the information you need, format them and returns everything in the HTTP answer as JSON.

Now

Hello again Antoine.

You already helped me for an other question (For the DAO), I kinda solve my issue. The difficulty come from the BDM model where you can’t create a Object and use it in many places as a composition.

Hi,

I have created an example (with Bonita CE 7.8.4) that use both aggregation and composition that might be useful.

I have an object “Product” that has a single “name” attribute. I use a process definition to remove all business data and create my static list of products: phone, car… (it’s my products catalog).

I have an object “InvoiceLine” that has two attributes: a quantity and a reference to a “Product”. This reference is actually an Aggregation has I should not delete my product from my catalog if I delete an invoice line.

And finally I have an Object “Invoice” that has two attributes: a description and a list of references to “InvoiceLine”. This relation between Invoice and InvoiceLine is a composition because if I remove my Invoice all associated InvoiceLine should be deleted.

My example includes a process that let you create a new Invoice. To start, the process requires some information that will lead to creation of Invoice and InvoiceLine objects. Product objects already exist so they don’t need to be created. They can be selected when creating the invoice in the instantiation form. We display the product name in the list, but we store the product persitenceId (the unique id managed by Bonita). When the form is submitted we send all the Invoice and InvoiceLine information including only the persistenceId for the product. In the default value of the invoice business variable we are using the data received in the contract to create the Java object. To set the product attribute we are using the ProductDAO class to retrieve all the existing product information using the persistenceId.