public static void writeItemDefinitions(BpmnModel model, XMLStreamWriter xtw) throws Exception {
    for (ItemDefinition itemDef : model.getItemDefinitions().values()) {
      xtw.writeStartElement(ELEMENT_ITEM_DEFINITION);
      if (StringUtils.isNotEmpty(itemDef.getId())) {
        xtw.writeAttribute(ATTRIBUTE_ID, itemDef.getId());
      }
      if (StringUtils.isNotEmpty(itemDef.getItemKind())) {
        xtw.writeAttribute(ATTRIBUTE_ITEM_KIND, itemDef.getItemKind());
      }
      if (StringUtils.isNotEmpty(itemDef.getStructureRef())) {
        xtw.writeAttribute(ATTRIBUTE_STRUCTURE_REF, itemDef.getStructureRef());
      }
      xtw.writeAttribute(ATTRIBUTE_ISCOLLECTION, String.valueOf(itemDef.isCollection()));

      xtw.writeEndElement();
    }
  }
Example #2
0
  protected void createItemDefinitions() {
    for (org.activiti.bpmn.model.ItemDefinition itemDefinitionElement :
        bpmnModel.getItemDefinitions().values()) {
      StructureDefinition structure = null;

      try {
        // it is a class
        Class<?> classStructure = ReflectUtil.loadClass(itemDefinitionElement.getStructureRef());
        structure = new ClassStructureDefinition(classStructure);
      } catch (ActivitiException e) {
        // it is a reference to a different structure
        structure = this.structures.get(itemDefinitionElement.getStructureRef());
      }

      ItemDefinition itemDefinition = new ItemDefinition(itemDefinitionElement.getId(), structure);
      if (StringUtils.isNotEmpty(itemDefinitionElement.getItemKind())) {
        itemDefinition.setItemKind(ItemKind.valueOf(itemDefinitionElement.getItemKind()));
      }
      itemDefinitions.put(itemDefinition.getId(), itemDefinition);
    }
  }