use of org.activiti.workflow.simple.definition.form.FormPropertyGroup in project Activiti by Activiti.
the class AlfrescoFormCreator method createForm.
public void createForm(M2Type contentType, Form formConfig, FormDefinition formDefinition, WorkflowDefinitionConversion conversion) {
if (formDefinition != null && formDefinition.getFormGroups() != null) {
for (FormPropertyGroup group : formDefinition.getFormGroups()) {
// Create a group in the form-config
String groupId = null;
if (group.getId() != null) {
groupId = AlfrescoConversionUtil.getValidIdString(group.getId());
} else {
groupId = AlfrescoConversionUtil.getValidIdString(group.getTitle());
}
FormSet formSet = formConfig.getFormAppearance().addFormSet(groupId, getAppearanceForGroup(group), group.getTitle(), getTemplateForGroup(group));
// Convert all properties
AlfrescoFormPropertyConverter converter = null;
for (FormPropertyDefinition property : group.getFormPropertyDefinitions()) {
converter = propertyConverters.get(property.getClass());
if (converter == null) {
throw new AlfrescoSimpleWorkflowException("Unsupported property type: " + property.getClass().getName());
}
converter.convertProperty(contentType, formSet.getId(), formConfig, property, conversion);
}
}
}
if (formDefinition != null && formDefinition.getFormPropertyDefinitions() != null && !formDefinition.getFormPropertyDefinitions().isEmpty()) {
for (FormPropertyDefinition def : formDefinition.getFormPropertyDefinitions()) {
if (def instanceof AlfrescoTransitionsPropertyDefinition) {
AlfrescoFormPropertyConverter converter = propertyConverters.get(def.getClass());
if (converter != null) {
converter.convertProperty(contentType, null, formConfig, def, conversion);
}
}
}
}
// Finally, add default "transitions" if not already added to the model
if (formConfig.getFormAppearance().getFormSet(AlfrescoConversionConstants.FORM_SET_RESPONSE) == null) {
formConfig.getFormAppearance().addFormSet(AlfrescoConversionConstants.FORM_SET_RESPONSE, null, null, null);
formConfig.getFormFieldVisibility().addShowFieldElement(AlfrescoConversionConstants.FORM_FIELD_TRANSITIONS);
formConfig.getFormAppearance().addFormField(AlfrescoConversionConstants.FORM_FIELD_TRANSITIONS, null, AlfrescoConversionConstants.FORM_SET_RESPONSE);
}
}
use of org.activiti.workflow.simple.definition.form.FormPropertyGroup in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testCustomReference.
/**
* Test if a custom reference (eg. type=cm:person) is turned into an association on the
* model.
*/
@Test
public void testCustomReference() throws Exception {
// TODO: finish test once all types are present
WorkflowDefinition definition = new WorkflowDefinition();
definition.setId("process");
HumanStepDefinition humanStep = new HumanStepDefinition();
humanStep.setId("step1");
FormDefinition form = new FormDefinition();
humanStep.setForm(form);
FormPropertyGroup group = new FormPropertyGroup();
group.setId("group");
group.setTitle("My group");
humanStep.getForm().addFormPropertyGroup(group);
// Add simple text
ReferencePropertyDefinition textProperty = new ReferencePropertyDefinition();
textProperty.setName("person");
textProperty.setMandatory(true);
textProperty.setType("cm:person");
group.addFormProperty(textProperty);
definition.addStep(humanStep);
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
// Check content-model
M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
assertNotNull(model);
M2Type type = model.getTypes().get(0);
assertNotNull(type);
// Simple text
M2ClassAssociation association = getAssociationFromType("person", type);
assertEquals("cm:person", association.getTarget().getClassName());
assertTrue(association.getTarget().isMandatory());
}
use of org.activiti.workflow.simple.definition.form.FormPropertyGroup in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testTaskListenerForOutgoingProperties.
@Test
public void testTaskListenerForOutgoingProperties() throws Exception {
WorkflowDefinition definition = new WorkflowDefinition();
definition.setId("process");
HumanStepDefinition humanStep = new HumanStepDefinition();
humanStep.setId("step1");
FormDefinition form = new FormDefinition();
humanStep.setForm(form);
TextPropertyDefinition text = new TextPropertyDefinition();
text.setName("my text");
text.getParameters().put(AlfrescoConversionConstants.PARAMETER_ADD_PROPERTY_TO_OUTPUT, true);
FormPropertyGroup group = new FormPropertyGroup();
group.setId("group");
form.getFormGroups().add(group);
group.getFormPropertyDefinitions().add(text);
definition.addStep(humanStep);
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
Process process = conversion.getProcess();
assertNotNull(process);
boolean listenerFound = false;
for (FlowElement flowElement : process.getFlowElements()) {
if (flowElement instanceof UserTask) {
UserTask task = (UserTask) flowElement;
assertNotNull(task.getTaskListeners());
assertEquals(2L, task.getTaskListeners().size());
assertEquals("create", task.getTaskListeners().get(0).getEvent());
assertEquals("complete", task.getTaskListeners().get(1).getEvent());
listenerFound = true;
}
}
assertTrue(listenerFound);
}
use of org.activiti.workflow.simple.definition.form.FormPropertyGroup in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testHumanStepBasicFormField.
/**
* Test basic form-fields (text, number, date, list, ...)
*/
@Test
public void testHumanStepBasicFormField() throws Exception {
// TODO: finish test once all types are present
WorkflowDefinition definition = new WorkflowDefinition();
definition.setId("process");
HumanStepDefinition humanStep = new HumanStepDefinition();
humanStep.setId("step1");
FormDefinition form = new FormDefinition();
humanStep.setForm(form);
FormPropertyGroup group = new FormPropertyGroup();
group.setId("group");
group.setTitle("My group");
humanStep.getForm().addFormPropertyGroup(group);
// Add simple text
TextPropertyDefinition textProperty = new TextPropertyDefinition();
textProperty.setName("text");
textProperty.setMandatory(true);
group.addFormProperty(textProperty);
definition.addStep(humanStep);
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
// Check content-model
M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
assertNotNull(model);
M2Type type = model.getTypes().get(0);
assertNotNull(type);
// Simple text
M2Property property = getPropertyFromType("text", type);
assertEquals("d:text", property.getPropertyType());
assertEquals(Boolean.TRUE, property.getMandatory().isMandatory());
}
Aggregations