use of org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference in project Activiti by Activiti.
the class InitializeAlfrescoModelsConversionListener method beforeStepsConversion.
@Override
public void beforeStepsConversion(WorkflowDefinitionConversion conversion) {
String processId = null;
if (conversion.getWorkflowDefinition().getId() != null) {
processId = AlfrescoConversionUtil.getValidIdString(conversion.getWorkflowDefinition().getId());
} else {
processId = generateUniqueProcessId(conversion);
}
M2Model model = addContentModel(conversion, processId);
addExtension(conversion, processId);
// In case the same property definitions are used across multiple forms, we need to identify this
// up-front and create an aspect for this that can be shared due to the fact that you cannot define the same
// property twice in a the same content-model namespace
addAspectsForReusedProperties(conversion.getWorkflowDefinition(), model, processId);
// Add list of property references
conversion.setArtifact(ARTIFACT_PROPERTY_REFERENCES, new ArrayList<PropertyReference>());
}
use of org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference 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