Example #1
0
 protected String getAppearanceForGroup(FormPropertyGroup group) {
   if (group.getTitle() != null && !group.getTitle().isEmpty()) {
     return AlfrescoConversionConstants.FORM_SET_APPEARANCE_TITLE;
   } else {
     return null;
   }
 }
Example #2
0
 protected String getTemplateForGroup(FormPropertyGroup group) {
   String template = null;
   if (group.getType() != null) {
     if (AlfrescoConversionConstants.FORM_GROUP_LAYOUT_2_COLUMNS.equals(group.getType())) {
       template = AlfrescoConversionConstants.FORM_SET_TEMPLATE_2_COLUMN;
     } else if (AlfrescoConversionConstants.FORM_GROUP_LAYOUT_3_COLUMNS.equals(group.getType())) {
       template = AlfrescoConversionConstants.FORM_SET_TEMPLATE_3_COLUMN;
     }
   }
   return template;
 }
Example #3
0
  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);
        }
      }
    }

    // Finally, add "transitions" if not already added
    // TODO: check if added once transitions are supported
    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);
  }