I have a list of object and I want to get a list from its field.
Say I pass List<Auto> autos from java side to the template on the document side. Each Auto has a field of speed.
So the result should be list of speed.
I can do it manually looping through the autos and building a new list from the speed fields.
Is there any easier solution built in for this in the freemarker something like 'autos.speed?tolist'
You are looking for the sequence built-in map, which is available from version 2.3.29. It returns a new sequence where all elements are replaced with the result of the parameter lambda, function, or method. This allows you to do:
autos?map(auto -> auto.speed)
If you want to do this in Java, see:
Create list of object from another using Java 8 Streams
There it comes down to:
autos.stream().map(Auto::getSpeed).collect(Collectors.toList());
Related
I am facing issues in performing certain actions based on the value in the excel file cell data.
Actions like if value is "NORMAL" then click Container type = Normal (radio button)
Similarly the Unit Container Value
Following is my code:
I am getting this error while performing action .WebElement("Container_Type_Normal").Click
Your error is because you can't start a line with . unless your within a with - and i can't see a with in your function. (i also don't recommend using a with as the can cause needless confusion)
The .webelement object is a catch-all type of object that is the child of other web objects or .page. You need this to be a full and valid path to the object, by this i mean start with browser().page().
You have a couple of options:
You can either make this a full path to your object based on the object repository:
Browser("<<OR Browser name>>").Page("<<OR Page name>>").WebElement("<<Your webelement name>>".click
For this, look at your OR and insert your names.
Or, option 2, you can use descriptive programming:
Browser("CreationTime:=0").Page("index:=0").WebElement("text:=" & fieldValue,"index:=0").click
That will take the browser that was created first (Creation time 0), the only page it has and the first (index 0) web element that contains your text (text is field value).
I'm assuming that you only have one browser, and that the first element that contains the text you want is what you want to click. You may need to add more layers too this or
A good approach is to mirror what is OR or use the object spy to ensure these properties are correct.
I have a UI macro that fetches a list of records and displays them into a table above some form fields. I'm not using an embedded list because I want the table to read-only and so far, haven't found a way to make an embedded list read.
In my macro I have :
<g2:evaluate var="jvar_records" object="true" >
var gr = new GlideRecord(Tables.PTC);
gr.query();
gr;
</g2:evaluate>
<j2:while test="$[jvar_records.next()]">
<tr class="$[jvar_class]">
<td>$[jvar_records.getValue('arrival_date')]</td>
<td>$[jvar_records.getValue('departure_date')]</td>
<td>$[jvar_records.getDisplayValue('certifier')]</td>
<td>$[jvar_records.getDispalayValue('trip.depart_reason_code')]</td>
</tr>
</j2:while>
The field certifier and trip are Reference fields, that I want to get the dispaly value of. But they keep coming back as empty in the macro. It works in a background-script just fine.
If I just get the value jvar_records.getValue('certifier') it correctly gives me the sys_id.
What am I missing?
Am relatively certain that, outside of the <g2: evaluate> tag, Jelly is constrained to client side API. Client side GlideRecord doesn't have a getDisplayValue function.
What I would do is have your g2:evaluate actually loop through the records and build an array of normal JavaScript objects with just the values you will need, then return that array of objects as opposed to returning the GlideRecord object with query results.
My task is to check the value of data from the global data sheet within different UIs, each of them having lots of data.
My idea was to do this in a generic way.
I create a array with the objects name, which corresponds with the name of the data sheet column
And then I just compare the content
Browser("").Page("").GENERIC_TYPE(label).GetROProperty("value") = datasheet.GetParameter(label)
Is there such a Generic Type that works for WebEdit and WebList?
You can use WebElement and this is generic as all elements on the page are web elements.
If you are reading the objects from OR, then you might have to update the element type to WebElement and it's tidious (if you are dealing with multiple objects). So the alternative way is using the below approach.
Browser("").Page("").WebElement("xpath:=//*[#common_attribute=" + element_attribute_value + "]").GetROProperty("value") = datasheet.GetParameter(label)
RocksDBStore<K,V> stores keys and values as byte[] on disk. It converts to/from K and V typed objects using Serdes provided while constructing the object of RocksDBStore<K,V>.
Given this, please help me understand the purpose of the following code in RocksDbKeyValueBytesStoreSupplier:
return new RocksDBStore<>(name,
Serdes.Bytes(),
Serdes.ByteArray());
Providing Serdes.Bytes() and Serdes.ByteArray() looks redundant.
RocksDbKeyValueBytesStoreSupplier is introduced in KAFKA-5650 (Kafka Streams 1.0.0) as part of KIP-182: Reduce Streams DSL overloads and allow easier use of custom storage engines.
In KIP-182, there is the following sentence :
The new Interface BytesStoreSupplier supersedes the existing StateStoreSupplier (which will remain untouched). This so we can provide a convenient way for users creating custom state stores to wrap them with caching/logging etc if they chose. In order to do this we need to force the inner most store, i.e, the custom store, to be a store of type <Bytes, byte[]>.
Please help me understand why we need to force custom stores to be of type <Bytes, byte[]>?
Another place (KAFKA-5749) where I found similar sentence:
In order to support bytes store we need to create a MeteredSessionStore and ChangeloggingSessionStore. We then need to refactor the current SessionStore implementations to use this. All inner stores should by of type < Bytes, byte[] >
Why?
Your observation is correct -- the PR implementing KIP-182 did miss to remove the Serdes from RocksDBStore that are not required anymore. This was fixed in 1.1 release already.
I have a list of TestRecord objects in velocity which have a method getDateExecuted which returns a java.util.date object. I would like to sort the Records by date using the sort tool.(or appropriate sorting algorithm) However I have not seen any implementations of the sort tool that aren't using an xPath node as the list argument. If the sort tool can not be used any information on creating a bubble/selection sort using only foreach loops would be helpful.
sort tool documentation:
http://velocity.apache.org/tools/devel/apidocs/org/apache/velocity/tools/generic/SortTool.html
http://www.hannonhill.com/kb/Script-Formats/#sort-tool
Add the SortTool object to the context:
context.put("sortTool", new SortTool());
In the template, you can get the sorted list (sorted by dateExecuted) as :
#foreach($testRecord in $sortTool.sort($testRecordList, "dateExecuted:asc"))
$testRecord.dateExecuted
#end
It is clearly specified in the SortTool documentation
http://velocity.apache.org/tools/devel/apidocs/org/apache/velocity/tools/generic/SortTool.html
Let me know for any issue