use of org.activiti.workflow.simple.definition.form.ListPropertyEntry in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testTransitionProperty.
@Test
public void testTransitionProperty() throws Exception {
WorkflowDefinition definition = new WorkflowDefinition();
definition.setId("process");
HumanStepDefinition humanStep = new HumanStepDefinition();
humanStep.setId("step1");
FormDefinition form = new FormDefinition();
humanStep.setForm(form);
AlfrescoTransitionsPropertyDefinition transition = new AlfrescoTransitionsPropertyDefinition();
transition.addEntry(new ListPropertyEntry("One", "One"));
transition.addEntry(new ListPropertyEntry("Two", "Two"));
humanStep.getForm().addFormProperty(transition);
definition.addStep(humanStep);
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
assertEquals(1L, model.getTypes().size());
M2Type taskType = model.getTypes().get(0);
assertEquals(1L, taskType.getPropertyOverrides().size());
assertEquals("bpm:outcomePropertyName", taskType.getPropertyOverrides().get(0).getName());
assertTrue(taskType.getPropertyOverrides().get(0).getDefaultValue().contains("step1transitions"));
assertEquals(1L, taskType.getProperties().size());
assertEquals(1L, model.getConstraints().size());
}
use of org.activiti.workflow.simple.definition.form.ListPropertyEntry in project Activiti by Activiti.
the class AlfrescoTransitionsPropertyDefinition method setValues.
@Override
public void setValues(FormPropertyDefinition otherDefinition) {
if (!(otherDefinition instanceof AlfrescoTransitionsPropertyDefinition)) {
throw new SimpleWorkflowException("An instance of AlfrescoTransitionProperty is required to set values");
}
AlfrescoTransitionsPropertyDefinition propDef = (AlfrescoTransitionsPropertyDefinition) otherDefinition;
setName(propDef.getName());
setMandatory(propDef.isMandatory());
setWritable(propDef.isWritable());
// Copy the entries from the other definition
if (entries == null) {
entries = new ArrayList<ListPropertyEntry>();
} else {
entries.clear();
}
if (propDef.getTransitions() != null) {
ListPropertyEntry newEntry = null;
for (ListPropertyEntry entry : propDef.getTransitions()) {
newEntry = new ListPropertyEntry(entry.getValue(), entry.getName());
entries.add(newEntry);
}
}
if (otherDefinition.getParameters() != null) {
setParameters(new HashMap<String, Object>(otherDefinition.getParameters()));
}
}
use of org.activiti.workflow.simple.definition.form.ListPropertyEntry in project Activiti by Activiti.
the class BaseStepDefinitionConverter method convertProperties.
/**
* Converts form properties. Multiple step types can contain forms,
* hence why it it a shared method here.
*/
protected List<FormProperty> convertProperties(FormDefinition formDefinition) {
List<FormProperty> formProperties = new ArrayList<FormProperty>();
for (FormPropertyDefinition propertyDefinition : formDefinition.getFormPropertyDefinitions()) {
FormProperty formProperty = new FormProperty();
formProperties.add(formProperty);
formProperty.setId(propertyDefinition.getName());
formProperty.setName(propertyDefinition.getName());
formProperty.setRequired(propertyDefinition.isMandatory());
String type = null;
if (propertyDefinition instanceof NumberPropertyDefinition) {
type = "long";
} else if (propertyDefinition instanceof DatePropertyDefinition) {
type = "date";
} else if (propertyDefinition instanceof BooleanPropertyDefinition) {
type = "boolean";
} else if (propertyDefinition instanceof ListPropertyDefinition) {
type = "enum";
ListPropertyDefinition listDefinition = (ListPropertyDefinition) propertyDefinition;
if (!listDefinition.getEntries().isEmpty()) {
List<FormValue> formValues = new ArrayList<FormValue>(listDefinition.getEntries().size());
for (ListPropertyEntry entry : listDefinition.getEntries()) {
FormValue formValue = new FormValue();
// We're using same value for id and name for the moment
formValue.setId(entry.getValue());
formValue.setName(entry.getName());
formValues.add(formValue);
}
formProperty.setFormValues(formValues);
}
} else {
// Fallback to simple text
type = "string";
}
formProperty.setType(type);
}
return formProperties;
}
Aggregations