In NiFi, I have a flow file with an attribute RSID. I need to generate a UUID v5 based on RSID and add it as an attribute to the flow file. This uuid needs to be based on RSID because some reports will have the same RSID and need to thus have the same UUID5.
I've seen some methods in Groovy that will generate a random uuid, but not v5 nor based on a string. Is this possible to do in Groovy/NiFi? If so, how would this be done? I'm very new to Groovy.
You can indeed do this with Groovy and NiFi using the ExecuteScript processor. This SO post includes the code for generating a UUID v5 which you can apply to your RSID namespace. If you want some pointers on using the NiFi API from ExecuteScript, feel free to check out my cookbook series, hopefully it will help you assemble a working solution.
I have also written a Jira to add a UUID5 function to NiFi Expression Language, to make this easier.
Related
As far as I can tell, the Terraform SDK does not support an interface type. In my case I'm using a data resource to reach out to an API and pull JSON data. I would like to put that data in an attribute for later use in a resource but the problem is the JSON response has a large dictionary filled with different types. In GoLang this is no problem because you can set the map type to Interface{}. It would seem however that terraform only allows you to set the following types in a schema:
TypeInt
TypeString
TypeBool
TypeFloat
TypeInvalid
TypeList
TypeMap
Without support for interface how would you go about doing this correctly? The very ugly hack I have right now is converting everything to a string and then fixing the type once it is passed to the resource.
I asked on Hashicorp's forums and received a phenomenal answer here.
The synopsis is that casting to a string is currently the best solution. However there is a team working on making a new SDK design which would support newer capabilities to include arguments with dynamically chosen types.
I have gone through all possible solutions online to implement data provider facility using cucumber, but all are either incomplete or not working. Can anyone please suggest a working solution to read data from an external source such as an excel or CSV? How is it used in the step defs and feature file?
Exact code might be difficult to share at the moment. But following approach should work for you. Cucumber has Interface called as Transformer which you need to implement. THe transformer implementation should be accepted as step definitions arguments. E.g.,
#Given("your text <regex>")
public void someMethod(TransformerImpl transformerImpl) {
//your code goes here
}
The TranformerImpl is the implementation of Transformer interface. In that interface you will implement the logic of taking the csv file path or name and read its content and pass its data to the step definition as argument.
Let me know if this helps.
So I was tasked to create a java client to communicate with java card.
Right now I can authenticate, write and read data using javax.smartcardio but having a bit of trouble trying to upload cap file and install it.
So after googling around, I found that I can use gpj as a library and use it in my java application to upload and install the cap file.
The problem is I can't find any documentation for gpj and I can't understand the code without one.
Here's one that I have trouble to understand public void installAndMakeSelecatable(AID paramAID1, AID paramAID2, AID paramAID3, byte paramByte, byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
Even when I look on the other part of the code, I can't find out the last parameter since all that use these method will pass null.
So if anyone know where can I find the documentation, I would be really glad. Or better yet, another library that can upload cap file and have some documentation with it.
so far, I've found gpj,jpcsc,jcManager and opal.
Nevermind, it seems that I'm not a clever guy.
For future reference, you can find out what to pass to what method by looking through the main method of the Global Platform Services class. For parameter that you are not sure what to pass, just use null.
In my current work, I have written code generator using String Template without thinking about Parser ( I am instantiating Template files using direct Java Object). and code generator generator generates nice Java code.
Now, I have started to write Parser. B'coz of some nice editor features of xText, I am thinking to write parser in Xtext.
My question is "Is it possible to use code generator ( written using StringTemplate ) and Parse (written in Xtext) in same project?
Yes that's possible. Xtext offers a typed AST for the parsed files and you could easily pass them to your code generator (directly, iff they fulfil the same contract / interfaces, or indirectly by transforming them to the expected structure). Xtext does not impose any constraints on how you want to use the parsed information.
I have developed a groovy application. Now it has been required
that for feeding the DB a CSV interface must be provided.
That is, I have to load a csv file, parse it and
insert records into the DB in a transactional way.
The question is if there exists for groovy something
like ostermiller utils (a configurable csv parser).
Thanks in advance,
Luis
Kelly Robinson just wrote a nice blog post about the different possibilities that are available to work with CSV files in Groovy.
Groovy and Java are interoperable. Take a look at the documentation for mixed Java and Groovy applications. Any Java class can easily be used in Groovy with no change (plus you have the groovy syntax). If you are interested in the ostermiller utils to do your CSV parsing, you can use it directly from Groovy.
If the ostermiller library does what you want you can call it directly from Groovy. Just put the necessary jars in your groovy\lib directory and you should be ready to go.