Search in sources :

Example 1 with SimpleWorkflowException

use of org.activiti.workflow.simple.exception.SimpleWorkflowException in project Activiti by Activiti.

the class PropertyReference method validate.

public void validate(M2Model model) {
    String namespacePrefix = model.getNamespaces().get(0).getPrefix();
    boolean valid = false;
    if (propertyName.contains(":")) {
        // Already prefixed. Check if we import that namespace...
        for (M2Namespace imported : model.getImports()) {
            if (propertyName.startsWith(imported.getPrefix())) {
                valid = true;
                break;
            }
        }
        if (!valid && !propertyName.startsWith(AlfrescoConversionConstants.WORKFLOW_NAMESPACE.getPrefix()) && !propertyName.startsWith(AlfrescoConversionConstants.BPM_NAMESPACE.getPrefix())) {
            throw new SimpleWorkflowException("Property reference: " + this.getPlaceholder() + " references a property for a namespace that is not imported in the BPM-model");
        } else {
            valid = true;
        }
    }
    if (!valid && !model.isContainedInModel(getQualifiedName(namespacePrefix))) {
        throw new SimpleWorkflowException("Property reference: " + this.getPlaceholder() + " does not reference an existing property.");
    }
}
Also used : M2Namespace(org.activiti.workflow.simple.alfresco.model.M2Namespace) SimpleWorkflowException(org.activiti.workflow.simple.exception.SimpleWorkflowException)

Example 2 with SimpleWorkflowException

use of org.activiti.workflow.simple.exception.SimpleWorkflowException in project Activiti by Activiti.

the class WorkflowDefinitionConversion method convert.

/**
   * Call this method to actually execute the conversion of the {@link WorkflowDefinition}
   * which was provided in the constructor.
   */
public void convert() {
    if (workflowDefinition == null) {
        throw new SimpleWorkflowException("Cannot start conversion: need to set a WorkflowDefinition first!");
    }
    this.incrementalIdMapping = new HashMap<String, Integer>();
    this.additionalArtifacts = new HashMap<String, Object>();
    // Create new process
    bpmnModel = new BpmnModel();
    process = new Process();
    bpmnModel.addProcess(process);
    // Let conversion listeners know initialization is finished
    if (conversionFactory.getAllWorkflowDefinitionConversionListeners() != null) {
        for (WorkflowDefinitionConversionListener conversionListener : conversionFactory.getAllWorkflowDefinitionConversionListeners()) {
            conversionListener.beforeStepsConversion(this);
        }
    }
    // Convert each step
    convertSteps(workflowDefinition.getSteps());
    // Let conversion listeners know step conversion is done
    if (conversionFactory.getAllWorkflowDefinitionConversionListeners() != null) {
        for (WorkflowDefinitionConversionListener conversionListener : conversionFactory.getAllWorkflowDefinitionConversionListeners()) {
            conversionListener.afterStepsConversion(this);
        }
    }
    // Add DI information to bpmn model
    BpmnAutoLayout bpmnAutoLayout = new BpmnAutoLayout(bpmnModel);
    bpmnAutoLayout.execute();
}
Also used : WorkflowDefinitionConversionListener(org.activiti.workflow.simple.converter.listener.WorkflowDefinitionConversionListener) BpmnAutoLayout(org.activiti.bpmn.BpmnAutoLayout) Process(org.activiti.bpmn.model.Process) SimpleWorkflowException(org.activiti.workflow.simple.exception.SimpleWorkflowException) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 3 with SimpleWorkflowException

use of org.activiti.workflow.simple.exception.SimpleWorkflowException in project Activiti by Activiti.

the class AlfrescoTransitionsPropertyDefinition method setValues.

@Override
public void setValues(FormPropertyDefinition otherDefinition) {
    if (!(otherDefinition instanceof AlfrescoTransitionsPropertyDefinition)) {
        throw new SimpleWorkflowException("An instance of AlfrescoTransitionProperty is required to set values");
    }
    AlfrescoTransitionsPropertyDefinition propDef = (AlfrescoTransitionsPropertyDefinition) otherDefinition;
    setName(propDef.getName());
    setMandatory(propDef.isMandatory());
    setWritable(propDef.isWritable());
    // Copy the entries from the other definition
    if (entries == null) {
        entries = new ArrayList<ListPropertyEntry>();
    } else {
        entries.clear();
    }
    if (propDef.getTransitions() != null) {
        ListPropertyEntry newEntry = null;
        for (ListPropertyEntry entry : propDef.getTransitions()) {
            newEntry = new ListPropertyEntry(entry.getValue(), entry.getName());
            entries.add(newEntry);
        }
    }
    if (otherDefinition.getParameters() != null) {
        setParameters(new HashMap<String, Object>(otherDefinition.getParameters()));
    }
}
Also used : ListPropertyEntry(org.activiti.workflow.simple.definition.form.ListPropertyEntry) SimpleWorkflowException(org.activiti.workflow.simple.exception.SimpleWorkflowException)

Aggregations

SimpleWorkflowException (org.activiti.workflow.simple.exception.SimpleWorkflowException)3 BpmnAutoLayout (org.activiti.bpmn.BpmnAutoLayout)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 Process (org.activiti.bpmn.model.Process)1 M2Namespace (org.activiti.workflow.simple.alfresco.model.M2Namespace)1 WorkflowDefinitionConversionListener (org.activiti.workflow.simple.converter.listener.WorkflowDefinitionConversionListener)1 ListPropertyEntry (org.activiti.workflow.simple.definition.form.ListPropertyEntry)1