Search in sources :

Example 1 with AlfrescoSimpleWorkflowException

use of org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException in project Activiti by Activiti.

the class AlfrescoFormCreator method createForm.

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);
            }
        }
    }
    if (formDefinition != null && formDefinition.getFormPropertyDefinitions() != null && !formDefinition.getFormPropertyDefinitions().isEmpty()) {
        for (FormPropertyDefinition def : formDefinition.getFormPropertyDefinitions()) {
            if (def instanceof AlfrescoTransitionsPropertyDefinition) {
                AlfrescoFormPropertyConverter converter = propertyConverters.get(def.getClass());
                if (converter != null) {
                    converter.convertProperty(contentType, null, formConfig, def, conversion);
                }
            }
        }
    }
    // Finally, add default "transitions" if not already added to the model
    if (formConfig.getFormAppearance().getFormSet(AlfrescoConversionConstants.FORM_SET_RESPONSE) == null) {
        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);
    }
}
Also used : AlfrescoTransitionsPropertyDefinition(org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition) FormPropertyGroup(org.activiti.workflow.simple.definition.form.FormPropertyGroup) FormSet(org.activiti.workflow.simple.alfresco.model.config.FormSet) FormPropertyDefinition(org.activiti.workflow.simple.definition.form.FormPropertyDefinition) AlfrescoSimpleWorkflowException(org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException)

Example 2 with AlfrescoSimpleWorkflowException

use of org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException in project Activiti by Activiti.

the class AlfrescoReferencePropertyConverter method addFieldReference.

protected void addFieldReference(Form form, String formSet, ReferencePropertyDefinition definition, M2Type contentType, WorkflowDefinitionConversion conversion) {
    if (form.isStartForm()) {
        throw new AlfrescoSimpleWorkflowException("Field references cannot be used on start-forms");
    }
    // Check if model contains an aspect for the property
    String propertyName = getPropertyName(definition, conversion);
    // Add property-reference to the context to be validated
    PropertyReference reference = new PropertyReference(definition.getName());
    AlfrescoConversionUtil.getPropertyReferences(conversion).add(reference);
    // Add aspect to content-type
    contentType.getMandatoryAspects().add(propertyName);
    // Add read-only field to form
    form.getFormFieldVisibility().addShowFieldElement(propertyName);
    FormField field = new FormField();
    form.getFormAppearance().addFormAppearanceElement(field);
    field.setId(propertyName);
    field.setLabelId(definition.getName());
    field.setSet(formSet);
    field.setControl(new FormFieldControl(AlfrescoConversionConstants.FORM_READONLY_TEMPLATE));
}
Also used : PropertyReference(org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference) FormFieldControl(org.activiti.workflow.simple.alfresco.model.config.FormFieldControl) AlfrescoSimpleWorkflowException(org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException) FormField(org.activiti.workflow.simple.alfresco.model.config.FormField)

Example 3 with AlfrescoSimpleWorkflowException

use of org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException in project Activiti by Activiti.

the class AlfrescoArtifactExporter method exportArtifacts.

/**
	 * Export all artifacts and configuration-files needed to run the process that is converted in the given
	 * {@link WorkflowDefinitionConversion}.
	 * 
	 * @param conversion the conversion object to be exported
	 * @param repositoryFolder the folder where all repository-artifacts and configurations are exported to
	 * @param shareFolder the folder where all share-artifacts and configurations are exported to
	 */
public void exportArtifacts(WorkflowDefinitionConversion conversion, File repositoryFolder, File shareFolder, boolean asExtension) {
    validateArtifactTargets(repositoryFolder, shareFolder);
    String processId = conversion.getProcess().getId();
    try {
        // Export process BPMN
        File processFile = new File(repositoryFolder, getBpmnFileName(conversion));
        processFile.createNewFile();
        FileOutputStream processStream = new FileOutputStream(processFile);
        writeBpmnModel(processStream, conversion);
        processStream.close();
        // Export content model
        File contentModelFile = new File(repositoryFolder, getContentModelFileName(conversion));
        contentModelFile.createNewFile();
        FileOutputStream modelStream = new FileOutputStream(contentModelFile);
        writeContentModel(modelStream, conversion);
        modelStream.close();
        // Export workflow deployer context XML
        File springContextFile = new File(repositoryFolder, processId + SPRING_CONTEXT_FILE_SUFFIX);
        springContextFile.createNewFile();
        FileOutputStream springContextStream = new FileOutputStream(springContextFile);
        writeWorkflowDeployerBean(springContextStream, processId, processFile.getName(), contentModelFile.getName());
        springContextStream.close();
        // Export share config
        File shareConfigFile = new File(shareFolder, getShareConfigFileName(conversion));
        shareConfigFile.createNewFile();
        FileOutputStream shareConfigStream = new FileOutputStream(shareConfigFile);
        writeShareConfig(shareConfigStream, conversion, asExtension);
        shareConfigStream.close();
        if (asExtension) {
            File shareModuleDeploymentFile = new File(shareFolder, getShareModuleDeploymentFileName(conversion));
            shareModuleDeploymentFile.createNewFile();
            FileOutputStream shareModuleStream = new FileOutputStream(shareModuleDeploymentFile);
            writeShareExtensionModule(shareModuleStream, conversion);
            shareModuleStream.close();
        }
        // Export share custom context
        File shareContextFile = new File(shareFolder, processId + SHARE_CONTEXT_FILE_SUFFIX);
        shareContextFile.createNewFile();
        FileOutputStream shareContextStream = new FileOutputStream(shareContextFile);
        writeShareCustomConfigBean(shareContextStream, processId, shareConfigFile.getName());
        shareContextStream.close();
    } catch (IOException ioe) {
        throw new AlfrescoSimpleWorkflowException("Error while exporting artifacts", ioe);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) AlfrescoSimpleWorkflowException(org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException) IOException(java.io.IOException) File(java.io.File)

Aggregations

AlfrescoSimpleWorkflowException (org.activiti.workflow.simple.alfresco.conversion.exception.AlfrescoSimpleWorkflowException)3 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 PropertyReference (org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference)1 AlfrescoTransitionsPropertyDefinition (org.activiti.workflow.simple.alfresco.form.AlfrescoTransitionsPropertyDefinition)1 FormField (org.activiti.workflow.simple.alfresco.model.config.FormField)1 FormFieldControl (org.activiti.workflow.simple.alfresco.model.config.FormFieldControl)1 FormSet (org.activiti.workflow.simple.alfresco.model.config.FormSet)1 FormPropertyDefinition (org.activiti.workflow.simple.definition.form.FormPropertyDefinition)1 FormPropertyGroup (org.activiti.workflow.simple.definition.form.FormPropertyGroup)1