BIRT Report processes grid in reverse order in web viewer - birt

I have a BIRT report with 2 datasets Measure that returns a single row name and a number, and Contracts which returns a contract type and a value.
The report is laid out to show the measure and then the list of contracts and values. I want to do a ratio of the contract value to the measure, the whole thing looking like:
MEASURE 1 --- 200
CONTRACT TYPE 1 --- 1000 --- 0.2
CONTRACT TYPE 2 --- 200 --- 1.0
CONTRACT TYPE 3 --- 400 --- 0.5
This is done by setting up a hierarchy in the Report Layout as follows:
+ Report Layout
++ Grid
+++ Table (bound to measure data set, has OnRender trigger that sets global variable for measure name and number)
++ Grid
+++ Table (bound to Contract Type data set)
++++ Cell
+++++ Bound data element with a formula that gets the global variable for the Measure and does the contract value / measure number math
This works exactly as expected when I run the report from the previewer in the Eclipse designer.
When I run on the web viewer, all the ratios are blank.
So I put a logging in the OnRender trigger and the formula to see what the global variables are set to.
When I run in the previewer, I get the following results:
-- measure name global variable - Enrollment
-- measure value global variable - 14000
--- contract ratio cal get measure value -- 14000
--- contract ratio cal get measure value -- 14000
--- contract ratio cal get measure value -- 14000
--- (and so on, one for each contract type row returned.)
When I run in the web viewer, I get the following results
--- contract ratio cal get measure value -- null
--- contract ratio cal get measure value -- null
--- contract ratio cal get measure value -- null
--- (and so on, one for each contract type row returned.
-- measure name global variable - Enrollment
-- measure value global variable - 14000
In other words, in the previewer the top of the report grid cell and data set execute first, and in the web viewer, the order is reversed.
What I'm finding says that execution should happen in the order it appears in the Report Layout hierarchy in the designer. Anyone have any idea what I can do?
Thanks,
Steve

The main difference between a preview and the webviewer is, a preview does not have a specific render step. Technically, a preview is a "RunAndRender" task, when webviewer has two distinct "run" and "render" tasks. This is why sometimes we can see this kind of differences.
As you describe the issue, it seems this global variable is defined in "onRender" script of your measure datafield, but it is consumed by contracts from "onCreate" "onPrepare", or from an expression of an element.
Anyway to solve the problem you would better set this global variable in onCreate script and make it persistent, to be sure it can be consumed from onRender events. To make a global var persistent there are two options:
Report variable: create a report variable in your outline and use it with vars["myVariable"]
old fashion: use reportContext.setPersistentGlobalVariable and reportContext.getPersistentGlobalVariable

It is generally not a good idea to do calculations in the onRender events.
You should move your code to the onCreate events instead.

After reading the information found in this question that discusses the differences between the generation phase and presentation phase in the web viewer, I altered my approach.
I created the global variables in the OnFetch trigger for the dataset, which made them available to include in the data elements placed in the Contract section of my report.
The results now duplicate what was being generated in the previewer.

Related

AnyLogic population cannot enter process -> location of agents missing

I created a model in which transporters should arrive at the same time as a dataset I collected in real-life. But when I run my model, the following Error occurs:
Exception during discrete event execution:
root.<population>[0]:
This agent isn't located in any space
My steps until now:
Create a population with agents of the type of my agents and fill them with the values of my data
create an event which checks every minute for all objects of my population if their arrival time equals the models time
Write a function that enters them into my process and on the road to come to my factory
Therefor every transporter exists already before being entered into my process so that the event can check the condition.
My problem:
When the condition is true and the object should enter my process an error occurs:
Exception during discrete event execution:
root.<population>[0]:
This agent isn't located in any space
Other times when I run the model, this error occurs:
root.mplkws[-1]:
This agent is already defined as agent living in space 'Discrete 2D' and can't have behaviour for space 'Continuous'
I don't understand why they dont have their initial space already. Everything was created in the Main method and I dont know how and where to change the populations agents location
I tried to set the space on the enter block with agent.setSpace(getSpace())but nothing changed.

How to retrieve all rules of a quality profile using the web api?

I have run a analysis on Sonarqube with Codescan. The number of issues returned, is way above the 10000 web api limit. Therefore, within my client/code I wanted to loop through all of the rules within a quality profile and return all the issues per rule.
How can I get a list of rules using the web api from java?
You can use api/qualityprofiles/backup. It takes a quality profile key as parameter and returns an xml containing all "active rules".
Newer SonarQube versions do not have the 10K issues limitation.
You have to loop n-times to collect all results.
For example:
Consider a project with 44K issues.
You have to discover first how many issues you have to read, call one time the /api/issues/search with only you project key and the parameter ps ( pagesize ) equal to 100
http:///api/issues/search?componentKeys=&ps=100
You could receive an answer like this
{"total":44130,"p":1,"ps":100,"paging":{"pageIndex":1,"pageSize":100,"total":44130},"issues":[{"key":"AVtoCSNP6OwvnmtEJjae","ru..........
So we have to claim 44130 issues, using a pagesize of 100 then you must call (44130 / 100 ) + 1 times the /api/issues/search for your project and for every request remember to increase by 1 the p ( page ) parameter ( so you can point the right portion of results )
Your sequence of command will be like this
http:///api/issues/search?componentKeys=YOUR_PROJECT_KEY>&ps=100&p=1
http:///api/issues/search?componentKeys=YOUR_PROJECT_KEY>&ps=100&p=2
http:///api/issues/search?componentKeys=YOUR_PROJECT_KEY>&ps=100&p=3
....
http:///api/issues/search?componentKeys=YOUR_PROJECT_KEY>&ps=100&p=442
Parse the result of every call and you will be obtained the list of your issues.
Cheers
Massimo

JMeter and random variable along with if controller

i want to control my sampler execution by using a random variable . I have a sequence of hits login,welcome,Bla,log out . i want the log out to be performed for 6/10 requests and let others do not login(so to speak 6 requests will perform the whole sequence including log out, 4 of them will perform will not perform log out ).How to achieve the same in JMETER
I have added a random variable rand and set it between 1-10 at the beginning of the thread group .Then just above Logout sampler i placed an IF controller were i check ${rand}>4 . How ever i always get all sequence executed . Please suggest what am i doing wrong
Your approach is a little bit weird, my expectation is that the problem is in the following areas:
Your IF Controller condition is wrong (check jmeter.log file for any suspicious entries)
Your random variable setting is wrong, i.e. it has the same value for all virtual users (threads) so they will either be executed all or none
So I would recommend using Throughput Controller or Switch Controller in order to set up this 60/40 distribution.
See Running JMeter Samplers with Defined Percentage Probability article for more details.
Random Variable in Jmeter is saved in long format be default so
${rand} > 4 won't work. You need to change
Condition to ${rand} > 4.0
or change Random Variable Output format to 00 (2 digits)
see Manual
This was accomplished by creating a combination of config element- random variable and an IF controller
1) a random variable was created with Minim and maxim value to meet above condition
2) and IF controller was able to check ${myrand}>4;
This had derived the desired result - thank you all

Getting value of linkDistance in d3

I want to print the value that my link distance returned in the console but when i do that I get only 20 which is the default value.I studied that if linkDistance is a function then ideally it gets called every time when layout starts so I should get the 2 different values that I am returning in console but it is not the case.
Any idea?

D3 ticks() does not return value if provided scale has only 1 result

I have an x-axis that displays the days that my data occurs on. The data is dynamic and sometimes I have data for only 1 day, 2 days, n days, etc.
Here is my code for displaying the days on the x-axis:
chart.x = d3.time.scale()
.range([0, chart.w]);
chart.xAxis = d3.svg.axis()
.scale(chart.x)
.orient("bottom")
.ticks(d3.time.day) // --- TODO : this is not showing the current day, for some reason...
.tickFormat(d3.time.format("%b %-d %p"));
If my data is spread on 2 days (ex: Tuesday, Wednesday), this will only display a tick for the second day (Wednesday), ie. when the day "changes" from one to another.
I want to also display a tick for the first day (Tuesday).
Even if there is only data on 1 day, I still want to display a tick for it.
Thanks you guys,
To extend the domain so that the scale starts and ends at a tick mark you use the .nice() method, as #meetamit suggested -- but "nicing" only works if you call that method after you set the domain, so that's why you might not have noticed any change. The API doesn't really make that clear, although since the method alters the domain I suppose it makes sense that changing the domain later would over-ride the effect of a previous nice() call.
Also, be sure to use the time-scale version of the method: .nice(d3.time.day) to get a domain rounded off to the nearest day as opposed to just the nearest hour.
Here's a fiddle:
http://fiddle.jshell.net/4rGQq/
The key code is simply:
xScale.domain(d3.extent(d))
//d3.extent() returns max and min of array, which become the basic domain
.nice(d3.time.day);
//nice() extends the domain to nearest start/end of a day
Compare what happens if you comment out the .nice() call after setting the domain, even with the other .nice() call during initialization of the scale. Also compare what happens if you don't specify the day-interval as a parameter to the nice method.
Can you show how chart.x is set up? Hard to tell without seeing it, but you may be able to fix it by calling chart.x.nice() (see documentation).
Otherwise, seems like you'll need to manually check the extents of its domain, and adjust them in the case of single day.
Clarification
Your code shows how you call range() but not how you call domain(), which is the important one.
It seems to me to me that if do
var domain = chart.x.domain()
console.log domain[0] == domain[1]
you'll see true getting logged whenever the data is for only one day. If so, it means you're dealing with a single point in time rather than a time range. In that case, you'll need to adjust the domain to be a longer range.
Really hard to know without even seeing an image of what you're working on.
.ticks() should be used to set the number of ticks you'd like to have on your axis, not the kind of data that should be in them. So try to set it like .ticks(3) and it should set a couple of ticks.
From the wiki:
.ticks([count])
Returns approximately count representative values from the scale's input domain. If count is not specified, it defaults to 10. The returned tick values are uniformly spaced, have human-readable values (such as multiples of powers of 10), and are guaranteed to be within the extent of the input domain. Ticks are often used to display reference lines, or tick marks, in conjunction with the visualized data. The specified count is only a hint; the scale may return more or fewer values depending on the input domain.

Resources