Search in sources :

Example 81 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project herd by FINRAOS.

the class CheckBusinessObjectDataAvailabilityMultiplePartitionsTest method testCheckBusinessObjectDataAvailabilityMultiplePartitionsXmlAllDataAvailable.

@Test
public void testCheckBusinessObjectDataAvailabilityMultiplePartitionsXmlAllDataAvailable() throws Exception {
    // Prepare test data.
    businessObjectDataAvailabilityTestHelper.createDatabaseEntitiesForBusinessObjectDataAvailabilityTesting(null);
    // Prepare a check business object data availability request that should result in response with the all business object data being available.
    BusinessObjectDataAvailabilityRequest businessObjectDataAvailabilityRequest = businessObjectDataServiceTestHelper.getTestBusinessObjectDataAvailabilityRequest(STORAGE_1_AVAILABLE_PARTITION_VALUES);
    List<FieldExtension> fieldExtensionList = new ArrayList<>();
    fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
    fieldExtensionList.add(buildFieldExtension("businessObjectDataAvailabilityRequest", "${businessObjectDataAvailabilityRequest}"));
    List<Parameter> parameters = new ArrayList<>();
    parameters.add(buildParameter("contentType", "xml"));
    parameters.add(buildParameter("businessObjectDataAvailabilityRequest", xmlHelper.objectToXml(businessObjectDataAvailabilityRequest)));
    Map<String, Object> variableValuesToValidate = new HashMap<>();
    variableValuesToValidate.put(CheckBusinessObjectDataAvailabilityMultiplePartitions.VARIABLE_IS_ALL_DATA_AVAILABLE, true);
    variableValuesToValidate.put(BaseJavaDelegate.VARIABLE_JSON_RESPONSE, VARIABLE_VALUE_NOT_NULL);
    testActivitiServiceTaskSuccess(CheckBusinessObjectDataAvailabilityMultiplePartitions.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
Also used : BusinessObjectDataAvailabilityRequest(org.finra.herd.model.api.xml.BusinessObjectDataAvailabilityRequest) HashMap(java.util.HashMap) FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) Parameter(org.finra.herd.model.api.xml.Parameter) Test(org.junit.Test)

Example 82 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class FieldExtensionExport method writeFieldExtensions.

public static boolean writeFieldExtensions(List<FieldExtension> fieldExtensionList, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception {
    for (FieldExtension fieldExtension : fieldExtensionList) {
        if (StringUtils.isNotEmpty(fieldExtension.getFieldName())) {
            if (StringUtils.isNotEmpty(fieldExtension.getStringValue()) || StringUtils.isNotEmpty(fieldExtension.getExpression())) {
                if (!didWriteExtensionStartElement) {
                    xtw.writeStartElement(ELEMENT_EXTENSIONS);
                    didWriteExtensionStartElement = true;
                }
                xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ELEMENT_FIELD, ACTIVITI_EXTENSIONS_NAMESPACE);
                BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_FIELD_NAME, fieldExtension.getFieldName(), xtw);
                if (StringUtils.isNotEmpty(fieldExtension.getStringValue())) {
                    xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ELEMENT_FIELD_STRING, ACTIVITI_EXTENSIONS_NAMESPACE);
                    xtw.writeCData(fieldExtension.getStringValue());
                } else {
                    xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, ATTRIBUTE_FIELD_EXPRESSION, ACTIVITI_EXTENSIONS_NAMESPACE);
                    xtw.writeCData(fieldExtension.getExpression());
                }
                xtw.writeEndElement();
                xtw.writeEndElement();
            }
        }
    }
    return didWriteExtensionStartElement;
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension)

Example 83 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class FieldExtensionParser method parseChildElement.

public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
    if (!accepts(parentElement))
        return;
    FieldExtension extension = new FieldExtension();
    BpmnXMLUtil.addXMLLocation(extension, xtr);
    extension.setFieldName(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_NAME));
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_STRING))) {
        extension.setStringValue(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_STRING));
    } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_EXPRESSION))) {
        extension.setExpression(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_EXPRESSION));
    } else {
        boolean readyWithFieldExtension = false;
        try {
            while (readyWithFieldExtension == false && xtr.hasNext()) {
                xtr.next();
                if (xtr.isStartElement() && ELEMENT_FIELD_STRING.equalsIgnoreCase(xtr.getLocalName())) {
                    extension.setStringValue(xtr.getElementText().trim());
                } else if (xtr.isStartElement() && ATTRIBUTE_FIELD_EXPRESSION.equalsIgnoreCase(xtr.getLocalName())) {
                    extension.setExpression(xtr.getElementText().trim());
                } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) {
                    readyWithFieldExtension = true;
                }
            }
        } catch (Exception e) {
            LOGGER.warn("Error parsing field extension child elements", e);
        }
    }
    if (parentElement instanceof ActivitiListener) {
        ((ActivitiListener) parentElement).getFieldExtensions().add(extension);
    } else if (parentElement instanceof ServiceTask) {
        ((ServiceTask) parentElement).getFieldExtensions().add(extension);
    } else if (parentElement instanceof SendTask) {
        ((SendTask) parentElement).getFieldExtensions().add(extension);
    } else if (parentElement instanceof MessageEventDefinition) {
        ((MessageEventDefinition) parentElement).getFieldExtensions().add(extension);
    }
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) FieldExtension(org.activiti.bpmn.model.FieldExtension) SendTask(org.activiti.bpmn.model.SendTask) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 84 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class DefaultActivityBehaviorFactory method createCamelActivityBehavior.

protected ActivityBehavior createCamelActivityBehavior(TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions) {
    try {
        Class<?> theClass = null;
        FieldExtension behaviorExtension = null;
        for (FieldExtension fieldExtension : fieldExtensions) {
            if ("camelBehaviorClass".equals(fieldExtension.getFieldName()) && StringUtils.isNotEmpty(fieldExtension.getStringValue())) {
                theClass = Class.forName(fieldExtension.getStringValue());
                behaviorExtension = fieldExtension;
                break;
            }
        }
        if (behaviorExtension != null) {
            fieldExtensions.remove(behaviorExtension);
        }
        if (theClass == null) {
            // Default Camel behavior class
            theClass = Class.forName("org.activiti.camel.impl.CamelBehaviorDefaultImpl");
        }
        List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fieldExtensions);
        addExceptionMapAsFieldDeclaration(fieldDeclarations, task.getMapExceptions());
        return (ActivityBehavior) ClassDelegate.defaultInstantiateDelegate(theClass, fieldDeclarations);
    } catch (ClassNotFoundException e) {
        throw new ActivitiException("Could not find org.activiti.camel.CamelBehavior: ", e);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) FieldExtension(org.activiti.bpmn.model.FieldExtension) BoundaryTimerEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryTimerEventActivityBehavior) IntermediateCatchSignalEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchSignalEventActivityBehavior) BoundaryMessageEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryMessageEventActivityBehavior) UserTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior) ActivityBehavior(org.activiti.engine.impl.delegate.ActivityBehavior) MailActivityBehavior(org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior) IntermediateThrowNoneEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowNoneEventActivityBehavior) BoundarySignalEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundarySignalEventActivityBehavior) ManualTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ManualTaskActivityBehavior) IntermediateCatchEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBehavior) EventSubProcessErrorStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventSubProcessErrorStartEventActivityBehavior) EventBasedGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventBasedGatewayActivityBehavior) CancelEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.CancelEndEventActivityBehavior) AbstractBpmnActivityBehavior(org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior) EventSubProcessMessageStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventSubProcessMessageStartEventActivityBehavior) ParallelGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ParallelGatewayActivityBehavior) IntermediateThrowMessageEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowMessageEventActivityBehavior) BoundaryEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior) ScriptTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior) ErrorEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior) InclusiveGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.InclusiveGatewayActivityBehavior) AdhocSubProcessActivityBehavior(org.activiti.engine.impl.bpmn.behavior.AdhocSubProcessActivityBehavior) ServiceTaskDelegateExpressionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior) ServiceTaskExpressionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior) BoundaryCompensateEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryCompensateEventActivityBehavior) ReceiveTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior) CallActivityBehavior(org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior) ExclusiveGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior) TransactionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TransactionActivityBehavior) NoneStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.NoneStartEventActivityBehavior) ShellActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ShellActivityBehavior) TerminateEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior) IntermediateThrowCompensationEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowCompensationEventActivityBehavior) IntermediateThrowSignalEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowSignalEventActivityBehavior) WebServiceActivityBehavior(org.activiti.engine.impl.bpmn.behavior.WebServiceActivityBehavior) NoneEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior) IntermediateCatchTimerEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchTimerEventActivityBehavior) ThrowMessageEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ThrowMessageEndEventActivityBehavior) IntermediateCatchMessageEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchMessageEventActivityBehavior) BoundaryCancelEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryCancelEventActivityBehavior) SubProcessActivityBehavior(org.activiti.engine.impl.bpmn.behavior.SubProcessActivityBehavior) TaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TaskActivityBehavior) FieldDeclaration(org.activiti.engine.impl.bpmn.parser.FieldDeclaration)

Example 85 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class BpmnMessagePayloadMappingProviderFactory method createFieldDeclarations.

public List<FieldDeclaration> createFieldDeclarations(List<FieldExtension> fieldList, ExpressionManager expressionManager) {
    List<FieldDeclaration> fieldDeclarations = new ArrayList<FieldDeclaration>();
    for (FieldExtension fieldExtension : fieldList) {
        FieldDeclaration fieldDeclaration = null;
        if (StringUtils.isNotEmpty(fieldExtension.getExpression())) {
            fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), expressionManager.createExpression(fieldExtension.getExpression()));
        } else {
            fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), new FixedValue(fieldExtension.getStringValue()));
        }
        fieldDeclarations.add(fieldDeclaration);
    }
    return fieldDeclarations;
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) FixedValue(org.activiti.engine.impl.el.FixedValue) FieldDeclaration(org.activiti.engine.impl.bpmn.parser.FieldDeclaration)

Aggregations

FieldExtension (org.activiti.bpmn.model.FieldExtension)94 ArrayList (java.util.ArrayList)68 Test (org.junit.Test)67 Parameter (org.finra.herd.model.api.xml.Parameter)64 HashMap (java.util.HashMap)55 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)24 BusinessObjectDataAttribute (org.finra.herd.model.api.xml.BusinessObjectDataAttribute)12 Job (org.finra.herd.model.api.xml.Job)11 ServiceTask (org.activiti.bpmn.model.ServiceTask)10 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)10 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)9 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)9 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)8 FieldDeclaration (org.activiti.engine.impl.bpmn.parser.FieldDeclaration)4 BusinessObjectDataStorageUnitKey (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 FlowElement (org.activiti.bpmn.model.FlowElement)3 Attribute (org.finra.herd.model.api.xml.Attribute)3 BusinessObjectDataAttributeKeys (org.finra.herd.model.api.xml.BusinessObjectDataAttributeKeys)3