I want to create a reusable sub processes in jbpm 6, but I cant't see any processes in Called Element pop up. It doesn't load any process information. Please can anyone give me the reason for this situation?
I'm not sure I completely understand your question/issue. However, I have successfully used reusable suprosses in JBPM 6.1.0.Final and eclipse.
These are steps:
Create a resuable subprocess with and ID. Make note the ID for steps 2-5.
Drag and Drop a "Call Activity" Activity to the bpmn
Edit the properties of the "Call Activity" - click on "Call Activity" and go to eclipse properties tab.
Click on "pencil" edit icon:
Enter the reusable subprocess id in edit window and type reusable subprosses id and hit o.k.
You should be able to run you bpmn and see the execution of subprocess.
I've just hitted this error today at work, using 6.1.0.Final. If process id has underscores it will not show in workbench called activity popup. Look at the sources:
Asset<String> processContent = ServletUtil.getProcessSourceContent(p, profile);
Pattern idPattern = Pattern.compile("<\\S*process[^\"]+id=\"([^_\"]+)\"", Pattern.MULTILINE);
Matcher idMatcher = idPattern.matcher(processContent.getAssetContent());
if(idMatcher.find()) {
String pid = idMatcher.group(1);
String pidcontent = ServletUtil.getProcessImageContent(processContent.getAssetLocation(), pid, profile);
if(pid != null && !(packageName.equals(processPackage) && pid.equals(processId))) {
processInfo.put(pid+"|"+processContent.getAssetLocation(), pidcontent != null ? pidcontent : "");
}
}
That regex used to get process id will not match "_". Check that your process id is valid.
Related
Can someone tell me please how to use an assert statement in Katalon Studio?
The scenario is- I have to create one user (user=program), once I click the submit button I have to capture the result if the user is created successfully or not. If the user is created successfully, only then the execution should proceed further if not then the test case should fail and further execution should stop.
Please let me how to use assert statement in Test Case, Object repository or global variable or keywords?
In Katalon Studio, default assertions are available. Using which we can keep the validation check points. Please refer to below code where its checking for userPofileImge element. If user profile img present, assertion will be PASSED and execution will continue, or else failed and execution stops.
**Code Snippet**
assert WebUI.verifyElementVisible(findTestObject('HomePageLocators/userProfileImg')) == true : 'login failed as user profile is not present'
If you are using Groovy language with Katalon studio, this is the answer:
def x = 1
assert x == 2
// Output: // // Assertion failed: // assert x == 2 //
| | // 1 false
Groovy Language features: http://docs.groovy-lang.org/docs/latest/html/documentation/core-testing-guide.html#_introduction
Katalon Studio has significant customized assert methods. You can choose as per your requirement and control failure. In your case, when you click on Submit, user is created and probably you get alert message, notification message and or new user should be visible in user area.
So you have to identify checkpoint from above and get the property and WebUI.verify--select method with FailureHandling.STOP_ON_FAILURE.
Katalon Studio provides mutiple way to handle test failure
FailureHandling.CONTINUE_ON_FAILURE
FailureHandling.STOP_ON_FAILURE // Applicable in your case
FailureHandling.OPTIONAL
Code will be like this
WebUI.verifyElementPresent(findTestObject('User Locator'), maxWaitTime,
FailureHandling.STOP_ON_FAILURE) // use this if you want to fail further
execution
I need to execute workflow from command line that is already created using UI.
Already I have tried to invoke workflow by creating workflow instance.
the code shown below which is i was tried
XmlTextReader reader = new XmlTextReader("Workflow1.xml");
Console.WriteLine("Waiting for Workflow completion..");
WorkflowRuntime runtime = new WorkflowRuntime();
WorkflowInstance instance = runtime.CreateWorkflow(reader);
instance.Start();
but it shows the error message "xml tag is not framed well".
I have fully copied the workflow xaml content and pasted in Workflow1.xml file.
is there any other possibilities to achieve this.
Thanks in Advance.
It looks like you are using Windows Workflow 4, but you are trying to use the Windows Workflow 3 runtime to execute the workflow. I've got a white paper [1] on WF 4 that might be useful, but here's a snippet from that article that might be helpful. It uses the workflowInvoker class to execute the workflow. You can also use WorkflowApplication if you have long running workflows that need bookmarking capabilities.
Activity mathWF;
using (Stream mathXaml = File.OpenRead("Math.xaml"))
{
mathWF = ActivityXamlServices.Load(mathXaml);
}
var outputs = WorkflowInvoker.Invoke(mathWF,
new Dictionary<string, object> {
{ "operand1", 5 },
{ "operand2", 10 },
{ "operation", "add" } });
Assert.AreEqual<int>(15, (int)outputs["result"], "Incorrect result returned");
Developer's Introduction to Windows Workflow
TL;DR version:
In CQ workflows, is there a difference between what's available to the OR Split compared to the Process Step?
Is it possible to access the /history/ nodes of a workflow instance from within an OR Split?
How?!
The whole story:
I'm working on a workflow in CQ5 / AEM5.6.
In this workflow I have a custom dialog, which stores a couple of properties on the workflow instance.
The path to the property I'm having trouble with is: /workflow/instances/[this instance]/history/[workItem id]/workItem/metaData and I've called the property "reject-or-approve".
The dialog sets the property fine (via a dropdown that lets you set it to "reject" or "approve"), and I can access other properties on this node via a process step (in ecma script) using:
var actionReason;
var history = workflowSession.getHistory(workItem.getWorkflow());
// loop backwards through workItems
// and as soon as we find a Action Reason that is not empty
// store that as 'actionReason' and break.
for (var index = history.size() - 1; index >= 0; index--) {
var previous = history.get(index);
var tempActionReason = previous.getWorkItem().getMetaDataMap().get('action-message');
if ((tempActionReason != '')&&(tempActionReason != null)) {
actionReason = tempActionReason;
break;
}
}
The process step is not the problem though. Where I'm having trouble is when I try to do the same thing from inside an OR Split.
When I try the same workflowSession.getHistory(workItem.getWorkflow()) in an OR Split, it throws an error saying workItem is not defined.
I've tried storing this property on the payload instead (i.e. storing it under the page's jcr:content), and in that case the property does seem to be available to the OR Split, but my problems with that are:
This reject-or-approve property is only relevant to the current workflow instance, so storing it on the page's jcr:content doesn't really make sense. jcr:content properties will persist after the workflow is closed, and will be accessible to future workflow instances. I could work around this (i.e. don't let workflows do anything based on the property unless I'm sure this instance has written to the property already), but this doesn't feel right and is probably error-prone.
For some reason, when running through the custom dialog in my workflow, only the Admin user group seems to be able to write to the jcr:content property. When I use the dialog as any other user group (which I need to do for this workflow design), the dialog looks as though it's working, but never actually writes to the jcr:content property.
So for a couple of different reasons I'd rather keep this property local to the workflow instance instead of storing it on the page's jcr:content -- however, if anyone can think of a reason why my dialog isn't setting the property on the jcr:content when I use any group other than admin, that would give me a workaround even if it's not exactly the solution I'm looking for.
Thanks in advance if anyone can help! I know this is kind of obscure, but I've been stuck on it for ages.
a couple of days ago i ran into the same issue. The issue here is that you don't have the workItem object, because you don't really have an existing workItem. Imagine the following: you are going through the workflow, you got a couple of workItems, with means, either process step, either inbox item. When you are in an or split, you don't have existing workItems, you can ensure by visiting the /workItems node of the workflow instance. Your workaround seems to be the only way to go through this "issue".
I've solved it. It's not all that elegant looking, but it seems to be a pretty solid solution.
Here's some background:
Dialogs seem to reliably let you store properties either on:
the payload's jcr:content node (which wasn't practical for me, because the payload is locked during the workflow, and doesn't let non-admins write to its jcr:content)
the workItem/metaData for the current workflow step
However, Split steps don't have access to workItem. I found a fairly un-helpful confirmation of that here: http://blogs.adobe.com/dmcmahon/2013/03/26/cq5-failure-running-script-etcworkflowscriptscaworkitem-ecma-referenceerror-workitem-is-not-defined/
So basically the issue was, the Dialog step could store the property, but the OR Split couldn't access it.
My workaround was to add a Process step straight after the Dialog in my workflow. Process steps do have access to workItem, so they can read the property set by the Dialog. I never particularly wanted to store this data on the payload's jcr:content, so I looked for another location. It turns out the workflow metaData (at the top level of the workflow instance node, rather than workItem/metaData, which is inside the /history sub-node) is accessible to both the Process step and the OR Split. So, my Process step now reads the workItem's approveReject property (set by the Dialog), and then writes it to the workflow's metaData node. Then, the OR Split reads the property from its new location, and does its magic.
The way you access the workflow metaData from the Process step and the OR Split is not consistent, but you can get there from both.
Here's some code: (complete with comments. You're welcome)
In the dialog where you choose to approve or reject, the name of the field is set to rejectApprove. There's no ./ or anything before it. This tells it to store the property on the workItem/metaData node for the current workflow step under /history/.
Straight after the dialog, a Process step runs this:
var rejectApprove;
var history = workflowSession.getHistory(workItem.getWorkflow());
// loop backwards through workItems
// and as soon as we find a rejectApprove that is not empty
// store that as 'rejectApprove' and break.
for (var index = history.size() - 1; index >= 0; index--) {
var previous = history.get(index);
var tempRejectApprove = previous.getWorkItem().getMetaDataMap().get('rejectApprove');
if ((tempRejectApprove != '')&&(tempRejectApprove != null)) {
rejectApprove = tempRejectApprove;
break;
}
}
// steps up from the workflow step into the workflow metaData,
// and stores the rejectApprove property there
// (where it can be accessed by an OR Split)
workItem.getWorkflowData().getMetaData().put('rejectApprove', rejectApprove);
Then after the Process step, the OR Split has the following in its tabs:
function check() {
var match = 'approve';
if (workflowData.getMetaData().get('rejectApprove') == match) {
return true;
} else {
return false;
}
}
Note: use this for the tab for the "approve" path, then copy it and replace var match = 'approve' with var match = 'reject'
So the key here is that from a Process step:
workItem.getWorkflowData().getMetaData().put('rejectApprove', rejectApprove);
writes to the same property that:
workflowData.getMetaData().get('rejectApprove') reads from when you execute it in an OR Split.
To suit our business requirements, there's more to the workflow I've implemented than just this, but the method above seems to be a pretty reliable way to get values that are entered in a dialog, and access them from within an OR Split.
It seems pretty silly that the OR Split can't access the workItem directly, and I'd be interested to know if there's a less roundabout way of doing this, but for now this has solved my problem.
I really hope someone else has this same problem, and finds this useful, because it took me waaay to long to figure out, to only apply it once!
I am designing a workflow in activiti so far i have been able to design it like above.
My problem is
i start a work flow.
present user option to execute one of the two possible action(Archive and complete in diagram)
i also need to have authorization on whether he can archive or complete or both.
user can take one of these options.
based on one of the action taken workflow proceeds.
So far to achieve this i introduced user task new before complete and archive and added two form variables named archive and complete as boolean.
Depending on which form variable he chooses to fill i proceed further.
But in this case i can't restrict user based on whether it has permission of archive and complete and all users will be shown both options.
is there any other way to achieve this i am very new to activiti and workflow and bpmn in general.
Any help will be appreciated thanks in advance
1. How to presents possible transitions to user:
Set transitions directly to task and set transition id according this pattern:
<task_id>_<transition_id> that means in this case: newTask_archive and newTask_complete. Then you can read all transitions from task definition and parse the postfix from id and send to user list of possible transitions (complete, archive). Your bussines layer can remove any transition according user permissions.
// Source: http://forums.activiti.org/content/how-get-all-possible-flows-current-activity
public List<String> getPossibleTransitionIds(long processInstanceId, String taskId) {
RepositoryServiceImpl repoServiceImpl = (RepositoryServiceImpl) repositoryService;
List<String> possibleTransitionIds = new ArrayList<String>();
ReadOnlyProcessDefinition processDef = repoServiceImpl.getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
PvmActivity activity = processDef.findActivity(taskId);
for (PvmTransition pvmTransition : activity.getOutgoingTransitions()) {
String transitionId = extractTransitionId(pvmTransition);
if (transitionId != null) {
possibleTransitionIds.add(transitionId);
}
}
return possibleTransitionIds;
}
2. How to move process by selected transition:
User selects one of presented transition ids. Bussines layer checks user's permissions and move process. Set selected transition to process variables and resolve task.
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("selectedTransition", selectedTransition);
taskService.resolveTask(taskId, variableMap);
In every transition has to be set a condition expression ${selectedTransition == '<transition_id>'}. In this case ${selectedTransition == 'complete'} and ${selectedTransition == 'archive'}
<sequenceFlow id="newTask_complete" name="Complete" sourceRef="newTask" targetRef="completeTask">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${selectedTransition == 'complete'}]]></conditionExpression>
</sequenceFlow>
I writing my own text editor plugin for eclipse. I am now working on my own formatter. Actually, following that link http://wiki.eclipse.org/FAQ_How_do_I_support_formatting_in_my_editor%3F.
I have written my Strategy, I have overridden getContentFormatter in my SourceViewerConfiguration..
As I run my plugin and press Ctrl+Shift+F - and nothing happens.
I think that I'm missing a step here. Should I create a handler or something?
Thanks
Might it be you skipped the last part of the linked page?
Finally, you will need to create an action that invokes the formatter. No generic formatting action is defined by the text infrastructure, but it is quite easy to create one of your own. The action’s run method can simply call the following on the source viewer to invoke the formatter:
sourceViewer.doOperation(ISourceViewer.FORMAT);
What helped me. I have created a handler with the following executors body:
//get the editorPart
if (editorPart != null) {
ITextOperationTarget target = (ITextOperationTarget) editorPart
.getAdapter(ITextOperationTarget.class);
if (target instanceof ISourceViewer) {
ISourceViewer textViewer = (ISourceViewer) target;
((ITextOperationTarget) textViewer)
.doOperation(ISourceViewer.FORMAT);
}
}
Then just create menu items and bind them to the handler.