use of org.activiti.workflow.simple.alfresco.model.M2Model in project Activiti by Activiti.
the class AlfrescoReferencePropertyConverter method addAssociation.
protected void addAssociation(Form form, String formSet, ReferencePropertyDefinition referenceDefinition, M2Type contentType, WorkflowDefinitionConversion conversion) {
M2Model model = AlfrescoConversionUtil.getContentModel(conversion);
// Check if model contains an aspect for the property
String propertyName = getPropertyName(referenceDefinition, conversion);
M2ClassAssociation association = new M2ClassAssociation();
association.setName(propertyName);
association.setTitle(referenceDefinition.getName());
M2AssociationSource source = new M2AssociationSource();
source.setMany(false);
source.setMandatory(true);
M2AssociationTarget target = new M2AssociationTarget();
target.setClassName(referenceDefinition.getType());
target.setMandatory(referenceDefinition.isMandatory());
// Determine whether or not it's allowed to select multiple targets
boolean isTargetMany = extractBooleanFromParameters(referenceDefinition.getParameters(), AlfrescoConversionConstants.PARAMETER_REFERENCE_MANY, false);
target.setMany(isTargetMany);
association.setTarget(target);
association.setSource(source);
M2Aspect aspect = model.getAspect(propertyName);
if (aspect != null) {
if (aspect.getAssociations().isEmpty()) {
aspect.getAssociations().add(association);
}
contentType.getMandatoryAspects().add(propertyName);
} else {
contentType.getAssociations().add(association);
}
// Add field to form
form.getFormFieldVisibility().addShowFieldElement(propertyName);
FormField field = new FormField();
form.getFormAppearance().addFormAppearanceElement(field);
field.setId(propertyName);
field.setSet(formSet);
// of the normal document picker, starting from the default location
if (AlfrescoConversionConstants.CONTENT_TYPE_CONTENT.equals(referenceDefinition.getType())) {
FormFieldControl control = new FormFieldControl(AlfrescoConversionConstants.FORM_PACKAGE_ITEMS_TEMPLATE);
control.addControlParameter(AlfrescoConversionConstants.FORM_PACKAGE_ITEMS_PARAM_ROOTNODE, AlfrescoConversionConstants.FORM_PACKAGE_ITEMS_PARAM_ROOTNODE_DEFAULT);
field.setControl(control);
// Since we use the "package" template, we need to set the special action-parameters. This might
// impact the general package actions, but it's the bes we can do without custom coding/template
addOrAlterPackageItemActions(contentType, true, true);
}
// Wire in variable output to process, if needed
addOutputProperty(referenceDefinition, propertyName, contentType.getName(), conversion);
}
use of org.activiti.workflow.simple.alfresco.model.M2Model 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