Search in sources :

Example 21 with ObjectModel

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

the class ProcessServiceWithEntitiesTest method prepare.

@Before
public void prepare() {
    configureServices();
    logger.debug("Preparing kjar");
    KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
    List<String> processes = new ArrayList<String>();
    processes.add("repo/processes/general/entityprocessvar-process.bpmn2");
    DeploymentDescriptorImpl customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
    List<String> remotableClasses = java.util.Arrays.asList("example.CaseDetail", "org.drools.persistence.jpa.marshaller.MappedVariable");
    customDescriptor.setClasses(remotableClasses);
    List<ObjectModel> marshallingStrategies = new ArrayList<ObjectModel>();
    marshallingStrategies.add(new ObjectModel("mvel", "new org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy(\"org.jbpm.test:test-module:1.0.0-SNAPSHOT\", classLoader)"));
    customDescriptor.setMarshallingStrategies(marshallingStrategies);
    Map<String, String> extraResources = new HashMap<>();
    extraResources.put(CASEDETAIL_JAVA, getCaseDetailEntitySource());
    extraResources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
    extraResources.put("src/main/resources/META-INF/persistence.xml", getPersistenceXml());
    InternalKieModule kJar1 = createKieJar(ks, releaseId, processes, extraResources);
    File pom = new File("target/kmodule", "pom.xml");
    pom.getParentFile().mkdir();
    try {
        FileOutputStream fs = new FileOutputStream(pom);
        fs.write(getPom(releaseId).getBytes());
        fs.close();
    } catch (Exception e) {
    }
    KieMavenRepository repository = getKieMavenRepository();
    repository.deployArtifact(releaseId, kJar1, pom);
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) LazyInitializationException(org.hibernate.LazyInitializationException) FileOutputStream(java.io.FileOutputStream) KieMavenRepository.getKieMavenRepository(org.kie.scanner.KieMavenRepository.getKieMavenRepository) KieMavenRepository(org.kie.scanner.KieMavenRepository) File(java.io.File) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) Before(org.junit.Before)

Example 22 with ObjectModel

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

the class RuntimeDataServiceImplSecurityTest method prepare.

@Before
public void prepare() {
    configureServices();
    logger.debug("Preparing kjar");
    KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
    List<String> processes = new ArrayList<String>();
    processes.add("repo/processes/general/EmptyHumanTask.bpmn");
    processes.add("repo/processes/general/humanTask.bpmn");
    processes.add("repo/processes/general/BPMN2-UserTask.bpmn2");
    processes.add("repo/processes/general/timer-process.bpmn2");
    DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
    customDescriptor.getBuilder().addEventListener(new ObjectModel("mvel", "org.jbpm.kie.test.util.CountDownListenerFactory.get(\"securityTest\", \"timer\", 1)")).addRequiredRole("view:managers").addRequiredRole("execute:employees");
    Map<String, String> resources = new HashMap<String, String>();
    resources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
    InternalKieModule kJar1 = createKieJar(ks, releaseId, processes, resources);
    File pom = new File("target/kmodule", "pom.xml");
    pom.getParentFile().mkdir();
    try {
        FileOutputStream fs = new FileOutputStream(pom);
        fs.write(getPom(releaseId).getBytes());
        fs.close();
    } catch (Exception e) {
    }
    KieMavenRepository repository = getKieMavenRepository();
    repository.deployArtifact(releaseId, kJar1, pom);
    assertNotNull(deploymentService);
    deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    assertNotNull(processService);
    identityProvider.setRoles(Arrays.asList("employees"));
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) HashMap(java.util.HashMap) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) ArrayList(java.util.ArrayList) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) FileOutputStream(java.io.FileOutputStream) KieMavenRepository.getKieMavenRepository(org.kie.scanner.KieMavenRepository.getKieMavenRepository) KieMavenRepository(org.kie.scanner.KieMavenRepository) File(java.io.File) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) Before(org.junit.Before)

Example 23 with ObjectModel

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

the class AbstractKieServicesBaseTest method createKieJar.

protected InternalKieModule createKieJar(KieServices ks, ReleaseId releaseId, List<String> resources, Map<String, String> extraResources) {
    KieFileSystem kfs = createKieFileSystemWithKProject(ks);
    kfs.writePomXML(getPom(releaseId));
    if (createDescriptor()) {
        DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
        DeploymentDescriptorBuilder ddBuilder = customDescriptor.getBuilder();
        for (ObjectModel listener : getProcessListeners()) {
            ddBuilder.addEventListener(listener);
        }
        for (ObjectModel listener : getTaskListeners()) {
            ddBuilder.addTaskEventListener(listener);
        }
        if (extraResources == null) {
            extraResources = new HashMap<String, String>();
        }
        extraResources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
    }
    for (String resource : resources) {
        kfs.write("src/main/resources/KBase-test/" + resource, ResourceFactory.newClassPathResource(resource));
    }
    if (extraResources != null) {
        for (Map.Entry<String, String> entry : extraResources.entrySet()) {
            kfs.write(entry.getKey(), ResourceFactory.newByteArrayResource(entry.getValue().getBytes()));
        }
    }
    kfs.write("src/main/resources/forms/DefaultProcess.ftl", ResourceFactory.newClassPathResource("repo/globals/forms/DefaultProcess.ftl"));
    kfs.write("src/main/resources/forms/DefaultProcess.form", ResourceFactory.newClassPathResource("repo/globals/forms/DefaultProcess.form"));
    kfs.write("src/main/resources/forms/DefaultProcess.frm", ResourceFactory.newClassPathResource("repo/globals/forms/DefaultProcess.frm"));
    KieBuilder kieBuilder = ks.newKieBuilder(kfs);
    if (!kieBuilder.buildAll().getResults().getMessages().isEmpty()) {
        for (Message message : kieBuilder.buildAll().getResults().getMessages()) {
            logger.error("Error Message: ({}) {}", message.getPath(), message.getText());
        }
        throw new RuntimeException("There are errors builing the package, please check your knowledge assets!");
    }
    return (InternalKieModule) kieBuilder.getKieModule();
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel) KieFileSystem(org.kie.api.builder.KieFileSystem) Message(org.kie.api.builder.Message) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) DeploymentDescriptorBuilder(org.kie.internal.runtime.conf.DeploymentDescriptorBuilder) KieBuilder(org.kie.api.builder.KieBuilder) Map(java.util.Map) HashMap(java.util.HashMap) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule)

Example 24 with ObjectModel

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

the class ProcessInstanceAdminServiceImplTest method getProcessListeners.

/*
     * Helper methods 
     */
@Override
protected List<ObjectModel> getProcessListeners() {
    List<ObjectModel> listeners = super.getProcessListeners();
    listeners.add(new ObjectModel("mvel", "org.jbpm.kie.test.util.CountDownListenerFactory.get(\"processAdminService\", \"timer\", 1)"));
    return listeners;
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel)

Example 25 with ObjectModel

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

the class UserTaskAdminServiceImplTest method getTaskListeners.

/*
     * Helper methods 
     */
@Override
protected List<ObjectModel> getTaskListeners() {
    List<ObjectModel> listeners = super.getTaskListeners();
    listeners.add(new ObjectModel("mvel", "org.jbpm.kie.test.util.CountDownListenerFactory.getTask(\"userTaskAdminService\", 1)"));
    return listeners;
}
Also used : ObjectModel(org.kie.internal.runtime.conf.ObjectModel)

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