Search in sources :

Example 1 with StructureDefinition

use of org.activiti.engine.impl.bpmn.data.StructureDefinition in project Activiti by Activiti.

the class BpmnParse method createItemDefinitions.

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);
    }
}
Also used : ClassStructureDefinition(org.activiti.engine.impl.bpmn.data.ClassStructureDefinition) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) ClassStructureDefinition(org.activiti.engine.impl.bpmn.data.ClassStructureDefinition) ActivitiException(org.activiti.engine.ActivitiException) ItemDefinition(org.activiti.engine.impl.bpmn.data.ItemDefinition)

Example 2 with StructureDefinition

use of org.activiti.engine.impl.bpmn.data.StructureDefinition in project Activiti by Activiti.

the class WSDLImporterTest method testImportCounterWithImport.

@Test
public void testImportCounterWithImport() throws Exception {
    URL url = ReflectUtil.getResource("org/activiti/engine/impl/webservice/counterWithImport.wsdl");
    importer.importFrom(url.toString());
    List<WSService> services = new ArrayList<WSService>(importer.getServices());
    assertEquals(1, services.size());
    WSService service = services.get(0);
    assertEquals("Counter", service.getName());
    assertEquals("http://localhost:63081/webservicemock", service.getLocation());
    List<StructureDefinition> structures = sortStructures();
    List<WSOperation> operations = sortOperations();
    assertEquals(7, operations.size());
    this.assertOperation(operations.get(0), "getCount", service);
    this.assertOperation(operations.get(1), "inc", service);
    this.assertOperation(operations.get(2), "noNameResult", service);
    this.assertOperation(operations.get(3), "prettyPrintCount", service);
    this.assertOperation(operations.get(4), "reservedWordAsName", service);
    this.assertOperation(operations.get(5), "reset", service);
    this.assertOperation(operations.get(6), "setTo", service);
    assertEquals(14, structures.size());
    this.assertStructure(structures.get(0), "getCount", new String[] {}, new Class<?>[] {});
    this.assertStructure(structures.get(1), "getCountResponse", new String[] { "count" }, new Class<?>[] { Integer.class });
    this.assertStructure(structures.get(2), "inc", new String[] {}, new Class<?>[] {});
    this.assertStructure(structures.get(3), "incResponse", new String[] {}, new Class<?>[] {});
    this.assertStructure(structures.get(4), "noNameResult", new String[] { "prefix", "suffix" }, new Class<?>[] { String.class, String.class });
    this.assertStructure(structures.get(5), "noNameResultResponse", new String[] { "return" }, new Class<?>[] { String.class });
    this.assertStructure(structures.get(6), "prettyPrintCount", new String[] { "prefix", "suffix" }, new Class<?>[] { String.class, String.class });
    this.assertStructure(structures.get(7), "prettyPrintCountResponse", new String[] { "prettyPrint" }, new Class<?>[] { String.class });
    this.assertStructure(structures.get(8), "reservedWordAsName", new String[] { "prefix", "suffix" }, new Class<?>[] { String.class, String.class });
    this.assertStructure(structures.get(9), "reservedWordAsNameResponse", new String[] { "static" }, new Class<?>[] { String.class });
    this.assertStructure(structures.get(10), "reset", new String[] {}, new Class<?>[] {});
    this.assertStructure(structures.get(11), "resetResponse", new String[] {}, new Class<?>[] {});
    this.assertStructure(structures.get(12), "setTo", new String[] { "value" }, new Class<?>[] { Integer.class });
    this.assertStructure(structures.get(13), "setToResponse", new String[] {}, new Class<?>[] {});
}
Also used : SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) ArrayList(java.util.ArrayList) URL(java.net.URL) Test(org.junit.Test)

Example 3 with StructureDefinition

use of org.activiti.engine.impl.bpmn.data.StructureDefinition in project Activiti by Activiti.

the class WSDLImporterTest method testImportInheritedElement.

@Test
public void testImportInheritedElement() throws Exception {
    URL url = ReflectUtil.getResource("org/activiti/engine/impl/webservice/inherited-elements-in-types.wsdl");
    assertNotNull(url);
    importer.importFrom(url.toString());
    List<StructureDefinition> structures = sortStructures();
    assertEquals(1, structures.size());
    final Object structureTypeInst = ReflectUtil.instantiate("org.activiti.webservice.counter.StructureType");
    final Class<? extends Object> structureType = structureTypeInst.getClass();
    this.assertStructure(structures.get(0), "inheritedRequest", new String[] { "rootElt", "inheritedElt", "newSimpleElt", "newStructuredElt" }, new Class<?>[] { Short.class, Integer.class, String.class, structureType });
    assertEquals(2, structureType.getDeclaredFields().length);
    assertNotNull(structureType.getDeclaredField("booleanElt"));
    assertNotNull(structureType.getDeclaredField("dateElt"));
    assertEquals(1, structureType.getSuperclass().getDeclaredFields().length);
    assertNotNull(structureType.getSuperclass().getDeclaredField("rootElt"));
}
Also used : SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) URL(java.net.URL) Test(org.junit.Test)

Example 4 with StructureDefinition

use of org.activiti.engine.impl.bpmn.data.StructureDefinition in project Activiti by Activiti.

the class WSDLImporterTest method testImportCounter.

@Test
public void testImportCounter() throws Exception {
    URL url = ReflectUtil.getResource("org/activiti/engine/impl/webservice/counter.wsdl");
    importer.importFrom(url.toString());
    List<WSService> services = new ArrayList<WSService>(importer.getServices());
    assertEquals(1, services.size());
    WSService service = services.get(0);
    assertEquals("Counter", service.getName());
    assertEquals("http://localhost:63081/webservicemock", service.getLocation());
    List<StructureDefinition> structures = sortStructures();
    List<WSOperation> operations = sortOperations();
    assertEquals(7, operations.size());
    this.assertOperation(operations.get(0), "getCount", service);
    this.assertOperation(operations.get(1), "inc", service);
    this.assertOperation(operations.get(2), "noNameResult", service);
    this.assertOperation(operations.get(3), "prettyPrintCount", service);
    this.assertOperation(operations.get(4), "reservedWordAsName", service);
    this.assertOperation(operations.get(5), "reset", service);
    this.assertOperation(operations.get(6), "setTo", service);
    assertEquals(14, structures.size());
    this.assertStructure(structures.get(0), "getCount", new String[] {}, new Class<?>[] {});
    this.assertStructure(structures.get(1), "getCountResponse", new String[] { "count" }, new Class<?>[] { Integer.class });
    this.assertStructure(structures.get(2), "inc", new String[] {}, new Class<?>[] {});
    this.assertStructure(structures.get(3), "incResponse", new String[] {}, new Class<?>[] {});
    this.assertStructure(structures.get(4), "noNameResult", new String[] { "prefix", "suffix" }, new Class<?>[] { String.class, String.class });
    this.assertStructure(structures.get(5), "noNameResultResponse", new String[] { "return" }, new Class<?>[] { String.class });
    this.assertStructure(structures.get(6), "prettyPrintCount", new String[] { "prefix", "suffix" }, new Class<?>[] { String.class, String.class });
    this.assertStructure(structures.get(7), "prettyPrintCountResponse", new String[] { "prettyPrint" }, new Class<?>[] { String.class });
    this.assertStructure(structures.get(8), "reservedWordAsName", new String[] { "prefix", "suffix" }, new Class<?>[] { String.class, String.class });
    this.assertStructure(structures.get(9), "reservedWordAsNameResponse", new String[] { "static" }, new Class<?>[] { String.class });
    this.assertStructure(structures.get(10), "reset", new String[] {}, new Class<?>[] {});
    this.assertStructure(structures.get(11), "resetResponse", new String[] {}, new Class<?>[] {});
    this.assertStructure(structures.get(12), "setTo", new String[] { "value" }, new Class<?>[] { Integer.class });
    this.assertStructure(structures.get(13), "setToResponse", new String[] {}, new Class<?>[] {});
}
Also used : SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) ArrayList(java.util.ArrayList) URL(java.net.URL) Test(org.junit.Test)

Example 5 with StructureDefinition

use of org.activiti.engine.impl.bpmn.data.StructureDefinition in project Activiti by Activiti.

the class CxfWSDLImporter method importStructure.

protected void importStructure(Mapping mapping) {
    QName qname = mapping.getElement();
    final JType type = mapping.getType().getTypeClass();
    if (type.isPrimitive()) {
        final Class<?> primitiveClass = ReflectUtil.loadClass(type.boxify().fullName());
        final StructureDefinition structure = new PrimitiveStructureDefinition(this.namespace + qname.getLocalPart(), primitiveClass);
        this.structures.put(structure.getId(), structure);
    } else if (type instanceof JDefinedClass) {
        JDefinedClass theClass = (JDefinedClass) type;
        SimpleStructureDefinition structure = new SimpleStructureDefinition(this.namespace + qname.getLocalPart());
        this.structures.put(structure.getId(), structure);
        importFields(theClass, structure);
    } else {
        final Class<?> referencedClass = ReflectUtil.loadClass(type.fullName());
        final StructureDefinition structure = new PrimitiveStructureDefinition(this.namespace + qname.getLocalPart(), referencedClass);
        this.structures.put(structure.getId(), structure);
    }
}
Also used : StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) PrimitiveStructureDefinition(org.activiti.engine.impl.bpmn.data.PrimitiveStructureDefinition) JDefinedClass(com.sun.codemodel.JDefinedClass) SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) QName(javax.xml.namespace.QName) PrimitiveStructureDefinition(org.activiti.engine.impl.bpmn.data.PrimitiveStructureDefinition) JDefinedClass(com.sun.codemodel.JDefinedClass) JClass(com.sun.codemodel.JClass) JType(com.sun.codemodel.JType)

Aggregations

StructureDefinition (org.activiti.engine.impl.bpmn.data.StructureDefinition)5 SimpleStructureDefinition (org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition)4 URL (java.net.URL)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 JClass (com.sun.codemodel.JClass)1 JDefinedClass (com.sun.codemodel.JDefinedClass)1 JType (com.sun.codemodel.JType)1 QName (javax.xml.namespace.QName)1 ActivitiException (org.activiti.engine.ActivitiException)1 ClassStructureDefinition (org.activiti.engine.impl.bpmn.data.ClassStructureDefinition)1 ItemDefinition (org.activiti.engine.impl.bpmn.data.ItemDefinition)1 PrimitiveStructureDefinition (org.activiti.engine.impl.bpmn.data.PrimitiveStructureDefinition)1