Form Mapping API

1
0
-1

Hello,

It will be super to have more explanation in the Bonita API.

I search to clone a process to a new one. i'm looking to clone the form Mapping;

1/ How to process the current list of form?

I believe this is :

SearchOptionsBuilder search = new SearchOptionsBuilder(0,100);
search.filter(FormMappingSearchDescriptor.PROCESS_DEFINITION_ID, processDesign.processDefinitionId);
SearchResult searchFormMapping = processAPI.searchFormMappings(search.done());

Then we can loop on the form Mapping

for (FormMapping formMapping : searchFormMapping.getResult()) {

Page page = pageAPI.getPage(formMapping.getPageId());
if (page!=null)
{
formMappingBuilder.addTaskForm(page.getName(), formMapping.getTarget(), formMapping.getTask()); }

Q1.1 Is that correct?

2/ How can I build the new form ?

BusinessArchiveBuilder barBuilder = new BusinessArchiveBuilder().createNewBusinessArchive()
.setProcessDefinition(newDesign);

FormMappingModelBuilder formMappingBuilder = FormMappingModelBuilder.buildFormMappingModel();
for (FormMapping formMapping : searchFormMapping.getResult()) {
Page page = pageAPI.getPage(formMapping.getPageId());
if (page!=null)
{
if (formMapping.getType() == FormMappingType.PROCESS_START)
formMappingBuilder.addProcessStartForm(page.getName(), formMapping.getTarget());
if (formMapping.getType() == FormMappingType.PROCESS_OVERVIEW)
formMappingBuilder.addProcessOverviewForm(page.getName(), formMapping.getTarget());
formMappingBuilder.addTaskForm(page.getName(), formMapping.getTarget(), formMapping.getTask());
}
}

Q2.1 : how do I deploy this newFormMappingModel ?

BusinessArchiveBuilder businessArchiveBuilder = new BusinessArchiveBuilder().createNewBusinessArchive();
if (artifactBuilder.processDefinitionBuilder != null)
businessArchiveBuilder.setProcessDefinition(artifactBuilder.processDefinitionBuilder.done());
if (artifactBuilder.formMappingBuilder != null) {
businessArchiveBuilder.setFormMappings(artifactBuilder.formMappingBuilder.build());
}
if (artifactBuilder.actorMapping != null)
businessArchiveBuilder.setActorMapping(artifactBuilder.actorMapping);
newDesign = artifactBuilder.processDefinitionBuilder.done();

Correct ?

At the end, my new process does not have any form mapping... Worst, it say " No form expected" for each tasks.

Thank you,

Comments

Submitted by Pierre-yves Monnet on Tue, 06/02/2020 - 01:04

Nb: the formMapping build() returns

org.bonitasoft.engine.bpm.bar.form.model.FormMappingModel@3a1e5437[formMappings=[org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@491d9a57[page=custompage_DamageStructurelForm,target=INTERNAL,type=TASK,taskname=Analyse], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@3f0cb83c[page=custompage_DamageStructurelForm,target=INTERNAL,type=TASK,taskname=Localisation], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@aeca4b2[page=custompage_DamageStructurelForm,target=INTERNAL,type=TASK,taskname=Cloture], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@421be634[page=custompage_ProcessToModifyModelA,target=INTERNAL,type=TASK,taskname=Model Validation Dommage], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@67f11302[page=custompage_ProcessToModifyModelB,target=INTERNAL,type=TASK,taskname=Model Collect Commentaire], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@3de69a98[page=custompage_DamageStructurelForm,target=INTERNAL,type=PROCESS_START,taskname=], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@52c060a2[page=custompage_DamageStructurelForm,target=INTERNAL,type=TASK,taskname=], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@4ff71688[page=custompage_caseoverview,target=INTERNAL,type=PROCESS_OVERVIEW,taskname=], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@20f16577[page=custompage_caseoverview,target=INTERNAL,type=TASK,taskname=], org.bonitasoft.engine.bpm.bar.form.model.FormMappingDefinition@29ca19ab[page=custompage_ProcessToModifyModelB,target=INTERNAL,type=TASK,taskname=v]]]

Some tasks are null (need to be investigate) but there is data.

No answers yet.
Notifications