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);
}
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;
}
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);
}
}
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);
}
}
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;
}
Aggregations