use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.
the class UserTaskJsonConverter method getExtensionElementValue.
protected String getExtensionElementValue(String name, UserTask userTask) {
String value = "";
if (CollectionUtils.isNotEmpty(userTask.getExtensionElements().get(name))) {
ExtensionElement extensionElement = userTask.getExtensionElements().get(name).get(0);
value = extensionElement.getElementText();
}
return value;
}
use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.
the class SequenceFlowJsonConverter method addExtensionElement.
protected void addExtensionElement(String name, String value, SequenceFlow flow) {
ExtensionElement extensionElement = new ExtensionElement();
extensionElement.setNamespace(NAMESPACE);
extensionElement.setNamespacePrefix("modeler");
extensionElement.setName(name);
extensionElement.setElementText(value);
flow.addExtensionElement(extensionElement);
}
use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.
the class BpmnXMLUtil method parseChildElements.
public static void parseChildElements(String elementName, BaseElement parentElement, XMLStreamReader xtr, Map<String, BaseChildElementParser> childParsers, BpmnModel model) throws Exception {
Map<String, BaseChildElementParser> localParserMap = new HashMap<String, BaseChildElementParser>(genericChildParserMap);
if (childParsers != null) {
localParserMap.putAll(childParsers);
}
boolean inExtensionElements = false;
boolean readyWithChildElements = false;
while (readyWithChildElements == false && xtr.hasNext()) {
xtr.next();
if (xtr.isStartElement()) {
if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
inExtensionElements = true;
} else if (localParserMap.containsKey(xtr.getLocalName())) {
BaseChildElementParser childParser = localParserMap.get(xtr.getLocalName());
//if we're into an extension element but the current element is not accepted by this parentElement then is read as a custom extension element
if (inExtensionElements && !childParser.accepts(parentElement)) {
ExtensionElement extensionElement = BpmnXMLUtil.parseExtensionElement(xtr);
parentElement.addExtensionElement(extensionElement);
continue;
}
localParserMap.get(xtr.getLocalName()).parseChildElement(xtr, parentElement, model);
} else if (inExtensionElements) {
ExtensionElement extensionElement = BpmnXMLUtil.parseExtensionElement(xtr);
parentElement.addExtensionElement(extensionElement);
}
} else if (xtr.isEndElement()) {
if (ELEMENT_EXTENSIONS.equals(xtr.getLocalName())) {
inExtensionElements = false;
} else if (elementName.equalsIgnoreCase(xtr.getLocalName())) {
readyWithChildElements = true;
}
}
}
}
use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.
the class BpmnXMLUtil method writeExtensionElements.
public static boolean writeExtensionElements(BaseElement baseElement, boolean didWriteExtensionStartElement, Map<String, String> namespaceMap, XMLStreamWriter xtw) throws Exception {
if (!baseElement.getExtensionElements().isEmpty()) {
if (didWriteExtensionStartElement == false) {
xtw.writeStartElement(ELEMENT_EXTENSIONS);
didWriteExtensionStartElement = true;
}
if (namespaceMap == null) {
namespaceMap = new HashMap<String, String>();
}
for (List<ExtensionElement> extensionElements : baseElement.getExtensionElements().values()) {
for (ExtensionElement extensionElement : extensionElements) {
writeExtensionElement(extensionElement, namespaceMap, xtw);
}
}
}
return didWriteExtensionStartElement;
}
use of org.activiti.bpmn.model.ExtensionElement in project Activiti by Activiti.
the class ValuedDataObjectXMLConverter method convertXMLToElement.
@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
ValuedDataObject dataObject = null;
ItemDefinition itemSubjectRef = new ItemDefinition();
String structureRef = xtr.getAttributeValue(null, ATTRIBUTE_DATA_ITEM_REF);
if (StringUtils.isNotEmpty(structureRef) && structureRef.contains(":")) {
String dataType = structureRef.substring(structureRef.indexOf(':') + 1);
if (dataType.equals("string")) {
dataObject = new StringDataObject();
} else if (dataType.equals("int")) {
dataObject = new IntegerDataObject();
} else if (dataType.equals("long")) {
dataObject = new LongDataObject();
} else if (dataType.equals("double")) {
dataObject = new DoubleDataObject();
} else if (dataType.equals("boolean")) {
dataObject = new BooleanDataObject();
} else if (dataType.equals("datetime")) {
dataObject = new DateDataObject();
} else {
LOGGER.error("Error converting {}, invalid data type: " + dataType, xtr.getAttributeValue(null, ATTRIBUTE_DATA_NAME));
}
} else {
// use String as default type
dataObject = new StringDataObject();
structureRef = "xsd:string";
}
if (dataObject != null) {
dataObject.setId(xtr.getAttributeValue(null, ATTRIBUTE_DATA_ID));
dataObject.setName(xtr.getAttributeValue(null, ATTRIBUTE_DATA_NAME));
BpmnXMLUtil.addXMLLocation(dataObject, xtr);
itemSubjectRef.setStructureRef(structureRef);
dataObject.setItemSubjectRef(itemSubjectRef);
parseChildElements(getXMLElementName(), dataObject, model, xtr);
List<ExtensionElement> valuesElement = dataObject.getExtensionElements().get("value");
if (valuesElement != null && !valuesElement.isEmpty()) {
ExtensionElement valueElement = valuesElement.get(0);
if (StringUtils.isNotEmpty(valueElement.getElementText())) {
if (dataObject instanceof DateDataObject) {
try {
dataObject.setValue(sdf.parse(valueElement.getElementText()));
} catch (Exception e) {
LOGGER.error("Error converting {}", dataObject.getName(), e.getMessage());
}
} else {
dataObject.setValue(valueElement.getElementText());
}
}
// remove value element
dataObject.getExtensionElements().remove("value");
}
}
return dataObject;
}
Aggregations