How to get a list of typed value for an option in Apache common cli - apache-commons-cli

I am trying to get a Long[] from the option. Here is my option definition:
option optUId = Option.builder("u").
hasArg().type(Number.class).valueSeparator(',').
numberOfArgs(500).desc("User ID").build();
It can take a comma separate user list.
If I use getParsedOptionValue, it only returns the first one option value.
If I use getOptionValues, it returns a String[]. Is there a way to get a Long[] back?

Apache Commons-CLI does not support this as it cannot know how you would convert more complex types of Object, you will need to convert the String[] to Long[] in your code.

Related

Using the toInteger function with locale and format parameters

I've got a dataflow with a csv file as source. The column NewPositive is a string and it contains numbers formatted in European style with a dot as thousand seperator e.g 1.019 meaning 1019
If I use the function toInteger to convert my NewPositive column to an int via toInteger(NewPositive,'#.###','de'), I only get the thousand cipher e.g 1 for 1.019 and not the rest. Why? For testing I tried creating a constant column: toInteger('1.019','#.###','de') and it gives 1019 as expected. So why does the function not work for my column? The column is trimmed and if I compare the first value with equality function: equals('1.019',NewPositive) returns true.
Please note: I know it's very easy to create a workaround by toInteger(replace(NewPositive,'.','')), but I want to learn how to use the toInteger function with the locale and format parameters.
Here is sample data:
Dato;NewPositive
2021-08-20;1.234
2021-08-21;1.789
I was able to repro this and probably looks to be a bug to me . I have reported this to the ADF team , will let you know once I hear back from them . You already have a work around please go ahead that to unblock yourself .

Using Mitmproxy proxy to display flows containing defined string

I'm searching for a way to filter out flows to only those, which contain defined string (or one of set of strings).
For an example...
I have set of strings teststring1, teststring2, teststring3 and I would like to see only requests/responses containing one of those strings.
Any idea how to do it in Mitmproxy?
You can set a flow filter (for example by pressing f) and then specify a filter pattern:
https://docs.mitmproxy.org/stable/concepts-filters/
Try this:
("teststring1" & "teststring2" & "teststring3")

mirth connect Database Reader automatic column mapping

Please could somebody confirm the following..
I am using Mirth Connect 3.5.08232.
My Source Connector is a Database Reader.
Say, I am using a query that returns multiple rows, and return the result (via JavaScript), as documentation suggests, so that Mirth would treat each row as a separate message. I also use a couple of mappers as source transformers, and save the mapped fields in my channel map (which ends up to contain only those fields that I define in transformers)
In the destination, and specifically, in destination response transformer (or destination body, if it is a JavaScript writer), how do I access the source fields?
the only way I found by trial and error is
var rawMsg = connectorMessage.getRawData();
var xmlMsg = new XML(rawMsg);
logger.info(xmlMsg.some_field); // ignore the root element of rawMsg
Is this the right way to do this? I thought that maybe the fields that were nicely automatically detected would be put in some kind of a map, like sourceMap - but that doesn't seem to be the case, right?
Thank you
If you are using Mapper steps in your transformer to extract the data and put it into a variable map (like the channel map), then you can use any of the following methods to retrieve it from a subsequent JavaScript context (including a JavaScript Writer, and your response transformer):
var value = channelMap.get('key');
var value = $c('key');
var value = $('key');
Look at the Variable Maps section of the User Guide for more information.
So to recap, say you're selecting a column "mycolumn" with a Database Reader. The XML sent to the channel will be something like this:
<result>
<mycolumn>value</mycolumn>
</result>
Then you can choose to extract pieces of that message into specific variables for later use. The transformer allows you to easily drag-and-drop pieces of the sample inbound message.
Finally in your JavaScript Writer (or in any subsequent filter, transformer, or response transformer), just drag the value into the field you want:
And the corresponding JavaScript code will automatically be inserted:
One last note, if you are selecting a lot of variables and don't want to make Mapper steps for each one individually, you can use a JavaScript Step to iterate through the message and extract each column into a separate map variable:
for each (child in msg.children()) {
channelMap.put(child.localName(), child.toString());
}
Or, you can just reference the columns directly from within the JavaScript Writer:
var msg = new XML(connectorMessage.getEncodedData());
var column1 = msg.column1.toString();
var column2 = msg.column2.toString();
...

Parameter field with multiple values not working

Setup a Parameter field with multiple values to be used in a SQL query command and it does not work when more than one value is selected, but works fine with one value selected. And yes, the "Allow multiple values" flag is set to True under Options.
I am trying to go from this:
EMPBNFIT.BENEFITPLAN in ('CONSUMER CHOICE','HMO', 'HS HMO','HS NETWORK CHOICE','HS PPO BASIC NH RPN','HS PPO PLUS NH RPN','MFS CONSUMER CHOICE','NETWORK CHOICE','PPO BASIC NH RPN','PPO PLUS NH RPN','WAIVE MEDICAL')
to this:
WHERE EMPBNFIT.BENEFITPLAN in ('{?MyPlans}')
What a coincidence; had the same problem this morning. I was able to make a workaround in Crystal by converting the array of multiple parameters into a single string, then replacing the IN section with an INSTR comparison.
Make a formula called ParamFix with this logic:
REPLACE(JOIN({?MyPlans}, ","), "&", "; ")
In my case, the different values were separated by an &, but you can replace that based on what comes back from the tables. Then replace the IN comparison with:
INSTR({#ParamFix}, EMPBNFIT.BENEFITPLAN) > 0

Parse setting explicit type using REST

I know you can set a Date field explicitly like so:
"date_brewed":{
"__type":"Date",
"iso":"2009-10-15T00:00:00.000Z"
}
But is there anyway to explicitly set the column type of 'Number' using REST? For instance, I'd like to set the column 'batch_size' to a Number instead of a string but when POST'ing via rest it keeps getting created as a string type column.
Meh, this was more of a Perl issue than a Parse issue.
What I had to do to tell Perl to treat the number like an actual number was to add a zero to the value. :/