In this tutorial, we shall learn some of the ways of how to convert a string value to a double value with examples. Some of them are using Double.parseDouble(), Double.valueOf(), new Double(). You can typecast or convert a String to Double in Java in many ways. Read contents of a File line by line using Stream.Read contents of a file line by line using BufferedReader.Replace multiple spaces with single space.Get character at specific index in string.Check if string contains search substring.Check if string starts with specific prefix.Check if string ends with specific suffix.Get index of nth occurrence of substring.Get index of the first Occurrence of substring.So I spend a lot of time working my way through the simple stuff figuring out what works. (53 instead of 5 )ĭef numVal2 = inputMap.get("Value2") as Integer Īs you can guess, I'm not a java/groovy developer either. Which did not give you the error trying to cast, but it didn't return the correct result. Int numVal2 = (Integer)inputMap.get("Value2") This intrigued me, so I fiddled around some more. That's what I mean by breaking it down and brute forcing it. Int numVal1 = inputMap.get("Value1") as int Okay - I'm going to pick the first because it seems simplest and try (with no quotes inside the input value): Int intNum = new Integer(stringNum).intValue() I find several suggested ways of doing it: Now I start googling groovy cast string to int. ReturnMap.put("Total",(int)inputMap.get("Value1")) Īnd we get the error even on something that simple. ReturnMap.put("Total",inputMap.get("Value1")) Start by commenting everything out except for a line like this: It's a brute force method where you strip you line down to the simplest it can be so you can see what it does and then build up the pieces again. that json object contains child fields that I couldn't figure out how to get to in the GUI, so resorted to learning and then implementing a very flexible groovy script that calls the jsonslurper library. Today I learned how to use groovy and jsonslurper to pull specific json objects out of an orchestrator input, where one of the inputs coming in from an external system is simply of type "object". Using this specific need to do simple math as an excuse to dig a bit into and learn groovy scripting will hopefully open your eyes to the possibilities. It's very very very modern in concept and for those of us who have traditionally worked on 10-20 year old software (XE, formscape, even world) and interfaces to have supermodern toys like this with an entire community of developers having contributed to the body of knowledge easily found via google, it's a bit of a dream come true. I wish it was some other language than Groovy but at least they picked an open standard language and didn't create some proprietary scripting language.Ĭlick to expand.I think I get what you're saying, but I think that with not too much effort it's possible to start to see the possibilities afforded to us by having Orchestrator implement a widely used scripting language. You can always build BSFNs to do calculations and other logic or write a web service in some other language/tool and call it (the two methods we have used at our organization) or as others have pointed out it does give you the option to write code in Groovy. I have only worked with Orchestrator a little bit so I am very far from being a SME on it and I certainly have some issues with it but from the little that I have seen I think it gives you quite a bit of options and ways to do things so I am not sure I would call it "primitive". We have ported some of those Business Services to Orchestrator and by having all the logic in BSFNs it was a very easy port. I didn't write a bunch of business logic / calculations in Java, I used Business Services as thin wrappers to BSFNs and it worked well. This was the approach I used with Business Services. I have not done much with Groovy so maybe I will change my opinion once I have, but personally I think it is best to keep as much business logic and calculations OUT of Orchestrator, put that in BSFNs (you will get reuse from that in other places) or build micro services in some other language and simply use Orchestrator to tie it all together. I wish it was some other language than Groovy but at least they picked an open standard language and didn't create some proprietary scripting language. Click to expand.I have only worked with Orchestrator a little bit so I am very far from being a SME on it and I certainly have some issues with it but from the little that I have seen I think it gives you quite a bit of options and ways to do things so I am not sure I would call it "primitive".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |