Search in sources :

Example 51 with ObjectModel

use of org.kie.internal.runtime.conf.ObjectModel in project jbpm by kiegroup.

the class MVELObjectModelResolverTest method testSimpleNoArgObjectModel.

@Test
public void testSimpleNoArgObjectModel() {
    ObjectModel model = new ObjectModel("new org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject()");
    ObjectModelResolver resolver = new MVELObjectModelResolver();
    Object result = resolver.getInstance(model, this.getClass().getClassLoader(), new HashMap<String, Object>());
    assertNotNull(result);
    assertTrue(result instanceof SimpleCustomObject);
    assertEquals("default", ((SimpleCustomObject) result).getName());
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) ObjectModelResolver(org.kie.internal.runtime.conf.ObjectModelResolver) SimpleCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject) SimpleCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject) Test(org.junit.Test)

Example 52 with ObjectModel

use of org.kie.internal.runtime.conf.ObjectModel in project jbpm by kiegroup.

the class ReflectionObjectModelResolverTest method testSimpleSingleStringArgObjectModel.

@Test
public void testSimpleSingleStringArgObjectModel() {
    ObjectModel model = new ObjectModel("org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject", new Object[] { "john" });
    ObjectModelResolver resolver = new ReflectionObjectModelResolver();
    Object result = resolver.getInstance(model, this.getClass().getClassLoader(), new HashMap<String, Object>());
    assertNotNull(result);
    assertTrue(result instanceof SimpleCustomObject);
    assertEquals("john", ((SimpleCustomObject) result).getName());
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) ObjectModelResolver(org.kie.internal.runtime.conf.ObjectModelResolver) ThirdLevelCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.ThirdLevelCustomObject) SimpleCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject) EmbedingCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.EmbedingCustomObject) SimpleCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject) Test(org.junit.Test)

Example 53 with ObjectModel

use of org.kie.internal.runtime.conf.ObjectModel in project jbpm by kiegroup.

the class ReflectionObjectModelResolverTest method testSimpleNestedObjectArgObjectModel.

@Test
public void testSimpleNestedObjectArgObjectModel() {
    ObjectModel model = new ObjectModel("org.jbpm.runtime.manager.impl.deploy.testobject.ThirdLevelCustomObject", new Object[] { new ObjectModel("org.jbpm.runtime.manager.impl.deploy.testobject.EmbedingCustomObject", new Object[] { new ObjectModel("org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject", new Object[] { "john" }), "testing object model" }) });
    ObjectModelResolver resolver = new ReflectionObjectModelResolver();
    Object result = resolver.getInstance(model, this.getClass().getClassLoader(), new HashMap<String, Object>());
    assertNotNull(result);
    assertTrue(result instanceof ThirdLevelCustomObject);
    assertEquals("testing object model", ((ThirdLevelCustomObject) result).getEmbeddedObject().getDescription());
    SimpleCustomObject customObject = ((ThirdLevelCustomObject) result).getEmbeddedObject().getCustomObject();
    assertNotNull(customObject);
    assertEquals("john", customObject.getName());
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) ThirdLevelCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.ThirdLevelCustomObject) ObjectModelResolver(org.kie.internal.runtime.conf.ObjectModelResolver) ThirdLevelCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.ThirdLevelCustomObject) SimpleCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject) EmbedingCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.EmbedingCustomObject) SimpleCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject) Test(org.junit.Test)

Example 54 with ObjectModel

use of org.kie.internal.runtime.conf.ObjectModel in project jbpm by kiegroup.

the class ReflectionObjectModelResolverTest method testSimpleContextValueObjectModel.

@Test
public void testSimpleContextValueObjectModel() {
    ObjectModel model = new ObjectModel("org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject", new Object[] { "context" });
    ObjectModelResolver resolver = new ReflectionObjectModelResolver();
    Map<String, Object> contextParam = new HashMap<String, Object>();
    contextParam.put("context", "value from the context");
    Object result = resolver.getInstance(model, this.getClass().getClassLoader(), contextParam);
    assertNotNull(result);
    assertTrue(result instanceof SimpleCustomObject);
    assertEquals("value from the context", ((SimpleCustomObject) result).getName());
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) HashMap(java.util.HashMap) ObjectModelResolver(org.kie.internal.runtime.conf.ObjectModelResolver) ThirdLevelCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.ThirdLevelCustomObject) SimpleCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject) EmbedingCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.EmbedingCustomObject) SimpleCustomObject(org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject) Test(org.junit.Test)

Example 55 with ObjectModel

use of org.kie.internal.runtime.conf.ObjectModel in project jbpm by kiegroup.

the class DeploymentDescriptorImpl method getBuilder.

@Override
public DeploymentDescriptorBuilder getBuilder() {
    return new DeploymentDescriptorBuilder() {

        private BuilderHandler handler = new BuilderHandler() {

            @Override
            public boolean accepted(Object value) {
                return true;
            }
        };

        private DeploymentDescriptorImpl descriptor = DeploymentDescriptorImpl.this;

        @Override
        public DeploymentDescriptorBuilder runtimeStrategy(RuntimeStrategy strategy) {
            if (handler.accepted(strategy)) {
                descriptor.setRuntimeStrategy(strategy);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder persistenceUnit(String pu) {
            if (handler.accepted(pu)) {
                descriptor.setPersistenceUnit(pu);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder persistenceMode(PersistenceMode mode) {
            if (handler.accepted(mode)) {
                descriptor.setPersistenceMode(mode);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder auditPersistenceUnit(String pu) {
            if (handler.accepted(pu)) {
                descriptor.setAuditPersistenceUnit(pu);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder auditMode(AuditMode mode) {
            if (handler.accepted(mode)) {
                descriptor.setAuditMode(mode);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder addWorkItemHandler(NamedObjectModel model) {
            if (handler.accepted(model)) {
                if (!descriptor.workItemHandlers.add(model)) {
                    descriptor.workItemHandlers.remove(model);
                    descriptor.workItemHandlers.add(model);
                }
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder addTaskEventListener(ObjectModel model) {
            if (handler.accepted(model)) {
                if (!descriptor.taskEventListeners.add(model)) {
                    descriptor.taskEventListeners.remove(model);
                    descriptor.taskEventListeners.add(model);
                }
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder addMarshalingStrategy(ObjectModel model) {
            if (handler.accepted(model)) {
                if (!descriptor.marshallingStrategies.add(model)) {
                    descriptor.marshallingStrategies.remove(model);
                    descriptor.marshallingStrategies.add(model);
                }
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder addGlobal(NamedObjectModel model) {
            if (handler.accepted(model)) {
                if (!descriptor.globals.add(model)) {
                    descriptor.globals.remove(model);
                    descriptor.globals.add(model);
                }
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder addEventListener(ObjectModel model) {
            if (handler.accepted(model)) {
                if (!descriptor.eventListeners.add(model)) {
                    descriptor.eventListeners.remove(model);
                    descriptor.eventListeners.add(model);
                }
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder addEnvironmentEntry(NamedObjectModel model) {
            if (handler.accepted(model)) {
                if (!descriptor.environmentEntries.add(model)) {
                    descriptor.environmentEntries.remove(model);
                    descriptor.environmentEntries.add(model);
                }
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder addConfiguration(NamedObjectModel model) {
            if (handler.accepted(model)) {
                if (!descriptor.configuration.add(model)) {
                    descriptor.configuration.remove(model);
                    descriptor.configuration.add(model);
                }
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder addRequiredRole(String role) {
            if (handler.accepted(role)) {
                descriptor.requiredRoles.add(role);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder addClass(String clazz) {
            if (handler.accepted(clazz)) {
                descriptor.classes.add(clazz);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder setConfiguration(List<NamedObjectModel> models) {
            if (handler.accepted(models)) {
                descriptor.setConfiguration(models);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder setEnvironmentEntries(List<NamedObjectModel> models) {
            if (handler.accepted(models)) {
                descriptor.setEnvironmentEntries(models);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder setWorkItemHandlers(List<NamedObjectModel> models) {
            if (handler.accepted(models)) {
                descriptor.setWorkItemHandlers(models);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder setGlobals(List<NamedObjectModel> models) {
            if (handler.accepted(models)) {
                descriptor.setGlobals(models);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder setEventListeners(List<ObjectModel> models) {
            if (handler.accepted(models)) {
                descriptor.setEventListeners(models);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder setTaskEventListeners(List<ObjectModel> models) {
            if (handler.accepted(models)) {
                descriptor.setTaskEventListeners(models);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder setMarshalingStrategies(List<ObjectModel> models) {
            if (handler.accepted(models)) {
                descriptor.setMarshallingStrategies(models);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder setRequiredRoles(List<String> roles) {
            if (handler.accepted(roles)) {
                descriptor.setRequiredRoles(roles);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder setClasses(List<String> classes) {
            if (handler.accepted(classes)) {
                descriptor.setClasses(classes);
            }
            return this;
        }

        @Override
        public DeploymentDescriptorBuilder setLimitSerializationClasses(Boolean limit) {
            if (handler.accepted(limit)) {
                descriptor.setLimitSerializationClasses(limit);
            }
            return this;
        }

        @Override
        public void setBuildHandler(BuilderHandler handler) {
            this.handler = handler;
        }

        @Override
        public DeploymentDescriptor get() {
            return descriptor;
        }
    };
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) RuntimeStrategy(org.kie.internal.runtime.conf.RuntimeStrategy) DeploymentDescriptorBuilder(org.kie.internal.runtime.conf.DeploymentDescriptorBuilder) BuilderHandler(org.kie.internal.runtime.conf.BuilderHandler) PersistenceMode(org.kie.internal.runtime.conf.PersistenceMode) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) AuditMode(org.kie.internal.runtime.conf.AuditMode) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ObjectModel (org.kie.internal.runtime.conf.ObjectModel)56 NamedObjectModel (org.kie.internal.runtime.conf.NamedObjectModel)40 Test (org.junit.Test)34 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)34 ArrayList (java.util.ArrayList)16 ObjectModelResolver (org.kie.internal.runtime.conf.ObjectModelResolver)10 HashMap (java.util.HashMap)9 SimpleCustomObject (org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject)9 DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)6 EmbedingCustomObject (org.jbpm.runtime.manager.impl.deploy.testobject.EmbedingCustomObject)6 ThirdLevelCustomObject (org.jbpm.runtime.manager.impl.deploy.testobject.ThirdLevelCustomObject)6 KieServices (org.kie.api.KieServices)6 DeploymentDescriptorBuilder (org.kie.internal.runtime.conf.DeploymentDescriptorBuilder)6 ReleaseId (org.kie.api.builder.ReleaseId)5 KieMavenRepository (org.kie.scanner.KieMavenRepository)5 File (java.io.File)4 Before (org.junit.Before)4 Cacheable (org.kie.internal.runtime.Cacheable)4