use of org.drools.compiler.kie.builder.impl.InternalKieModule 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();
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImplTest method prepare.
@Before
public void prepare() {
configureServices();
logger.debug("Preparing kjar");
KieServices ks = KieServices.Factory.get();
// version 1 of kjar
ReleaseId releaseId = ks.newReleaseId(ADMIN_GROUP_ID, ADMIN_ARTIFACT_ID, ADMIN_VERSION_V1);
List<String> processes = new ArrayList<String>();
processes.add("repo/processes/general/humanTask.bpmn");
processes.add("repo/processes/general/BPMN2-IntermediateCatchEventTimerDuration.bpmn2");
processes.add("repo/processes/errors/BPMN2-BrokenScriptTask.bpmn2");
processes.add("repo/processes/errors/BPMN2-UserTaskWithRollback.bpmn2");
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
File pom = new File("target/admin", "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.installArtifact(releaseId, kJar1, pom);
processAdminService = new ProcessInstanceAdminServiceImpl();
((ProcessInstanceAdminServiceImpl) processAdminService).setProcessService(processService);
((ProcessInstanceAdminServiceImpl) processAdminService).setRuntimeDataService(runtimeDataService);
((ProcessInstanceAdminServiceImpl) processAdminService).setCommandService(new TransactionalCommandService(emf));
((ProcessInstanceAdminServiceImpl) processAdminService).setIdentityProvider(identityProvider);
// now let's deploy to runtime both kjars
deploymentUnit = new KModuleDeploymentUnit(ADMIN_GROUP_ID, ADMIN_ARTIFACT_ID, ADMIN_VERSION_V1);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class ProcessInstanceMigrationServiceImplTest method prepare.
@Before
public void prepare() {
configureServices();
logger.debug("Preparing kjar");
KieServices ks = KieServices.Factory.get();
// version 1 of kjar
ReleaseId releaseId = ks.newReleaseId(MIGRATION_GROUP_ID, MIGRATION_ARTIFACT_ID, MIGRATION_VERSION_V1);
List<String> processes = new ArrayList<String>();
processes.add("migration/v1/AddTaskAfterActive-v1.bpmn2");
processes.add("migration/v1/RemoveActiveTask-v1.bpmn2");
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
File pom = new File("target/migration-v1", "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.installArtifact(releaseId, kJar1, pom);
// version 2 of kjar
ReleaseId releaseId2 = ks.newReleaseId(MIGRATION_GROUP_ID, MIGRATION_ARTIFACT_ID, MIGRATION_VERSION_V2);
processes = new ArrayList<String>();
processes.add("migration/v2/AddTaskAfterActive-v2.bpmn2");
processes.add("migration/v2/RemoveActiveTask-v2.bpmn2");
InternalKieModule kJar2 = createKieJar(ks, releaseId2, processes);
File pom2 = new File("target/migration-v2", "pom.xml");
pom2.getParentFile().mkdirs();
try {
FileOutputStream fs = new FileOutputStream(pom2);
fs.write(getPom(releaseId2).getBytes());
fs.close();
} catch (Exception e) {
}
repository = getKieMavenRepository();
repository.installArtifact(releaseId2, kJar2, pom2);
migrationService = new ProcessInstanceMigrationServiceImpl();
// now let's deploy to runtime both kjars
deploymentUnitV1 = new KModuleDeploymentUnit(MIGRATION_GROUP_ID, MIGRATION_ARTIFACT_ID, MIGRATION_VERSION_V1);
deploymentService.deploy(deploymentUnitV1);
units.add(deploymentUnitV1);
deploymentUnitV2 = new KModuleDeploymentUnit(MIGRATION_GROUP_ID, MIGRATION_ARTIFACT_ID, MIGRATION_VERSION_V2);
deploymentService.deploy(deploymentUnitV2);
units.add(deploymentUnitV2);
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class UserTaskAdminServiceImplTest method prepare.
@Before
public void prepare() {
configureServices();
logger.debug("Preparing kjar");
KieServices ks = KieServices.Factory.get();
// version 1 of kjar
ReleaseId releaseId = ks.newReleaseId(ADMIN_GROUP_ID, ADMIN_ARTIFACT_ID, ADMIN_VERSION_V1);
List<String> processes = new ArrayList<String>();
processes.add("repo/processes/general/humanTask.bpmn");
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
File pom = new File("target/admin", "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.installArtifact(releaseId, kJar1, pom);
userTaskAdminService = new UserTaskAdminServiceImpl();
((UserTaskAdminServiceImpl) userTaskAdminService).setUserTaskService(userTaskService);
((UserTaskAdminServiceImpl) userTaskAdminService).setRuntimeDataService(runtimeDataService);
((UserTaskAdminServiceImpl) userTaskAdminService).setIdentityProvider(identityProvider);
((UserTaskAdminServiceImpl) userTaskAdminService).setCommandService(new TransactionalCommandService(emf));
// now let's deploy to runtime both kjars
deploymentUnit = new KModuleDeploymentUnit(ADMIN_GROUP_ID, ADMIN_ARTIFACT_ID, ADMIN_VERSION_V1);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
// set user to administrator so it will be allowed to do operations
identityProvider.setName("Administrator");
identityProvider.setRoles(Collections.singletonList(""));
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project jbpm by kiegroup.
the class DeactivateDeploymentServiceWithSyncTest method prepare.
@Before
public void prepare() {
configureServices();
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/customtask.bpmn");
processes.add("repo/processes/general/humanTask.bpmn");
processes.add("repo/processes/general/signal.bpmn");
processes.add("repo/processes/general/import.bpmn");
processes.add("repo/processes/general/callactivity.bpmn");
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes);
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);
ReleaseId releaseIdSupport = ks.newReleaseId(GROUP_ID, "support", VERSION);
List<String> processesSupport = new ArrayList<String>();
processesSupport.add("repo/processes/support/support.bpmn");
InternalKieModule kJar2 = createKieJar(ks, releaseIdSupport, processesSupport);
File pom2 = new File("target/kmodule2", "pom.xml");
pom2.getParentFile().mkdir();
try {
FileOutputStream fs = new FileOutputStream(pom2);
fs.write(getPom(releaseIdSupport).getBytes());
fs.close();
} catch (Exception e) {
}
repository.deployArtifact(releaseIdSupport, kJar2, pom2);
configureDeploymentSync();
}
Aggregations