cancel
Showing results for 
Search instead for 
Did you mean: 

Write values into a Collection in activiti:value

burn83
Champ in-the-making
Champ in-the-making
Hello to everybody!!

I have a little problem…i've created a public java class that implements JavaDelegate in order to populate an activiti:formProperty type="enum", with some activiti:value!

with this Java istruction :

listidexams.add(idexams);
listexams.add(examsname);
arg0.setVariable("completeexams", listexams);
arg0.setVariable("completeidexams", listidexams);


…i put in collection listexams some value that i've extract from my db.

Now when I must prepare the xml code..how i must doing?!
<extensionElements>
       <activiti:formProperty id="esame" type="enum">
         <activiti:value id="first_id_of_exams" name="first_element_of_list" />
              <activiti:value id="second_id_of_exams" name="second_element_of_list" />
         …
              …
       </activiti:formProperty>
    </extensionElements>

Obviusly, this activiti:values must do dinamic!! Smiley Sad
14 REPLIES 14

jbarrez
Star Contributor
Star Contributor
From the userguide:

<activiti:formProperty id="direction" type="enum">
      <activiti:value id="left" name="Go Left" />
      <activiti:value id="right" name="Go Right" />
      <activiti:value id="up" name="Go Up" />
      <activiti:value id="down" name="Go Down" />
    </activiti:formProperty>

burn83
Champ in-the-making
Champ in-the-making
hello jbarrez..in the example that you show me the values are static!! i know that values at the moment of write the xml code! Smiley Sad
In my case, i have one or more "activiti:value", in accordion with my query, based on my data (list of exams, list of students).
I need to make a cycle, or a loop, for all results of my query.
is it possible?!

can i write something like:

<activiti:formProperty id="list">
for (i=0, i<sizeofexams, i++){
<activiti:value id="id" name="exam" />
}
</activiti:formProperty>

i think that, logically is correct, but i don't know the exact way…

frederikherema1
Star Contributor
Star Contributor
Hi there. If I understand correctly, this is what you're trying to to:

- Generate a BPMN2.0.xml file for a process with an enum-form property in it.
- Form-property values are known when generating the XML-file.

This is perfectly possible, you can for example use freemarker or any other template-language to generate the BPMN20.xml with a loop-construct inside, looping over the possible enum values. Even better is to use the bpmn-converter project (https://github.com/Activiti/Activiti/tree/master/modules/activiti-bpmn-converter). You can create a POJO-model for your process and add the form-property enum there. Afterwards, you can convert the POJO to Xml and deploy it to activiti…


If your use case is that you only know the possible values AT RUNTIME, you should create a custom FormProperty type, which uses your code top query for the possible values. If you look for "UserFormType" in the forum, you'll get plenty of pointers on how to do this.

burn83
Champ in-the-making
Champ in-the-making
I have understand!! but i have some problems with the source code of "Activiti-BPMN-Converter" project.


Scanning for projects…

Some problems were encountered while building the effective model for org.activiti:activiti-bpmn-converter:jar:5.12-SNAPSHOT
'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 24, column 15
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.

It is highly recommended to fix these problems because they threaten the stability of your build.

For this reason, future Maven versions might no longer support building such malformed projects.

                                                                       
————————————————————————
Building Activiti - BPMN Converter 5.12-SNAPSHOT
————————————————————————
————————————————————————
BUILD FAILURE
————————————————————————
Total time: 1.237s
Finished at: Mon Dec 24 10:58:21 CET 2012
Final Memory: 6M/154M
————————————————————————
Failed to execute goal on project activiti-bpmn-converter: Could not resolve dependencies for project org.activiti:activiti-bpmn-converter:jar:5.12-SNAPSHOT: Failed to collect dependencies for [org.activiti:activiti-bpmn-model:jar:5.12-SNAPSHOT (compile), commons-lang:commons-lang:jar:2.4 (compile), com.h2database:h2:jar:1.3.168 (provided), junit:junit:jar:4.8.1 (provided), org.activiti:activiti-engine:jar:5.12-SNAPSHOT (test)]: Failed to read artifact descriptor for org.activiti:activiti-bpmn-model:jar:5.12-SNAPSHOT: Failure to find org.activiti:activiti-rootSmiley Tongueom:5.12-SNAPSHOT in https://maven.alfresco.com/nexus/content/repositories/activiti/ was cached in the local repository, resolution will not be reattempted until the update interval of activiti has elapsed or updates are forced -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException


I compile with success "Activiti-BPMN-Model" project and "Activiti-Engine" project (i have added <exclude>**/ProcessDiagramRetrievalTest.java</exclude> in pom.xml).

burn83
Champ in-the-making
Champ in-the-making
in order to remove my waning message..i try to add this (in pom.xml of Activiti-BPMN-Converter)

<version>2.4</version>

but nothing…

the error is:

Scanning for projects…

Some problems were encountered while building the effective model for org.activiti:activiti-bpmn-converter:jar:5.12-SNAPSHOT
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.
The expression ${version} is deprecated. Please use ${project.version} instead.

It is highly recommended to fix these problems because they threaten the stability of your build.

For this reason, future Maven versions might no longer support building such malformed projects.

                                                                       
————————————————————————
Building Activiti - BPMN Converter 5.12-SNAPSHOT
————————————————————————
Downloading: http://download.java.net/maven/2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4....

Downloading: https://repository.sonatype.org/content/repositories/apache-snapshots/org/apache/maven/plugins/maven...

Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2...
        
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2... (6 KB at 19.5 KB/sec)
————————————————————————
BUILD FAILURE
————————————————————————
Total time: 3.628s
Finished at: Mon Dec 24 11:05:59 CET 2012
Final Memory: 9M/154M
————————————————————————
Failed to execute goal on project activiti-bpmn-converter: Could not resolve dependencies for project org.activiti:activiti-bpmn-converter:jar:5.12-SNAPSHOT: Failed to collect dependencies for [org.activiti:activiti-bpmn-model:jar:5.12-SNAPSHOT (compile), commons-lang:commons-lang:jar:2.4 (compile), com.h2database:h2:jar:1.3.168 (provided), junit:junit:jar:4.8.1 (provided), org.activiti:activiti-engine:jar:5.12-SNAPSHOT (test)]: Failed to read artifact descriptor for org.activiti:activiti-bpmn-model:jar:5.12-SNAPSHOT: Failure to find org.activiti:activiti-rootSmiley Tongueom:5.12-SNAPSHOT in https://maven.alfresco.com/nexus/content/repositories/activiti/ was cached in the local repository, resolution will not be reattempted until the update interval of activiti has elapsed or updates are forced -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

I think that activiti 5.12 is too recent and in fact i try to edit the activiti 5.10 … but "activiti bpmn converter" project in 5.10 examples isn't…

trademak
Star Contributor
Star Contributor
Sorry, but I don't understand your issue now. You are referring to Activiti 5.10, but you are using the Activiti BPMN converter from 5.12-SNAPSHOT?
if you run mvn clean install from the root of the current Github master, the model, converter and engine projects will be build for you.
Can you give that a try?

Best regards,

burn83
Champ in-the-making
Champ in-the-making
Yeah!! Everybody ok in Activiti 5.11 and Netbeans…the sources was cleaned and builded, and finally..i can import jar in my Projects…

burn83
Champ in-the-making
Champ in-the-making
Hi…
I try to edit a project, but there are some problems in order to show, in final XML, the activiti:value.. i.e.

BpmnModel bpmnModel = new BpmnModel();
    Process process = bpmnModel.getMainProcess();
    process.setId("Processoautogenerato");
    process.setName("Prenotazione Esame Generata");
    bpmnModel.getProcesses().add(process);
    StartEvent startEvent = new StartEvent();
    startEvent.setId("startEvent1");
    startEvent.setName("Start");
    startEvent.setInitiator("initiator");
    process.addFlowElement(startEvent);
   
    ServiceTask stask = new ServiceTask();
    stask.setId("popola");
    stask.setName("Popola Esame");
    stask.setImplementationType("class");
    stask.setImplementation("Popola");
    process.addFlowElement(stask);
   
    UserTask task = new UserTask();
    task.setId("selectesame");
    task.setName("Seleziona Esame");
    task.setAssignee("${initiator}");
    List<String> lstcandidati = new ArrayList<String>();
    lstcandidati.add("Studenti");
    task.setCandidateGroups(lstcandidati);
    task.setDocumentation("Qui lo studente (${initiator}) seleziona l'esame al quale prenotarsi");
   
    List<FormProperty> formProperties = new ArrayList();
    FormProperty formProperty = new FormProperty();
    formProperty.setName("Seleziona Esame");
    formProperty.setId("selectesame");
    formProperty.setType("enum");
    formProperty.setRequired(true);
   
    [color=#FF0000]List<FormValue> lstformValue = new ArrayList();
    FormValue fv = new FormValue();
    fv.setId("id1");
    fv.setName("Analisi I");
   
    FormValue fv2 = new FormValue();
    fv2.setId("id2");
    fv2.setName("Geometria I");
    lstformValue.add(fv);
    lstformValue.add(fv2);
   
    formProperty.setFormValues(lstformValue);[/color]
    formProperties.add(formProperty);
    task.setFormProperties(formProperties);

    process.addFlowElement(task);
   
    EndEvent endEvent = new EndEvent();
    endEvent.setId("endEvent1");
    process.addFlowElement(endEvent);
   
   
    SequenceFlow flow1 = new SequenceFlow();
    flow1.setId("flow1");
    flow1.setSourceRef("startEvent1");
    flow1.setTargetRef("popola");
    process.addFlowElement(flow1);
   
    SequenceFlow flow2 = new SequenceFlow();
    flow2.setId("flow2");
    flow2.setSourceRef("popola");
    flow2.setTargetRef("selectesame");
    process.addFlowElement(flow2);
   
    SequenceFlow flow3 = new SequenceFlow();
    flow3.setId("flow3");
    flow3.setSourceRef("selectesame");
    flow3.setTargetRef("endEvent1");
    process.addFlowElement(flow3);
   
    BpmnXMLConverter converter = new BpmnXMLConverter();
    System.out.println(new String(converter.convertToXML(bpmnModel)));

and the result is:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="Processoautogenerato" name="Prenotazione Esame Generata" isExecutable="true">
    <startEvent id="startEvent1" name="Start" activiti:initiator="initiator" activiti:formKey="initiator"></startEvent>
    <serviceTask id="popola" name="Popola Esame" activiti:class="Popola"></serviceTask>
    <userTask id="selectesame" name="Seleziona Esame" activiti:assignee="${initiator}" activiti:candidateGroups="Studenti">
      <documentation>Qui lo studente (${initiator}) seleziona l'esame al quale prenotarsi</documentation>
      <extensionElements>
        <activiti:formProperty id="selectesame" name="Seleziona Esame" type="enum">
//here there aren't my activiti:value!!
</activiti:formProperty>
      </extensionElements>
    </userTask>
    <endEvent id="endEvent1"></endEvent>
    <sequenceFlow id="flow1" sourceRef="startEvent1" targetRef="popola"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="popola" targetRef="selectesame"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="selectesame" targetRef="endEvent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_Processoautogenerato">
    <bpmndi:BPMNPlane bpmnElement="Processoautogenerato" id="BPMNPlane_Processoautogenerato"></bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


with activiti:value hiding…any ideas Smiley Sad !?

trademak
Star Contributor
Star Contributor
Hi,

The form values were not yet written in the XML export logic of form properties.
Now it is, so you can pull these changes from the git master.

Best regards,