I am using jBPM 5.3.0, but i have a problem when i try to implement LocalTaskService for Human Task.
I try this code:
org.jbpm.task.service.TaskService taskService = new org.jbpm.task.service.TaskService(getEntityManagerFactory(), SystemEventListenerFactory.getSystemEventListener());
SyncWSHumanTaskHandler syncWSHumanTaskHandler = new SyncWSHumanTaskHandler();
syncWSHumanTaskHandler.setLocal(true);
TaskService localTaskService = new LocalTaskService(taskService);
syncWSHumanTaskHandler.setClient(localTaskService);
getKnowledgeSession().getWorkItemManager().registerWorkItemHandler("Human Task", syncWSHumanTaskHandler);
But it seems that the SyncWSHumanTaskHandler is deprecated.
So i would like to know if someone implement it in the last release of jBPM and have some samples.
Thank you,
You can always find unit tests that shows the functionality:
https://github.com/droolsjbpm/jbpm/blob/master/jbpm-human-task/jbpm-human-task-core/src/test/java/org/jbpm/process/workitem/wsht/local/sync/WSHumanTaskHandlerLocalSyncTest.java
That test shows how to use the new classes. As I've already answered here:
https://community.jboss.org/message/738956
We are trying to keep all the implementation aligned with the same names for all the transports and for the async and sync implementations. The new Human Task WorkItemHandlers are called:
AbstractHTWorkItemHandler -> GenericHTWorkItemHandler & AsyncGenericHTWorkItemHandler -> Then the concrete implementation for the different transports: LocalHTWorkItemHandler, HornetQHTWorkItemHandler and Mina...
Using LocalTaskService is ok.
Cheers
Related
I want to develop a hook that will automatically merge a branch (always the same one) into the master when smth happens. This should happen because there are some strange diffs when pull requests are opened and we found out that this merging is the solution.
So I am working with the BitBucket Server API and I found the class PullRequestCreateRequest and the interface PullRequestService
This is what I got atm:
if (MYCONDITION)
{
PullRequestImpl pullRequest = new PullRequestImpl(); //class that implements PullRequestService
PullRequestCreateRequest prCreate = new PullRequestCreateRequest.Builder()
.title("Automatic Merge Branch Foo Into Master")
.description("blablabla")
.repository(request.getRepository()) //from head of the method
//.fromBranch("MyBranch") HELP pls
.toBranchId("master")
.build();
pullRequest.create(prCreate);
pullRequest.merge(prCreate);
}
My Problem is, that I don't know how to specify my source branch. I searched in the Doc, but just found some RefIds, etc.
Has someone an idea?
Btw: I create the PR first because it's not allowed to merge directly into the master and I can't change this.
Use fromRefId():
PullRequestCreateRequest prCreate = new PullRequestCreateRequest.Builder()
.title("Automatic Merge Branch Foo Into Master")
.description("blablabla")
.repository(request.getRepository())
.fromRefId("Foo") //<-- here you go
.toBranchId("master")
.build();
First, some background why I want this crazy thing. I'm building a Plugin in Jenkins that provides an API for scripts that are started from a pipeline-script to independently communicate with jenkins.
For example a shell-script can then tell jenkins to start a new stage from the running script.
I've got the communication between the script and Jenkins working, but the problem is that I now want to try and start a stage from a callback in my code but I can't seem to figure out how to do it.
Stuff I've tried and failed at:
Start a new StageStep.java
I can't seem to find a way to correctly instantiate and inject the step into the lifecycle. I've looked into DSL.java, but cant seem to get to an instance to call invokeStep(), nor was I able to find out how to instantiate DSL.java with the right environment.
Look at StageStepExecution.java and do what it does.
It seems to either invoke the body with an Environment Variable and nothing else, or set some actions and save the state in a config file when it has no body. I could not find out how the Pipeline: Stage View Plugin hooks into this, but it doesn't seem to read the config file. I've tried setting the Actions (even the inner class through reflection) but that did not seem to do anything.
Inject a custom string as Groovy body and call it with csc.newBodyInvoker()
A hacky solution I came up with was just generating the groovy script and running it like the ParallelStep does. But the sandbox does not allow me to call new GroovyShell().evaluate(""), and If I approve that call, the 'stage' step throws a MissingMethodException. So I also do not instatiate the script with the right environment. Providing the EnvironmentExpander does not make any difference.
Referencing and modifying workflow/{n}.xml
Changing the name of a stage in the relevant workflow/{n}.xml and rebooting the server updates the name of the stage, but modifying my custom stage to look like a regular one does not seem to add the step as a stage.
Stuff I've researched:
If some other plugin does something like this, but I couldn't find any example of plugins starting other steps.
How Jenkins handles the scripts and starts the steps, but It seems as though every step is directly called through the method name after the script is parsed, and I found no way to hook into this.
Other plugins using the StageView through other methods, but I could not find any.
add an AtomNode as a head onto the running thread, but I couldn't find how to replace/add the head and am hesitant to mess with jenkins' threading.
I've spent multiple days on this seemingly trivial call, but I can't seem to figure it out.
So the latest thing I tried actually worked, and is displayed correctly, but it ain't pretty.
I basically reimplemented the implementation of DSL.invokeStep(), which required me to use reflection A LOT. This is not safe, and will break with any changes of course so I'll open an issue in the Jenkins' ticket system in the hopes they will add a public interface for doing this. I'm just hoping this won't give me any weird side-effects.
// First, get some environment stuff
CpsThread cpsThread = CpsThread.current();
CpsFlowExecution currentFlowExecution = (CpsFlowExecution) getContext().get(FlowExecution.class);
// instantiate the stage's descriptor
StageStep.DescriptorImpl stageStepDescriptor = new StageStep.DescriptorImpl();
// now we need to put a new FlowNode as the head of the step-stack. This is of course not possible directly,
// but everything is also outside of the sandbox, so putting the class in the same package doesn't work
// get the 'head' field
Field cpsHeadField = CpsThread.class.getDeclaredField("head");
cpsHeadField.setAccessible(true);
Object headValue = cpsHeadField.get(cpsThread);
// get it's value
Method head_get = headValue.getClass().getDeclaredMethod("get");
head_get.setAccessible(true);
FlowNode currentHead = (FlowNode) head_get.invoke(headValue);
// crate a new StepAtomNode starting at the current value of 'head'.
FlowNode an = new StepAtomNode(currentFlowExecution, stageStepDescriptor, currentHead);
// now set this as the new head.
Method head_setNewHead = headValue.getClass().getDeclaredMethod("setNewHead", FlowNode.class);
head_setNewHead.setAccessible(true);
head_setNewHead.invoke(headValue, an);
// Create a new CpsStepContext, and as the constructor is protected, use reflection again
Constructor<?> declaredConstructor = CpsStepContext.class.getDeclaredConstructors()[0];
declaredConstructor.setAccessible(true);
CpsStepContext context = (CpsStepContext) declaredConstructor.newInstance(stageStepDescriptor,cpsThread,currentFlowExecution.getOwner(),an,null);
stageStepDescriptor.checkContextAvailability(context); // Good to check stuff I guess
// Create a new instance of the step, passing in arguments as a Map
Map<String, Object> stageArguments = new HashMap<>();
stageArguments.put("name", "mynutest");
Step stageStep = stageStepDescriptor.newInstance(stageArguments);
// so start the damd thing
StepExecution execution = stageStep.start(context);
// now that we have a callable instance, we set the step on the Cps Thread. Reflection to the rescue
Method mSetStep = cpsThread.getClass().getDeclaredMethod("setStep", StepExecution.class);
mSetStep.setAccessible(true);
mSetStep.invoke(cpsThread, execution);
// Finally. Start running the step
execution.start();
Can Somebody let me know how to use elasticsearch in vertx for java.I have used eventbus but i couldn't able to get it done. New to Vertx. Any help will be appreciated.
I have tried it this way. Index name is movies. Index_type is movie. And ID is 1. I want to delete this record.Using Default Configuration.
JsonObject delete = new JsonObject();
delete.put("action", "delete");
delete.put("_index", "movies");
delete.put("_type", "movie");
delete.put("_id", "1");
vertx.createHttpServer().requestHandler(req -> {
vertx.eventBus().send("et.vertx.elasticsearch", delete);
})listen(8080);
Check this out, it's a vertx service for Elasticsearch...that should get
you going.
https://github.com/englishtown/vertx-elasticsearch-service
This repo is tasted with elastic search 6.1. Originally Forked from ef-labs/vertx-elasticsearch-service but diverged a lot since then. It will good to get started with ES with Vert.x:
https://github.com/hubrick/vertx-elasticsearch-service
I've already been retrieved details of a specific AS/400 job by its job number. I have a problem. I want to get that specific jobs thread detail. Some jobs have multi threading. I need to get specific job's list of multi threads and thread details. I'm checked jt400 doc for finding some class for it. But I'm failing to find :(
Thank in Advance!
JobList jobList = new JobList(System);
jobList.clearJobSelectionCriteria();
jobList.addJobSelectionCriteria(JobList.SELECTION_JOB_NUMBER, jobNumber);
Enumeration list = jobList.getJobs();
while (list.hasMoreElements()) {
Job j = (Job) list.nextElement();
System.out.println(j.getName());
System.out.println(j.getStatus());
System.out.println(j.getOutputQueue());
}
The API you're looking for is QWCOLTHD. JTOpen 8.1 was recently released and I don't see the QWCOLTHD API implemented.
It looks like you either need to email the developers and ask for this API, or write the implementation yourself. JTOpen is open source; you can get the source code and see how similar APIs are implemented and then write the appropriate classes for QWCOLTHD.
I would like to know how to create outlook "Task Request" in java.
Here is another Java lib: http://moonrug.com/
I have used an earlier version of this API in my previous job. It is a commercial product.
Trying to code purely from memory and looking at the examples provided by the Moyosoft website. I have no means to compile or execute this. But you will get an idea on how to proceed
Outlook outlookApplication = new Outlook();
// Get the Task folder where the task has to be created
OutlookFolder taskFolder= outlookApplication.getDefaultFolder(FolderType.TASKS);
//Creating a new Task
OutlookTask task = new OutlookTask (taskFolder);
task.setSubject("New Java Task"); //Name of the Task
task.setStart(new Date()); // creating task with current server time
task.setStatus(TaskStatus.NOT_STARTED); //task has not yet started
task.setOwner("owner's_email#example.com"); // I don't whether this is name or email.
task.setReminderTime(new Date()) //set a reminder time, set appropriately
task.setDueDate(new Date()); //deadline for the task completion, set appropriately
// and so one.
The following APIs should help you.
http://www.moyosoft.com/joc/javadocplus/?docclass=com.moyosoft.connector.ms.outlook.task.OutlookTaskRequest
http://www.moyosoft.com/joc/javadocplus/?docclass=com.moyosoft.connector.ms.outlook.task.OutlookTask
The complete java docs can be found here. It is not very well documented but the API names are self explanatory.
http://www.moyosoft.com/joc/javadocplus/
Their site also have a few code examples which was helpful in figuring it out.
I hope this is helpful. I do not have access to these APIs now, therefore I have no way to provide code examples.