use of org.activiti.workflow.simple.alfresco.model.config.Configuration in project Activiti by Activiti.
the class InitializeAlfrescoModelsConversionListener method afterStepsConversion.
@Override
public void afterStepsConversion(WorkflowDefinitionConversion conversion) {
M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
M2Namespace modelNamespace = model.getNamespaces().get(0);
for (FlowElement flowElement : conversion.getProcess().getFlowElements()) {
if (flowElement instanceof StartEvent) {
StartEvent startEvent = (StartEvent) flowElement;
if (startEvent.getFormKey() == null) {
Module module = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
Configuration detailsForm = module.addConfiguration(EVALUATOR_STRING_COMPARE, MessageFormat.format(EVALUATOR_CONDITION_ACTIVITI, conversion.getProcess().getId()));
// is available
if (conversion.getWorkflowDefinition().getStartFormDefinition() != null && !conversion.getWorkflowDefinition().getStartFormDefinition().getFormGroups().isEmpty()) {
// Create the content model for the start-task
M2Type type = new M2Type();
model.getTypes().add(type);
type.setName(AlfrescoConversionUtil.getQualifiedName(modelNamespace.getPrefix(), AlfrescoConversionConstants.START_TASK_SIMPLE_NAME));
type.setParentName(AlfrescoConversionConstants.DEFAULT_START_FORM_TYPE);
// Create a form-config for the start-task
Module shareModule = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
Configuration configuration = shareModule.addConfiguration(AlfrescoConversionConstants.EVALUATOR_TASK_TYPE, type.getName());
Form formConfig = configuration.createForm();
formConfig.setStartForm(true);
// Populate model and form based on FormDefinition
formCreator.createForm(type, formConfig, conversion.getWorkflowDefinition().getStartFormDefinition(), conversion);
// Use the same form-config for the workflow details
detailsForm.addForm(formConfig);
// Set formKey on start-event, referencing type
startEvent.setFormKey(type.getName());
} else {
// Revert to the default start-form
startEvent.setFormKey(DEFAULT_START_FORM_TYPE);
// Also add form-config to the share-module for workflow detail screen, based on the default form
populateDefaultDetailFormConfig(detailsForm);
}
}
}
}
// Check all elements that can contain PropertyReferences or need additional builders invoked
List<PropertyReference> references = AlfrescoConversionUtil.getPropertyReferences(conversion);
for (FlowElement element : conversion.getProcess().getFlowElements()) {
if (element instanceof SequenceFlow) {
resolvePropertyRefrencesInSequenceFlow((SequenceFlow) element, modelNamespace, references);
} else if (element instanceof IntermediateCatchEvent) {
resolvePropertyRefrencesInCatchEvent((IntermediateCatchEvent) element, modelNamespace, references);
} else if (element instanceof ServiceTask) {
resolvePropertyRefrencesInServiceTask((ServiceTask) element, modelNamespace, references);
} else if (element instanceof UserTask) {
addScriptListenersToUserTask((UserTask) element, conversion);
}
}
// Check if all property-references reference a valid property
if (references != null && !references.isEmpty()) {
for (PropertyReference reference : references) {
reference.validate(model);
}
}
}
use of org.activiti.workflow.simple.alfresco.model.config.Configuration in project Activiti by Activiti.
the class WorkflowDefinitionConversionTest method testEmptyWorkflowDefinitionConversion.
/**
* Check if all required artifacts are created when converting an empty workflow-definition.
*/
@Test
public void testEmptyWorkflowDefinitionConversion() {
WorkflowDefinition definition = new WorkflowDefinition();
definition.setDescription("This is the description");
definition.setId("workflowdefinition");
definition.setName("My workflow definition");
WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
conversion.convert();
BpmnModel bpmnModel = conversion.getBpmnModel();
assertNotNull(bpmnModel);
Process process = bpmnModel.getMainProcess();
assertNotNull(process);
assertEquals("This is the description", process.getDocumentation());
assertEquals("My workflow definition", process.getName());
assertEquals("workflowdefinition", process.getId());
// Default start-task key should be used, as no custom startform-config is present
boolean startTaskFound = false;
for (FlowElement element : process.getFlowElements()) {
if (element instanceof StartEvent) {
assertEquals("bpm:startTask", ((StartEvent) element).getFormKey());
startTaskFound = true;
}
}
assertTrue(startTaskFound);
// Check presence of content-model
M2Model contentModel = AlfrescoConversionUtil.getContentModel(conversion);
assertNotNull(contentModel);
// Check presence of form-config and default workflow-details
Module module = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
assertNotNull(module);
assertEquals(1L, module.getConfigurations().size());
Configuration config = module.getConfigurations().get(0);
assertEquals(1L, config.getForms().size());
assertEquals("activiti$workflowdefinition", config.getCondition());
assertEquals(AlfrescoConversionConstants.EVALUATOR_STRING_COMPARE, config.getEvaluator());
}
use of org.activiti.workflow.simple.alfresco.model.config.Configuration in project Activiti by Activiti.
the class AlfrescoHumanStepDefinitionConverter method convertStepDefinition.
@Override
public UserTask convertStepDefinition(StepDefinition stepDefinition, WorkflowDefinitionConversion conversion) {
HumanStepDefinition humanStep = (HumanStepDefinition) stepDefinition;
validate(humanStep);
M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
M2Namespace modelNamespace = model.getNamespaces().get(0);
// Let superclass handle BPMN-specific conversion
UserTask userTask = super.convertStepDefinition(stepDefinition, conversion);
// Clear form-properties in the BPMN file, as we use custom form-mapping in Alfresco
userTask.getFormProperties().clear();
userTask.setName(humanStep.getName() != null ? humanStep.getName() : humanStep.getId());
// Create the content model for the task
M2Type type = new M2Type();
model.getTypes().add(type);
type.setName(AlfrescoConversionUtil.getQualifiedName(modelNamespace.getPrefix(), humanStep.getId()));
type.setParentName(AlfrescoConversionConstants.DEFAULT_BASE_FORM_TYPE);
// Update task-key on the task itself
userTask.setFormKey(type.getName());
// Create a form-config for the task
Module shareModule = AlfrescoConversionUtil.getExtension(conversion).getModules().get(0);
Configuration configuration = shareModule.addConfiguration(AlfrescoConversionConstants.EVALUATOR_TASK_TYPE, type.getName());
Form formConfig = configuration.createForm();
// Populate model and form based on FormDefinition
formCreator.createForm(type, formConfig, humanStep.getForm(), conversion);
// Set up property sharing using task-listeners
addPropertySharing(humanStep, conversion, userTask);
// is created
if (humanStep.getAssignmentType() == HumanStepAssignmentType.USER) {
String assignee = humanStep.getAssignment().getAssignee();
if (assignee != null && PropertyReference.isPropertyReference(assignee)) {
PropertyReference reference = PropertyReference.createReference(assignee);
AlfrescoConversionUtil.getPropertyReferences(conversion).add(reference);
userTask.setAssignee(reference.getUsernameReferenceExpression(modelNamespace.getPrefix()));
}
} else if (humanStep.getAssignmentType() == HumanStepAssignmentType.USERS) {
if (humanStep.getAssignment().getCandidateUsers() != null) {
userTask.setCandidateUsers(resolveUserPropertyReferences(humanStep.getAssignment().getCandidateUsers(), modelNamespace.getPrefix(), conversion));
}
} else if (humanStep.getAssignmentType() == HumanStepAssignmentType.GROUPS) {
if (humanStep.getAssignment().getCandidateGroups() != null) {
userTask.setCandidateGroups(resolveGroupPropertyReferences(humanStep.getAssignment().getCandidateGroups(), modelNamespace.getPrefix(), conversion));
}
}
return userTask;
}
Aggregations