Changing Map parameters in Drools Flow - drools

Am a beginner in drools flow and Jbpm 5. I want to pass in some parameter in map and i need certain script tasks to alter that parameter. How do i do it?

In an action script you can do something like:
kcontext.setVariable("name", value);
For example, if you have a variable i:
kcontext.setVariable("i", i + "Changed");
Note that you probably should define your variable as a process variable to be able to do this. Click on the background of your process and in the Properties view, edit the "variables" property to add a new process property with a given name and type.
For more documentation, see:
http://docs.jboss.org/jbpm/v5.2/userguide/ch05.html#sec.data
Kris

Related

Anylogic: Declare parameter of type ArrayList

I'm building a class (sorry - Agent) that will work with a set of Tank objects (Fluid Library) - doing things like monitoring individual levels or total level of all tanks, reporting on levels and initiating actions based on levels - things of that nature. For argument's sake let's call it a "TankMonitor" agent.
Ideally I'd like to be able to define a Parameter in my "TankMonitor" agent that allows me to define the tanks of interest when I place a TankMonitor in main. I have tried to define the type of the parameter as Other - ArrayList<Tank> however I don't know how to set up the next step to allow me to populate the ArrayList of Tanks when I put an instance of this agent in main. My preference would be to have a list type control to populate the ArrayList - much like the way the AnyLogic Seize block allows you to specify multiple resource pools to choose from.
Has anyone attempted this before and been successful?
This is possible as follows:
Change the type to "Other" and then 'Tank[]' , i.e. an Array of Tanks
Change the control type to "one-dimensional array"
Example below. Now you have the same UI to pre-define tanks at design time for your agent instance.
In addition to Benjamin's perfect answer, I'd just add the manual workaround, which is not needed here but can be useful when the parameter in question has a more complicated structure than covered by the pre-made controls, say a list of lists, a map, or similar.
In such a case, the Control Type is still Text, and populating it in an instance happens by pointing it to a new object of the parameter's type. E.g. for an ArrayList<Tank> parameter, you might instantiate a new ArrayList object, which you fill with a list of objects like so:
new ArrayList<Tank>(Arrays.asList(tankA, tankB))
In the Java code, whatever is written into that text box will end up on the right side of a parameter assignment statement in the embedded Agent instance's auto-generated parameter setup function. Therefore, multi-statement code won't work in this spot. Instead, if the process of building the parameter value doesn't fit neatly into a single expression, you can hide the code in a function which returns the desired object, and call that from the parameter's text box.

Validating the Workflow in Design Time

At the beginning, let me confess that I am totally new to Workflow Foundation. I am trying to write one custom activity, let's say we call it GoTo. This activity has a property called TargetActivityName (of type string). The TargetActivityName specifies the name (or DisplayName) of another activity present in the workflow. Now, I need to validate that the activity name is valid, that is, whenever the someone designs a workflow with the GoTo activity and specifies the TargetActivityName, the workflow should validate that an activity of that name is present.
Any ways to achieve this? I am not rehosting it, just using Visual Studio.
Thanks,
Jeevan
If you need all the activities present in a assembly you can check
C#: List All Classes in Assembly
and then use that list to get compare your string with fullName.

Is there a way to change the eclipse template variable tab order?

I'd like to create a code template in eclipse and specify where the user can type in the variable name if there are multiple instances of the same variable, because the code completion is not available at the first instance.
This example is written in Progress ABL, as the variable name is defined before the variable type in this case, but it's not really language related if something like that is possible within the scope of templates in eclipse.
Example:
define buffer bTablename for Tablename.
Template:
define buffer b${tablename} for ${tablename}.
But I want to start writing at the second ${tablename}, is there a way to change the "tab order" or something to accomplish that?
The JFace template language doesn't allow to specify a tab order for the template variables.
You would need to either write your own extension for the template completion or contribute changes to Eclipse that introduce that functionality.

Powershell: Hiding second function parameter when first is already defined

I'm trying to implement API of our product using Powershell. E.g., I'd like to create a function Remove-OurProductEntity. This function should have both -ById and -ByFullPath parameters to know which entity to delete. They shouldn't be both mandatory, but only one of them.
If user specified one of them in the command line, the second mustn't appear in autocompletion and Powershell shouldn't ask user to define the second. Moreover, if user specified both, function should ask to define the only one.
Is it possible to be done in Powershell? Or I should handle all the logic inside the function?
Powershell has really COOL language, and guess, something similar should be.
Parameter sets are your friend.
http://blogs.msdn.com/b/powershell/archive/2008/12/23/powershell-v2-parametersets.aspx

PowerShell InitializeDefaultDrive

In my custom powershell provider I want the user to be able to skip the internal call to InitializeDefaultDrives.
The InitializeDefaultDrives method is called when the provider starts. I guess this is when I use the Add-SnapIn cmdlet to load my provider. So it looks like i'm searching for a way to add dynamic parameters to to the Add-SnapIn cmdlet.
I know i can just skip the implementation of InitializeDefaultDrives and have the user use new-PsDrive to add the drive manually if desired. That is not want I want. I want to always create a default drive except in the case where the user wants to skip this.
Thanks!
AFAIK dynamic parameters only work when you control the source code i.e. in your code you can choose to expose a dynamic parameter based on the value of another parameter (like a path). Then your code does something different based on the value of the dynamic parameter. However, you should be able to accomplish what you want via a session preference variable.
$SuppressDriveInit = $true
Add-PSSnapin Acme
If the variable is not definied or is set to false, then go ahead and initialize the drive. It is low tech but should work fine.